lizhen_gitee 5a2b1d27f5 被忽略的 | 7 months ago | |
---|---|---|
.. | ||
AutoScroll.js | 7 months ago | |
README.md | 7 months ago | |
index.js | 7 months ago |
This plugin allows for the page to automatically scroll during dragging near a scrollable element's edge on mobile devices and IE9 (or whenever fallback is enabled), and also enhances most browser's native drag-and-drop autoscrolling. Demo:
window
: https://jsbin.com/dosilir/edit?js,outputoverflow: hidden
: https://jsbin.com/xecihez/edit?html,js,outputThis plugin is a default plugin, and is included in the default UMD and ESM builds of Sortable
import { Sortable, AutoScroll } from 'sortablejs';
Sortable.mount(new AutoScroll());
new Sortable(el, {
scroll: true, // Enable the plugin. Can be HTMLElement.
scrollFn: function(offsetX, offsetY, originalEvent, touchEvt, hoverTargetEl) { ... }, // if you have custom scrollbar scrollFn may be used for autoscrolling
scrollSensitivity: 30, // px, how near the mouse must be to an edge to start scrolling.
scrollSpeed: 10, // px, speed of the scrolling
bubbleScroll: true // apply autoscroll to all parent elements, allowing for easier movement
});
scroll
optionEnables the plugin. Defaults to true
. May also be set to an HTMLElement which will be where autoscrolling is rooted.
Demo:
window
: https://jsbin.com/dosilir/edit?js,outputoverflow: hidden
: https://jsbin.com/xecihez/edit?html,js,outputscrollFn
optionDefines function that will be used for autoscrolling. el.scrollTop/el.scrollLeft is used by default.
Useful when you have custom scrollbar with dedicated scroll function.
This function should return 'continue'
if it wishes to allow Sortable's native autoscrolling.
scrollSensitivity
optionDefines how near the mouse must be to an edge to start scrolling.
scrollSpeed
optionThe speed at which the window should scroll once the mouse pointer gets within the scrollSensitivity
distance.
bubbleScroll
optionIf set to true
, the normal autoscroll
function will also be applied to all parent elements of the element the user is dragging over.
Demo: https://jsbin.com/kesewor/edit?html,js,output