Skip to content

Commit d83734a

Browse files
committed
Add forceAutoScrollFallback option
1 parent 0a1bab7 commit d83734a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

plugins/AutoScroll/AutoScroll.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function AutoScrollPlugin() {
2929
function AutoScroll() {
3030
this.defaults = {
3131
scroll: true,
32+
forceAutoScrollFallback: false,
3233
scrollSensitivity: 30,
3334
scrollSpeed: 10,
3435
bubbleScroll: true
@@ -106,7 +107,7 @@ function AutoScrollPlugin() {
106107
// Edge's autoscroll seems too conditional,
107108
// MACOS Safari does not have autoscroll,
108109
// Firefox and Chrome are good
109-
if (fallback || Edge || IE11OrLess || Safari) {
110+
if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
110111
autoScroll(evt, this.options, elem, fallback);
111112

112113
// Listener for pointer element change

plugins/AutoScroll/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Sortable.mount(new AutoScroll());
2626
```js
2727
new Sortable(el, {
2828
scroll: true, // Enable the plugin. Can be HTMLElement.
29+
forceAutoscrollFallback: false, // force autoscroll plugin to enable even when native browser autoscroll is available
2930
scrollFn: function(offsetX, offsetY, originalEvent, touchEvt, hoverTargetEl) { ... }, // if you have custom scrollbar scrollFn may be used for autoscrolling
3031
scrollSensitivity: 30, // px, how near the mouse must be to an edge to start scrolling.
3132
scrollSpeed: 10, // px, speed of the scrolling
@@ -40,6 +41,8 @@ new Sortable(el, {
4041
#### `scroll` option
4142
Enables the plugin. Defaults to `true`. May also be set to an HTMLElement which will be where autoscrolling is rooted.
4243

44+
**Note: Just because this plugin is enabled does not mean that it will always be used for autoscrolling. Some browsers have native drag and drop autoscroll, in which case this autoscroll plugin won't be invoked. If you wish to have this always be invoked for autoscrolling, set the option `forceAutoScrollFallback` to `true`.**
45+
4346
Demo:
4447
- `window`: https://jsbin.com/dosilir/edit?js,output
4548
- `overflow: hidden`: https://jsbin.com/xecihez/edit?html,js,output
@@ -48,6 +51,13 @@ Demo:
4851
---
4952

5053

54+
#### `forceAutoScrollFallback` option
55+
Enables sortable's autoscroll even when the browser can handle it (with native drag and drop). Defaults to `false`. This will not disable the native autoscrolling. Note that setting `forceFallback: true` in the sortable options will also enable this.
56+
57+
58+
---
59+
60+
5161
#### `scrollFn` option
5262
Useful when you have custom scrollbar with dedicated scroll function.
5363
Defines a function that will be used for autoscrolling. Sortable uses el.scrollTop/el.scrollLeft by default. Set this option if you wish to handle it differently.

0 commit comments

Comments
 (0)