Skip to content

Commit

Permalink
Merge pull request #99 from flosell/fix-win8-mouse-move-on-click
Browse files Browse the repository at this point in the history
fix issue with click-events being prevented when a device sends mouse-move events along with the click
  • Loading branch information
flosell committed Aug 18, 2015
2 parents c31befb + 9f00707 commit 2dfa2d0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/eventsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,32 @@ describe("Click events inside handle", function() {
expect(clickHandler.calls.length).toEqual(1);
expect(clickHandler.calls[0].args[0].isDefaultPrevented()).toBe(false);
});

it("should be passed through if mouse moving without changing position", function() {
var clickHandler = jasmine.createSpy();
var someX = 42;
var someY = 42;
helpers.initDragdealer('content-slider');

var wrapperPosition = $('#content-slider').offset();

$('#content-slider').click(clickHandler);
$('#content-slider .inner-button')
.simulate('mousemove',{ // to have a consistent startDrag position
clientX: someX,
clientY: someY
})
.simulate('mousedown')
.simulate('mousemove',{
clientX: someX,
clientY: someY
})
.simulate('mouseup')
.simulate('click');

expect(clickHandler.calls.length).toEqual(1);
expect(clickHandler.calls[0].args[0].isDefaultPrevented()).toBe(false);
});
});

describe("Previous DOM events", function() {
Expand Down
6 changes: 6 additions & 0 deletions src/dragdealer.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,12 @@ Dragdealer.prototype = {
this.startDrag();
},
onDocumentMouseMove: function(e) {
if ((e.clientX - this.dragStartPosition.x) === 0 &&
(e.clientY - this.dragStartPosition.y) === 0) {
// This is required on some Windows8 machines that get mouse move events without actual mouse movement
return;
}

Cursor.refresh(e);
if (this.dragging) {
this.activity = true;
Expand Down

0 comments on commit 2dfa2d0

Please sign in to comment.