helpcenter/Web/js/jquery/mwheelIntent.js
2018-07-13 15:35:52 +03:00

1 line
1.0 KiB
JavaScript

!function(e){function n(){this===l.elem&&(l.pos=[-260,-260],l.elem=!1,u=3)}var t,i,l={pos:[-260,-260]},u=3,h=document,o=h.documentElement,s=h.body;e.event.special.mwheelIntent={setup:function(){var t=e(this).bind("mousewheel",e.event.special.mwheelIntent.handler);return this!==h&&this!==o&&this!==s&&t.bind("mouseleave",n),t=null,!0},teardown:function(){return e(this).unbind("mousewheel",e.event.special.mwheelIntent.handler).unbind("mouseleave",n),!0},handler:function(n,h){var o=[n.clientX,n.clientY];return this===l.elem||Math.abs(l.pos[0]-o[0])>u||Math.abs(l.pos[1]-o[1])>u?(l.elem=this,l.pos=o,u=250,clearTimeout(i),i=setTimeout(function(){u=10},200),clearTimeout(t),t=setTimeout(function(){u=3},1500),n=e.extend({},n,{type:"mwheelIntent"}),(e.event.dispatch||e.event.handle).apply(this,arguments)):void 0}},e.fn.extend({mwheelIntent:function(e){return e?this.bind("mwheelIntent",e):this.trigger("mwheelIntent")},unmwheelIntent:function(e){return this.unbind("mwheelIntent",e)}}),e(function(){s=h.body,e(h).bind("mwheelIntent.mwheelIntentDefault",e.noop)})}(jQuery);