1/* 2 * exScrollEvent 1.0.0 - jQuery plugin 3 * written by Cyokodog 4 * 5 * Copyright (c) 2009 Cyokodog (http://d.hatena.ne.jp/cyokodog/) 6 * Dual licensed under the MIT (MIT-LICENSE.txt) 7 * and GPL (GPL-LICENSE.txt) licenses. 8 * 9 * Built for jQuery library 10 * http://jquery.com 11 * 12 * 13 * 2013.09 add scrollYdown scrollYup 14 * 15 */ 16(function($j){ 17 $j.ex = $j.ex || {}; 18 $j.ex.scrollEvent = function( target , config ){ 19 var o = this; 20 if( typeof config == 'function') config = { 21 callback : config 22 } 23 var c = o.config = $j.extend({},$j.ex.scrollEvent.defaults,config,{ 24 target : target 25 }); 26 c.status = 0; 27 c.scroll = o.getPos(); 28 c.target.scroll(function( evt ){ 29 if (o.isMove()) { 30 c.status = (c.status == 0 ? 1 : (c.status == 1 ? 2 : c.status) ); 31 c.callback( evt , c ); 32 } 33 if(c.tm) clearTimeout(c.tm); 34 c.tm = setTimeout(function(){ 35 o.isMove(); 36 c.status = 0; 37 c.callback( evt , c ); 38 },c.delay); 39 }); 40 } 41 $j.extend($j.ex.scrollEvent.prototype,{ 42 isMove : function(){ 43 var o = this, c = o.config; 44 var pos = o.getPos(); 45 var scrollYdown = (pos.top != c.scroll.top && pos.top > c.scroll.top); 46 var scrollYup = (pos.top != c.scroll.top && pos.top < c.scroll.top); 47 var scrollX = (pos.left != c.scroll.left); 48 if(scrollYdown || scrollYup || scrollX){ 49 c.scrollYdown = scrollYdown; 50 c.scrollYup = scrollYup; 51 c.scrollX = scrollX; 52 c.prevScroll = c.scroll; 53 c.scroll = pos; 54 return true; 55 } 56 return false; 57 58 }, 59 getPos : function(){ 60 var o = this, c = o.config; 61 return { 62 top : c.target.scrollTop(), 63 left : c.target.scrollLeft() 64 } 65 } 66 }); 67 $j.ex.scrollEvent.defaults = { 68 delay : 100 69 } 70 $j.fn.exScrollEvent = function( config ){ 71 new $j.ex.scrollEvent(this , config); 72 return this; 73 }; 74})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.