author | Clipperz <info@clipperz.com> | 2013-01-09 09:03:53 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-09 09:03:53 (UTC) |
commit | 644891059e1f37d0748bc34b9ca78c05fa748214 (patch) (side-by-side diff) | |
tree | a746ee125d503088dc53dac823474e4295560947 /frontend/gamma/js/Zepto/gesture.js | |
parent | a9974c63bdcef65f009420dce095d1e39da7e3b8 (diff) | |
download | clipperz-644891059e1f37d0748bc34b9ca78c05fa748214.zip clipperz-644891059e1f37d0748bc34b9ca78c05fa748214.tar.gz clipperz-644891059e1f37d0748bc34b9ca78c05fa748214.tar.bz2 |
Added JQTouch and Zepto libraries
JQTouch and Zepto are tentatively used for the mobile version of Clipperz.
No final commitment has been made, though.
Diffstat (limited to 'frontend/gamma/js/Zepto/gesture.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/gamma/js/Zepto/gesture.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/frontend/gamma/js/Zepto/gesture.js b/frontend/gamma/js/Zepto/gesture.js new file mode 100644 index 0000000..035455b --- a/dev/null +++ b/frontend/gamma/js/Zepto/gesture.js @@ -0,0 +1,35 @@ +// Zepto.js +// (c) 2010-2012 Thomas Fuchs +// Zepto.js may be freely distributed under the MIT license. + +;(function($){ + if ($.os.ios) { + var gesture = {}, gestureTimeout + + function parentIfText(node){ + return 'tagName' in node ? node : node.parentNode + } + + $(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){ + $.fn[m] = function(callback){ return this.bind(m, callback) } + }) + } +})(Zepto) |