images
6 years ago
stylesheets
6 years ago
themes
6 years ago
LICENSE-sizzle.txt
6 years ago
MIT-LICENSE-history.txt
6 years ago
gpl-2.0.txt
6 years ago
gpl-3.0.txt
6 years ago
jquery.browser.js
6 years ago
jquery.truncate.js
6 years ago
mwheelIntent.js
6 years ago
mwheelIntent.js
77 lines
| 1 | /** |
| 2 | * @author trixta |
| 3 | * @version 1.2 |
| 4 | */ |
| 5 | (function($){ |
| 6 | |
| 7 | var mwheelI = { |
| 8 | pos: [-260, -260] |
| 9 | }, |
| 10 | minDif = 3, |
| 11 | doc = document, |
| 12 | root = doc.documentElement, |
| 13 | body = doc.body, |
| 14 | longDelay, shortDelay |
| 15 | ; |
| 16 | |
| 17 | function unsetPos(){ |
| 18 | if(this === mwheelI.elem){ |
| 19 | mwheelI.pos = [-260, -260]; |
| 20 | mwheelI.elem = false; |
| 21 | minDif = 3; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | $.event.special.mwheelIntent = { |
| 26 | setup: function(){ |
| 27 | var jElm = $(this).bind('mousewheel', $.event.special.mwheelIntent.handler); |
| 28 | if( this !== doc && this !== root && this !== body ){ |
| 29 | jElm.bind('mouseleave', unsetPos); |
| 30 | } |
| 31 | jElm = null; |
| 32 | return true; |
| 33 | }, |
| 34 | teardown: function(){ |
| 35 | $(this) |
| 36 | .unbind('mousewheel', $.event.special.mwheelIntent.handler) |
| 37 | .unbind('mouseleave', unsetPos) |
| 38 | ; |
| 39 | return true; |
| 40 | }, |
| 41 | handler: function(e, d){ |
| 42 | var pos = [e.clientX, e.clientY]; |
| 43 | if( this === mwheelI.elem || Math.abs(mwheelI.pos[0] - pos[0]) > minDif || Math.abs(mwheelI.pos[1] - pos[1]) > minDif ){ |
| 44 | mwheelI.elem = this; |
| 45 | mwheelI.pos = pos; |
| 46 | minDif = 250; |
| 47 | |
| 48 | clearTimeout(shortDelay); |
| 49 | shortDelay = setTimeout(function(){ |
| 50 | minDif = 10; |
| 51 | }, 200); |
| 52 | clearTimeout(longDelay); |
| 53 | longDelay = setTimeout(function(){ |
| 54 | minDif = 3; |
| 55 | }, 1500); |
| 56 | e = $.extend({}, e, {type: 'mwheelIntent'}); |
| 57 | return $.event.dispatch.apply(this, arguments); |
| 58 | } |
| 59 | } |
| 60 | }; |
| 61 | $.fn.extend({ |
| 62 | mwheelIntent: function(fn) { |
| 63 | return fn ? this.bind("mwheelIntent", fn) : this.trigger("mwheelIntent"); |
| 64 | }, |
| 65 | |
| 66 | unmwheelIntent: function(fn) { |
| 67 | return this.unbind("mwheelIntent", fn); |
| 68 | } |
| 69 | }); |
| 70 | |
| 71 | $(function(){ |
| 72 | body = doc.body; |
| 73 | //assume that document is always scrollable, doesn't hurt if not |
| 74 | $(doc).bind('mwheelIntent.mwheelIntentDefault', $.noop); |
| 75 | }); |
| 76 | })(jQuery); |
| 77 |