Skip to content

Commit a6b478d

Browse files
fix(scroll): move the option to disable autoscroll (#2192)
1 parent af2fc1e commit a6b478d

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

doc/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ gridstack.js API
102102
* example `dragInOptions: { appendTo: 'body', helper: 'clone', handle: '.grid-stack-item-content' }`
103103
* **Note**: if you have multiple grids, it's best to call `GridStack.setupDragIn()` with same params as it only need to be done once.
104104
* **Note2**: instead of 'clone' you can also pass your own function (get passed the event).
105-
- `draggable` - allows to override draggable options - see `DDDragOpt`. (default: `{handle: '.grid-stack-item-content', appendTo: 'body'}`)
105+
- `draggable` - allows to override draggable options - see `DDDragOpt`. (default: `{handle: '.grid-stack-item-content', appendTo: 'body', scroll: true}`)
106106
- `dragOut` to let user drag nested grid items out of a parent or not (default false) See [example](http://gridstackjs.com/demo/nested.html)
107107
- `engineClass` - the type of engine to create (so you can subclass) default to GridStackEngine
108108
- `float` - enable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html)
@@ -134,6 +134,7 @@ gridstack.js API
134134
- `handle`?: string - class selector of items that can be dragged. default to '.grid-stack-item-content'
135135
- `appendTo`?: string - default to 'body' (TODO: is this even used anymore ?)
136136
- `pause`?: boolean | number - if set (true | msec), dragging placement (collision) will only happen after a pause by the user. Note: this is Global
137+
- `scroll`?: boolean - default to 'true', enable or disable the scroll when an element is dragged on bottom or top of the grid.
137138

138139
### DDDragInOpt extends DDDragOpt
139140
- `helper`?: string | ((event: Event) => HTMLElement) - helper function when dropping (ex: 'clone' or your own method)

src/gridstack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,7 @@ export class GridStack {
21812181
if (node._temporaryRemoved) return; // handled by dropover
21822182
let distance = ui.position.top - node._prevYPix;
21832183
node._prevYPix = ui.position.top;
2184-
if (!this.opts.disableAutoScroll) {
2184+
if (this.opts.draggable.scroll) {
21852185
Utils.updateScrollPosition(el, ui.position, distance);
21862186
}
21872187

src/types.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const gridDefaults: GridStackOptions = {
1515
cellHeightThrottle: 100,
1616
cellHeightUnit: 'px',
1717
column: 12,
18-
draggable: { handle: '.grid-stack-item-content', appendTo: 'body' },
18+
draggable: { handle: '.grid-stack-item-content', appendTo: 'body', scroll: true },
1919
handle: '.grid-stack-item-content',
2020
itemClass: 'grid-stack-item',
2121
margin: 10,
@@ -140,9 +140,6 @@ export interface GridStackOptions {
140140
Note: only used by addGrid(), else your element should have the needed class */
141141
class?: string;
142142

143-
/** disallows the scroll when dragging or resizing a widget (default?: false) */
144-
disableAutoScroll?: boolean;
145-
146143
/** disallows dragging of widgets (default?: false) */
147144
disableDrag?: boolean;
148145

@@ -351,7 +348,7 @@ export interface DDDragOpt {
351348
/** if set (true | msec), dragging placement (collision) will only happen after a pause by the user. Note: this is Global */
352349
pause?: boolean | number;
353350
/** default to `true` */
354-
// scroll?: boolean;
351+
scroll?: boolean;
355352
/** parent constraining where item can be dragged out from (default: null = no constrain) */
356353
// containment?: string;
357354
}

0 commit comments

Comments
 (0)