diff --git a/doc/README.md b/doc/README.md index 32de9a1cc..d13c9870c 100644 --- a/doc/README.md +++ b/doc/README.md @@ -102,7 +102,7 @@ gridstack.js API * example `dragInOptions: { appendTo: 'body', helper: 'clone', handle: '.grid-stack-item-content' }` * **Note**: if you have multiple grids, it's best to call `GridStack.setupDragIn()` with same params as it only need to be done once. * **Note2**: instead of 'clone' you can also pass your own function (get passed the event). -- `draggable` - allows to override draggable options - see `DDDragOpt`. (default: `{handle: '.grid-stack-item-content', appendTo: 'body'}`) +- `draggable` - allows to override draggable options - see `DDDragOpt`. (default: `{handle: '.grid-stack-item-content', appendTo: 'body', scroll: true}`) - `dragOut` to let user drag nested grid items out of a parent or not (default false) See [example](http://gridstackjs.com/demo/nested.html) - `engineClass` - the type of engine to create (so you can subclass) default to GridStackEngine - `float` - enable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) @@ -134,6 +134,7 @@ gridstack.js API - `handle`?: string - class selector of items that can be dragged. default to '.grid-stack-item-content' - `appendTo`?: string - default to 'body' (TODO: is this even used anymore ?) - `pause`?: boolean | number - if set (true | msec), dragging placement (collision) will only happen after a pause by the user. Note: this is Global +- `scroll`?: boolean - default to 'true', enable or disable the scroll when an element is dragged on bottom or top of the grid. ### DDDragInOpt extends DDDragOpt - `helper`?: string | ((event: Event) => HTMLElement) - helper function when dropping (ex: 'clone' or your own method) diff --git a/src/gridstack.ts b/src/gridstack.ts index b1d08c6e9..653b36c41 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -2181,7 +2181,7 @@ export class GridStack { if (node._temporaryRemoved) return; // handled by dropover let distance = ui.position.top - node._prevYPix; node._prevYPix = ui.position.top; - if (!this.opts.disableAutoScroll) { + if (this.opts.draggable.scroll) { Utils.updateScrollPosition(el, ui.position, distance); } diff --git a/src/types.ts b/src/types.ts index 8acd37d4f..7d3a0913e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -15,7 +15,7 @@ export const gridDefaults: GridStackOptions = { cellHeightThrottle: 100, cellHeightUnit: 'px', column: 12, - draggable: { handle: '.grid-stack-item-content', appendTo: 'body' }, + draggable: { handle: '.grid-stack-item-content', appendTo: 'body', scroll: true }, handle: '.grid-stack-item-content', itemClass: 'grid-stack-item', margin: 10, @@ -140,9 +140,6 @@ export interface GridStackOptions { Note: only used by addGrid(), else your element should have the needed class */ class?: string; - /** disallows the scroll when dragging or resizing a widget (default?: false) */ - disableAutoScroll?: boolean; - /** disallows dragging of widgets (default?: false) */ disableDrag?: boolean; @@ -351,7 +348,7 @@ export interface DDDragOpt { /** if set (true | msec), dragging placement (collision) will only happen after a pause by the user. Note: this is Global */ pause?: boolean | number; /** default to `true` */ - // scroll?: boolean; + scroll?: boolean; /** parent constraining where item can be dragged out from (default: null = no constrain) */ // containment?: string; }