Source
* Get the delay for a sequent list scrolling when the item is dragged to the beginning or to the end of the list.
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
const ZBX_STYLE_SORTABLE = 'sortable';
const ZBX_STYLE_SORTABLE_LIST = 'sortable-list';
const ZBX_STYLE_SORTABLE_ITEM = 'sortable-item';
const ZBX_STYLE_SORTABLE_DRAG_HANDLE = 'sortable-drag-handle';
const ZBX_STYLE_SORTABLE_DRAGGING = 'sortable-dragging';
const SORTABLE_EVENT_DRAG_START = 'drag_start';
const SORTABLE_EVENT_DRAG_END = 'drag_end';
class CSortable extends CBaseComponent {
/**
* Create CSortable instance.
*
* @param {HTMLElement} target
*
* @returns {CSortable}
*/
constructor(target, {
is_vertical,
is_sorting_enabled = true,
drag_scroll_delay_short = 150,
drag_scroll_delay_long = 400,
wheel_step = 100,
do_activate = true
}) {
super(target);
this._is_vertical = is_vertical;
this._is_sorting_enabled = is_sorting_enabled;
this._drag_scroll_delay_short = drag_scroll_delay_short;
this._drag_scroll_delay_long = drag_scroll_delay_long;
this._wheel_step = wheel_step;
this._init();
this._registerEvents();
if (do_activate) {
this.activate();
}
}
/**
* Activate the interactive functionality.
*
* @returns {CSortable}
*/
activate() {
if (this._is_activated) {
throw Error('Instance already activated.');
}
this._fixListPos();
this._activateEvents();
this._is_activated = true;
return this;
}
/**
* Deactivate the interactive functionality.
*
* @returns {CSortable}
*/
deactivate() {
if (!this._is_activated) {
throw Error('Instance already deactivated.');
}