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, onDrag: this.onDrag,
getPosition: this.getPosition, getPosition: this.getPosition,
setPosition: this.setPosition, setPosition: this.setPosition,
getGuidesStatic: () => this.guidesStatic, guidesStatic: () => this.guidesStatic,
getGuidesTarget: () => this.guidesTarget, guidesTarget: () => this.guidesTarget,
...dragger ...dragger
}; };
this.setupGuides(); this.setupGuides();

19
src/utils/Dragger.js

@ -48,15 +48,11 @@ export default class Dragger {
// Offset before snap to guides // Offset before snap to guides
snapOffset: 5, snapOffset: 5,
/** // Static guides to be snapped
* Get static guides guidesStatic: null,
*/
getGuidesStatic: () => [],
/** // Target guides that will snap to static one
* Get target guides guidesTarget: null,
*/
getGuidesTarget: () => [],
// Document on which listen to pointer events // Document on which listen to pointer events
doc: 0, doc: 0,
@ -94,13 +90,14 @@ export default class Dragger {
* @param {Event} e * @param {Event} e
*/ */
start(ev) { start(ev) {
const { onStart, getGuidesStatic, getGuidesTarget } = this.opts; const { opts } = this;
const { onStart } = opts;
this.toggleDrag(1); this.toggleDrag(1);
this.startPointer = this.getPointerPos(ev); this.startPointer = this.getPointerPos(ev);
isFunction(onStart) && onStart(ev, this); isFunction(onStart) && onStart(ev, this);
this.startPosition = this.getStartPosition(); this.startPosition = this.getStartPosition();
this.guidesStatic = getGuidesStatic(); this.guidesStatic = result(opts, 'guidesStatic') || [];
this.guidesTarget = getGuidesTarget(); this.guidesTarget = result(opts, 'guidesTarget') || [];
this.drag(ev); this.drag(ev);
} }

Loading…
Cancel
Save