Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(gesture): make sure clicks properly support keys
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed Jan 28, 2015
1 parent bb82c6e commit c6d24eb
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/core/services/gesture/gesture.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ angular.module('material.core')
},
onEnd: function(ev, pointer) {
if (pointer.distance < this.state.options.maxDistance) {
this.dispatchEvent(ev, 'click');
this.dispatchEvent(ev, 'click', null, ev);
}
}
});
Expand Down Expand Up @@ -355,16 +355,25 @@ angular.module('material.core')
/*
* NOTE: dispatchEvent is very performance sensitive.
*/
function dispatchEvent(srcEvent, eventType, eventPointer) {
function dispatchEvent(srcEvent, eventType, eventPointer, /*original DOMEvent */ev) {
eventPointer = eventPointer || pointer;
var eventObj;

if (eventType === 'click') {
eventObj = document.createEvent('MouseEvents');
eventObj.initMouseEvent('click', true, true, window, {},
eventPointer.x, eventPointer.y,
eventPointer.x, eventPointer.y,
false, false, false, false, 0, null);
eventObj.initMouseEvent(
'click', true, true, window, ev.detail,
ev.screenX, ev.screenY, ev.clientX, ev.clientY,
ev.ctrlKey, ev.altKey, ev.shiftKey, ev.metaKey,
ev.button, ev.relatedTarget || null
);
angular.extend(eventObj, {
which: ev.which,
x: ev.x, y: ev.y,
offsetX: ev.offsetX, offsetY: ev.offsetY,
layerX: ev.layerX, layerY: ev.layerY
});

} else {
eventObj = document.createEvent('CustomEvent');
eventObj.initCustomEvent(eventType, true, true, {});
Expand Down

3 comments on commit c6d24eb

@koraytaylan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be an error with this commit because the demo website is broken for safari right now :(

@ajoslin
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed via daa0131.

We really need automated testing in all browsers.

@koraytaylan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 yup working again!

it's funny that I instantly noticed it as I was traveling along the docs and it suddenly stopped working 😄

Please sign in to comment.