/ Published in: jQuery
tinyscrollbar
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
this.update = function(bKeepScroll){ var bKeepScroll = bKeepScroll || false; var CurrentScroll = iScroll; iScroll = 0; oViewport[options.axis] = oViewport.obj[0]['offset'+ sSize]; oContent[options.axis] = oContent.obj[0]['scroll'+ sSize]; oContent.ratio = oViewport[options.axis] / oContent[options.axis]; oScrollbar.obj.toggleClass('disable', oContent.ratio >= 1); oTrack[options.axis] = options.size == 'auto' ? oViewport[options.axis] : options.size; oThumb[options.axis] = Math.min(oTrack[options.axis], Math.max(0, ( options.sizethumb == 'auto' ? (oTrack[options.axis] * oContent.ratio) : options.sizethumb ))); oScrollbar.ratio = options.sizethumb == 'auto' ? (oContent[options.axis] / oTrack[options.axis]) : (oContent[options.axis] - oViewport[options.axis]) / (oTrack[options.axis] - oThumb[options.axis]); setSize(); if(!(oContent.ratio >= 1) && bKeepScroll){ iScroll = CurrentScroll; if((iScroll + oViewport[options.axis]) > oContent[options.axis]) { iScroll = oContent[options.axis] - oViewport[options.axis]; } oContent.obj.css(sDirection, -iScroll); if((oScrollbar.ratio > 0) && (iScroll > 0)) { iPosition.now = iScroll / oScrollbar.ratio; oThumb.obj.css(sDirection, iPosition.now); } } };