Posted By

daanoz on 03/25/11


Tagged

javascript jquery tinyscrollbar


Versions (?)

tinyscrollbar - no revert scroll


 / Published in: jQuery
 

tinyscrollbar

  1. this.update = function(bKeepScroll){
  2. var bKeepScroll = bKeepScroll || false;
  3. var CurrentScroll = iScroll;
  4. iScroll = 0;
  5. oViewport[options.axis] = oViewport.obj[0]['offset'+ sSize];
  6. oContent[options.axis] = oContent.obj[0]['scroll'+ sSize];
  7. oContent.ratio = oViewport[options.axis] / oContent[options.axis];
  8. oScrollbar.obj.toggleClass('disable', oContent.ratio >= 1);
  9. oTrack[options.axis] = options.size == 'auto' ? oViewport[options.axis] : options.size;
  10. oThumb[options.axis] = Math.min(oTrack[options.axis], Math.max(0, ( options.sizethumb == 'auto' ? (oTrack[options.axis] * oContent.ratio) : options.sizethumb )));
  11. oScrollbar.ratio = options.sizethumb == 'auto' ? (oContent[options.axis] / oTrack[options.axis]) : (oContent[options.axis] - oViewport[options.axis]) / (oTrack[options.axis] - oThumb[options.axis]);
  12. setSize();
  13. if(!(oContent.ratio >= 1) && bKeepScroll){
  14. iScroll = CurrentScroll;
  15. if((iScroll + oViewport[options.axis]) > oContent[options.axis]) {
  16. iScroll = oContent[options.axis] - oViewport[options.axis];
  17. }
  18. oContent.obj.css(sDirection, -iScroll);
  19. if((oScrollbar.ratio > 0) && (iScroll > 0)) {
  20. iPosition.now = iScroll / oScrollbar.ratio;
  21. oThumb.obj.css(sDirection, iPosition.now);
  22. }
  23. }
  24. };

Report this snippet  

You need to login to post a comment.