Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Correctly forward preventDefault for mouse and pointer events
Browse files Browse the repository at this point in the history
Fixes #18
Fixes #20
  • Loading branch information
dfreedm committed Jul 11, 2014
1 parent 5490290 commit e0fbe4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 5 additions & 8 deletions samples/simple/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width user-scalable=no">
<meta name="viewport" content="width=device-width, user-scalable=no">
<title>polymer-gestures testing ground</title>
<style>
* {
Expand Down Expand Up @@ -70,7 +70,9 @@
<div id="enterleave">
</div>
</div>
<div id="wrapper"><div id="output"></div></div>
<div id="wrapper">
<div id="output"></div>
</div>
<script>
var events = [
// base events
Expand All @@ -97,14 +99,9 @@
events.forEach(function(en) {
capture.addEventListener(en, function(inEvent) {
appendOutput(inEvent.type + ' [' + inEvent.pointerId + ']');
inEvent.preventDefault();
});
});
enterleave.addEventListener('pointerenter', function(e) {
appendOutput('enterleave entered');
});
enterleave.addEventListener('pointerleave', function(e) {
appendOutput('enterleave left');
});
</script>
</body>
</html>
4 changes: 3 additions & 1 deletion src/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@
}
}
// keep the semantics of preventDefault
eventCopy.preventDefault = inEvent.preventDefault;
eventCopy.preventDefault = function() {
inEvent.preventDefault();
};
return eventCopy;
},
/**
Expand Down

0 comments on commit e0fbe4c

Please sign in to comment.