Browse Source

Trigger events for Drag mode

pull/2524/head
Artur Arseniev 7 years ago
parent
commit
c3dfffee19
  1. 47
      src/commands/view/ComponentDrag.js

47
src/commands/view/ComponentDrag.js

@ -50,16 +50,20 @@ export default {
event && drg.start(event); event && drg.start(event);
this.toggleDrag(1); this.toggleDrag(1);
this.em.trigger(`${evName}:start`, { this.em.trigger(`${evName}:start`, this.getEventOpts());
mode,
target,
guidesTarget: this.guidesTarget,
guidesStatic: this.guidesStatic
});
return drg; return drg;
}, },
getEventOpts() {
return {
mode: this.opts.mode,
target: this.target,
guidesTarget: this.guidesTarget,
guidesStatic: this.guidesStatic
};
},
stop() { stop() {
this.toggleDrag(); this.toggleDrag();
}, },
@ -354,6 +358,7 @@ export default {
onEnd && onEnd(...args); onEnd && onEnd(...args);
editor.stopCommand(id); editor.stopCommand(id);
this.hideGuidesInfo(); this.hideGuidesInfo();
this.em.trigger(`${evName}:end`, this.getEventOpts());
}, },
hideGuidesInfo() { hideGuidesInfo() {
@ -414,29 +419,31 @@ export default {
const statEdge2Raw = isY const statEdge2Raw = isY
? rect.left + rect.width ? rect.left + rect.width
: rect.top + rect.height; : rect.top + rect.height;
const pos2 = `${isY ? item.y : item.x}px`; const posFirst = isY ? item.y : item.x;
const posSecond = isEdge1 ? statEdge2 : origEdge2;
const pos2 = `${posFirst}px`;
const size = isEdge1 ? origEdge1 - statEdge2 : statEdge1 - origEdge2; const size = isEdge1 ? origEdge1 - statEdge2 : statEdge1 - origEdge2;
const sizeRaw = isEdge1 const sizeRaw = isEdge1
? origEdge1Raw - statEdge2Raw ? origEdge1Raw - statEdge2Raw
: statEdge1Raw - origEdge2Raw; : statEdge1Raw - origEdge2Raw;
guideInfoStyle.display = ''; guideInfoStyle.display = '';
guideInfoStyle[isY ? 'top' : 'left'] = pos2; guideInfoStyle[isY ? 'top' : 'left'] = pos2;
guideInfoStyle[isY ? 'left' : 'top'] = `${ guideInfoStyle[isY ? 'left' : 'top'] = `${posSecond}px`;
isEdge1 ? statEdge2 : origEdge2
}px`;
guideInfoStyle[isY ? 'width' : 'height'] = `${size}px`; guideInfoStyle[isY ? 'width' : 'height'] = `${size}px`;
elGuideInfoCnt.innerHTML = `${Math.round(sizeRaw)}px`; elGuideInfoCnt.innerHTML = `${Math.round(sizeRaw)}px`;
this.em.trigger(`${evName}:active`, {
...this.getEventOpts(),
guide: item,
guidesStatic,
matched: res,
posFirst,
posSecond,
size,
sizeRaw,
elGuideInfo,
elGuideInfoCnt
});
} }
console.log({
guide: item,
guidesStatic,
matchStatic: res
});
this.em.trigger(`${evName}:active`, {
guide: item,
guidesStatic,
matchStatic: res
});
}); });
}, },

Loading…
Cancel
Save