-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjquery.jscrollie.min.js
7 lines (7 loc) · 2.39 KB
/
jquery.jscrollie.min.js
1
2
3
4
5
6
7
/* jScrollie v0.5. Released Jun 29 2011. http://github.com/joevennix/jScrollie */
(function($){$.jScrollie=function(){if($.jScrollie.scrollData==null){$body=$('body');var clearer=$('<div class="jScrollieClear" style="clear:both;"></div>').appendTo($body);$body.wrapInner('<div class="jScrollieMetaContainer"><div class="jScrollie">');var preWrap=$('<div class="jScrollieContainer">'+'<div class="jScrollieTrack">'+'<div class="jScrollieDrag">'+'<div class="jScrollieDragTop">'+'</div>'+'<div class="jScrollieDragBottom">'+'</div>'+'</div>'+'</div>'+'</div>').prependTo($body);$.jScrollie.scrollData={jScroll:$('.jScrollieContainer'),track:$('.jScrollieTrack'),drag:$('.jScrollieDrag'),dragTop:$('.jScrollieDragTop'),dragBottom:$('.jScrollieDragBottom'),content:$('body'),clearer:clearer,scroller:$('.jScrollie')};var checkRefresh=function(){console.log('checking refresh')
$.jScrollie.update();}
$.jScrollie.update();}};$.jScrollie.update=function(){$this=$(this);var scrollData=$.jScrollie.scrollData;var contentHeight=scrollData.clearer.position().top-
scrollData.content.position().top;scrollData.height=scrollData.scroller.height();scrollData.contentHeight=contentHeight;scrollData.offset=scrollData.scroller.offset();$this.unbind();var ratio=$.jScrollie.scrollData.scroller.height()/contentHeight;if(ratio<1){scrollData.jScroll.show();scrollData.jScroll.height(scrollData.scroller.height());var offset=scrollData.scroller.offset();var dragHeight=Math.max(Math.round(scrollData.scroller.height()*ratio),scrollData.dragTop.height()+scrollData.dragBottom.height());scrollData.drag.height(dragHeight);scrollData.scroller.scroll(function(event){$.jScrollie.scrollData.drag.css('top',Math.min(Math.round($.jScrollie.scrollData.scroller.scrollTop()*ratio),$.jScrollie.scrollData.scroller.height()-dragHeight)+'px');});scrollData.scroller.scroll();var unbindMousemove=function(){$('html').unbind('mousemove.jScrollie');};scrollData.drag.mousedown(function(event){unbindMousemove();var drag=scrollData.drag;var offsetTop=event.pageY-drag.offset().top;$('html').bind('mousemove.jScrollie',function(event){scrollData.scroller.scrollTop((event.pageY-scrollData.scroller.offset().top
-offsetTop)/ratio);return false;}).mouseup(unbindMousemove);return false;});scrollData.track.mousedown(function(event){scrollData.scroller.scrollTop(((event.pageY-20)/scrollData.scroller.height())*contentHeight);});}
else{$.jScrollie.scrollData.jScroll.hide();}};})(jQuery);