Skip to content

Commit

Permalink
remove unnecessary $(document).ready() in gesture.js
Browse files Browse the repository at this point in the history
References madrobby#303
  • Loading branch information
mislav committed Nov 3, 2011
1 parent 7fe2438 commit c255813
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
34 changes: 16 additions & 18 deletions src/gesture.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@
return 'tagName' in node ? node : node.parentNode;
}

$(document).ready(function(){
$(document.body).bind('gesturestart', function(e){
var now = Date.now(), delta = now - (gesture.last || now);
gesture.target = parentIfText(e.target);
gestureTimeout && clearTimeout(gestureTimeout);
gesture.e1 = e.scale;
gesture.last = now;
}).bind('gesturechange', function(e){
gesture.e2 = e.scale;
}).bind('gestureend', function(e){
if (gesture.e2 > 0) {
Math.abs(gesture.e1 - gesture.e2) != 0 && $(gesture.target).trigger('pinch') &&
$(gesture.target).trigger('pinch' + (gesture.e1 - gesture.e2 > 0 ? 'In' : 'Out'));
gesture.e1 = gesture.e2 = gesture.last = 0;
} else if ('last' in gesture) {
gesture = {};
}
});
$(document).bind('gesturestart', function(e){
var now = Date.now(), delta = now - (gesture.last || now);
gesture.target = parentIfText(e.target);
gestureTimeout && clearTimeout(gestureTimeout);
gesture.e1 = e.scale;
gesture.last = now;
}).bind('gesturechange', function(e){
gesture.e2 = e.scale;
}).bind('gestureend', function(e){
if (gesture.e2 > 0) {
Math.abs(gesture.e1 - gesture.e2) != 0 && $(gesture.target).trigger('pinch') &&
$(gesture.target).trigger('pinch' + (gesture.e1 - gesture.e2 > 0 ? 'In' : 'Out'));
gesture.e1 = gesture.e2 = gesture.last = 0;
} else if ('last' in gesture) {
gesture = {};
}
});

['pinch', 'pinchIn', 'pinchOut'].forEach(function(m){
Expand Down
2 changes: 1 addition & 1 deletion test/gesture_functional.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<body>
<h1>Zepto gestures functional test</h1>

<div id="gesture_test" style="width: 200px; height: 200px; background: #ddd">
<div id="gesture_test" style="width: 200px; height: 200px; background: #ddd; -webkit-user-select: none">
gesture events test
</div>

Expand Down

0 comments on commit c255813

Please sign in to comment.