Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. var page = $("html,body");
  2. var fx = function(elem, target) {
  3. var
  4. avaiableToScroll = ($(document).height() - $(window).height()),
  5. scrollTop = $(document).scrollTop(),
  6. scrollBottom = ($(document).height() - $(window).height()) - $(document).scrollTop(),
  7. scrollTo = target == 0 ? scrollTop : scrollBottom;
  8.  
  9. return elem.animate({scrollTop: target}, {duration: (((scrollTo/avaiableToScroll) || 1) * 400), easing: "linear"});
  10. };
  11. $('.subir').on('mousedown', function (e) {
  12. e.preventDefault();
  13. e.stopPropagation();
  14. fx(page, 0);
  15. });
  16.  
  17. $('.descer').on('mousedown', function(e) {
  18. e.preventDefault();
  19. e.stopPropagation();
  20. fx(page, ($(document).height() - $(window).height()));
  21. });
  22. $('.subir,.descer').on('mouseup', function (e) {
  23. e.preventDefault();
  24. e.stopPropagation();
  25. page.stop(true, false);
  26. });
  27.  
  28. $(window).scroll(function(){
  29. var scrollTop = $(document).scrollTop();
  30. if(scrollTop === 0){
  31. $('.subir').css('opacity', .5);
  32. $('.descer').css('opacity', 1);
  33. }
  34. else if(scrollTop === ($(document).height() - $(window).height())){
  35. $('.subir').css('opacity', 1);
  36. $('.descer').css('opacity', .5);
  37. }
  38. else{
  39. $('.subir').css('opacity', 1);
  40. $('.descer').css('opacity', 1);
  41. }
  42. }).trigger('scroll');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement