Permalink
Browse files

remove unnecessary $(document).ready() in gesture.js

References #303
  • Loading branch information...
1 parent 7fe2438 commit c25581368d803a65178d01482ec4fb10ee0730cb @mislav mislav committed Nov 3, 2011
Showing with 17 additions and 19 deletions.
  1. +16 −18 src/gesture.js
  2. +1 −1 test/gesture_functional.html
View
@@ -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){
@@ -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>

0 comments on commit c255813

Please sign in to comment.