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

Commit

Permalink
Set default touch-action for certain gestures
Browse files Browse the repository at this point in the history
Fix sample to use correct event listener API
  • Loading branch information
dfreedm committed Aug 1, 2014
1 parent 8e29bfb commit 49fe2d0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions samples/simple/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<script src="../../polymer-gestures.js"></script>
</head>
<body>
<div id="capture" touch-action="none">
<div id="capture">
<div id="enterleave">
</div>
</div>
Expand Down Expand Up @@ -97,7 +97,7 @@
}
find('capture', 'output', 'enterleave');
events.forEach(function(en) {
PolymerGestures.addGesture(capture, en, function(inEvent) {
PolymerGestures.addEventListener(capture, en, function(inEvent) {
appendOutput(inEvent.type + ' [' + inEvent.pointerId + ']');
inEvent.preventDefault();
});
Expand Down
9 changes: 8 additions & 1 deletion src/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@
scope.activateGesture = function(node, gesture) {
var dep = dispatcher.dependencyMap[gesture];
if (dep) {
var recognizer = dispatcher.gestures[dep.index];
if (dep.listeners === 0) {
var recognizer = dispatcher.gestures[dep.index];
if (recognizer) {
recognizer.enabled = true;
}
Expand All @@ -332,6 +332,13 @@
dispatcher.register(node);
node._pgListeners = 0;
}
// TODO(dfreedm): re-evaluate bookkeeping to avoid using attributes
if (recognizer) {
var touchAction = recognizer.defaultActions && recognizer.defaultActions[gesture];
if (touchAction && !node.hasAttribute('touch-action')) {
node.setAttribute('touch-action', touchAction);
}
}
node._pgListeners++;
}
return Boolean(dep);
Expand Down
3 changes: 3 additions & 0 deletions src/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
'track',
'trackend'
],
defaultActions: {
'track': 'none'
},
WIGGLE_THRESHOLD: 4,
clampDir: function(inDelta) {
return inDelta > 0 ? 1 : -1;
Expand Down

0 comments on commit 49fe2d0

Please sign in to comment.