lazyScroller (beta)

Keep your hand free from scroll button.

当前为 2015-01-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name lazyScroller (beta)
  3. // @version 0.1
  4. // @description Keep your hand free from scroll button.
  5. // @namespace idmresettrial
  6. // @author idmresettrial
  7. // @run-at document-end
  8. // @grant none
  9.  
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
  11.  
  12. // Website list
  13.  
  14. // @match *://*.vozforums.com/*
  15.  
  16.  
  17. // End list
  18.  
  19.  
  20. // ==/UserScript==
  21.  
  22.  
  23. distance = 300;
  24. duration = 500;
  25. pause = 50;
  26. direct = "out";
  27.  
  28. repeat = "";
  29. lazyScroller = '<div id="lazyScroller"><div class="lazyButton" id="lazyUp">↑</div><div class="lazyButton" id="lazyDown">↓</div></div>';
  30.  
  31. $("body").append(lazyScroller);
  32. $("#lazyScroller").attr("style","position:fixed; top: 0px; left: 0px; margin:10px;");
  33. $(".lazyButton").attr("style","margin:0px; width:20px; height:20px; font-size:10px; color:#fff;line-height:20px;text-align:center;background:rgba(248, 72, 72, 0.5)");
  34.  
  35. $(document).on("mousemove",function(e) {
  36. if (Math.abs(parseInt($("#lazyScroller").css("left"))-e.clientX)>100 || Math.abs(parseInt($("#lazyScroller").css("top"))-e.clientY)>100) {
  37. $("#lazyScroller").css({"left": e.clientX, "top": e.clientY});
  38. }
  39. });
  40.  
  41. $("#lazyScroller .lazyButton").mouseover(function() {
  42. direct = $(this).attr("id");
  43. setTimeout(function() {go();},pause);
  44. $(this).css({"background": "#f84848"});
  45. });
  46.  
  47. $("#lazyScroller .lazyButton").mouseout(function() {
  48. direct = "out";
  49. clearTimeout(repeat);
  50. $(this).css({"background": "rgba(248, 72, 72, 0.5)"});
  51. });
  52.  
  53.  
  54. function go()
  55. {
  56. if (direct === "lazyUp") {
  57. $("body").animate({scrollTop: ($("body").scrollTop()-distance)}, duration);
  58. repeat = setTimeout(function() {go();},duration+pause);
  59. } else if (direct === "lazyDown") {
  60. $("body").animate({scrollTop: ($("body").scrollTop()+distance)}, duration);
  61. repeat = setTimeout(function() {go();},duration+pause);
  62. } else clearTimeout(repeat);
  63. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址