diff --git a/src/utils/Dragger.js b/src/utils/Dragger.js index 95e441faa..00a6a873b 100644 --- a/src/utils/Dragger.js +++ b/src/utils/Dragger.js @@ -8,6 +8,10 @@ export default class Dragger { */ constructor(opts = {}) { this.opts = { + /** + * Element on which the drag will be executed. By default, the document will be used + */ + container: null, /** * Callback on start * onStart(ev, dragger) { @@ -76,9 +80,10 @@ export default class Dragger { toggleDrag(enable) { const docs = this.getDocumentEl(); + const container = this.getContainerEl(); const method = enable ? 'on' : 'off'; const methods = { on, off }; - methods[method](docs, 'mousemove dragover', this.drag); + methods[method](container, 'mousemove dragover', this.drag); methods[method](docs, 'mouseup dragend touchend', this.stop); methods[method](docs, 'keydown', this.cancel); } @@ -272,6 +277,11 @@ export default class Dragger { } } + getContainerEl() { + const { container } = this.opts; + return container ? [container] : this.getDocumentEl(); + } + /** * Returns documents */