Skip to content

Commit

Permalink
fix(event): trigger drag and mousemove at same time
Browse files Browse the repository at this point in the history
  • Loading branch information
elaine1234 committed Mar 1, 2019
1 parent 6b23e99 commit dc7699d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/mixin/event.js
Expand Up @@ -96,9 +96,14 @@ module.exports = {
el.style.cursor = preShape.attr('cursor') || 'default';
}
}
// 拖拽过程中不会触发mousemove事件
if (dragging) {
self._emitEvent('drag', e, point, dragging);
/**
* H5原生事件中drag同时不会触发mousemove
* 但是在上层具有嵌套关系的item事件计算中需要用到drag时的mousemove
* 才能计算dragenter etc.
*/
self._emitEvent('mousemove', e, point, shape);
}
if (shape) {
if (!dragging) {
Expand Down
5 changes: 5 additions & 0 deletions test/unit/canvas/core/event-spec.js
Expand Up @@ -232,6 +232,7 @@ describe('event dispatcher', () => {
let groupEnd = false;
let clicked = false;
let count = 0;
let mousemove = 0;
rect.on('dragstart', () => {
rectDrag = true;
});
Expand All @@ -247,6 +248,9 @@ describe('event dispatcher', () => {
rect.on('drag', () => {
++count;
});
rect.on('mousemove', () => {
++mousemove;
});
rect.on('click', () => {
clicked = true;
});
Expand All @@ -273,6 +277,7 @@ describe('event dispatcher', () => {
clientX: bbox.left + 10
});
expect(count).to.equal(1);
expect(mousemove).to.equal(1);
Simulate.simulate(canvas._cfg.el, 'mouseup', {
clientY: bbox.top + 12,
clientX: bbox.left + 12
Expand Down

0 comments on commit dc7699d

Please sign in to comment.