diff --git a/src/commands/view/ComponentDrag.js b/src/commands/view/ComponentDrag.js index ded945c73..332425dd0 100644 --- a/src/commands/view/ComponentDrag.js +++ b/src/commands/view/ComponentDrag.js @@ -26,8 +26,8 @@ module.exports = { onDrag: this.onDrag, getPosition: this.getPosition, setPosition: this.setPosition, - getGuidesStatic: () => this.guidesStatic, - getGuidesTarget: () => this.guidesTarget, + guidesStatic: () => this.guidesStatic, + guidesTarget: () => this.guidesTarget, ...dragger }; this.setupGuides(); diff --git a/src/utils/Dragger.js b/src/utils/Dragger.js index c2da717e5..1b669a328 100644 --- a/src/utils/Dragger.js +++ b/src/utils/Dragger.js @@ -48,15 +48,11 @@ export default class Dragger { // Offset before snap to guides snapOffset: 5, - /** - * Get static guides - */ - getGuidesStatic: () => [], + // Static guides to be snapped + guidesStatic: null, - /** - * Get target guides - */ - getGuidesTarget: () => [], + // Target guides that will snap to static one + guidesTarget: null, // Document on which listen to pointer events doc: 0, @@ -94,13 +90,14 @@ export default class Dragger { * @param {Event} e */ start(ev) { - const { onStart, getGuidesStatic, getGuidesTarget } = this.opts; + const { opts } = this; + const { onStart } = opts; this.toggleDrag(1); this.startPointer = this.getPointerPos(ev); isFunction(onStart) && onStart(ev, this); this.startPosition = this.getStartPosition(); - this.guidesStatic = getGuidesStatic(); - this.guidesTarget = getGuidesTarget(); + this.guidesStatic = result(opts, 'guidesStatic') || []; + this.guidesTarget = result(opts, 'guidesTarget') || []; this.drag(ev); }