Browse Source

Rename guides option in Dragger

pull/1918/head
Artur Arseniev 8 years ago
parent
commit
1580e498f1
  1. 4
      src/commands/view/ComponentDrag.js
  2. 19
      src/utils/Dragger.js

4
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();

19
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);
}

Loading…
Cancel
Save