合一猎豆雷达、合一看盟、猎豆37标识物

jquery.hovertreescroll.js 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. 柯乐义
  3. http://keleyi.com
  4. */
  5. jQuery.getPos = function (e) {
  6. var l = 0;
  7. var t = 0;
  8. var w = jQuery.intval(jQuery.css(e, 'width'));
  9. var h = jQuery.intval(jQuery.css(e, 'height'));
  10. var wb = e.offsetWidth;
  11. var hb = e.offsetHeight;
  12. while (e.offsetParent) {
  13. l += e.offsetLeft + (e.currentStyle ? jQuery.intval(e.currentStyle.borderLeftWidth) : 0);
  14. t += e.offsetTop + (e.currentStyle ? jQuery.intval(e.currentStyle.borderTopWidth) : 0);
  15. e = e.offsetParent;
  16. }
  17. l += e.offsetLeft + (e.currentStyle ? jQuery.intval(e.currentStyle.borderLeftWidth) : 0);
  18. t += e.offsetTop + (e.currentStyle ? jQuery.intval(e.currentStyle.borderTopWidth) : 0);
  19. return { x: l, y: t, w: w, h: h, wb: wb, hb: hb };
  20. };
  21. jQuery.getClient = function (e) {
  22. if (e) {
  23. w = e.clientWidth;
  24. h = e.clientHeight;
  25. } else {
  26. w = (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth;
  27. h = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;
  28. }
  29. return { w: w, h: h };
  30. };
  31. jQuery.getScroll = function (e) {
  32. if (e) {
  33. t = e.scrollTop;
  34. l = e.scrollLeft;
  35. w = e.scrollWidth;
  36. h = e.scrollHeight;
  37. } else {
  38. if (document.documentElement && document.documentElement.scrollTop) {
  39. t = document.documentElement.scrollTop;
  40. l = document.documentElement.scrollLeft;
  41. w = document.documentElement.scrollWidth;
  42. h = document.documentElement.scrollHeight;
  43. } else if (document.body) {
  44. t = document.body.scrollTop;
  45. l = document.body.scrollLeft;
  46. w = document.body.scrollWidth;
  47. h = document.body.scrollHeight;
  48. }
  49. }
  50. return { t: t, l: l, w: w, h: h };
  51. };
  52. jQuery.intval = function (v) {
  53. v = parseInt(v);
  54. return isNaN(v) ? 0 : v;
  55. };
  56. jQuery.fn.HoverTreeScroll = function (s) {
  57. o = jQuery.speed(s);
  58. return this.each(function () {
  59. new jQuery.fx.HoverTreeScroll(this, o);
  60. });
  61. };
  62. jQuery.fx.HoverTreeScroll = function (e, o) {
  63. var z = this;
  64. z.o = o;
  65. z.e = e;
  66. z.p = jQuery.getPos(e);
  67. z.s = jQuery.getScroll();
  68. z.clear = function () { clearInterval(z.timer); z.timer = null };
  69. z.t = (new Date).getTime();
  70. z.step = function () {
  71. var t = (new Date).getTime();
  72. var p = (t - z.t) / z.o.duration;
  73. if (t >= z.o.duration + z.t) {
  74. z.clear();
  75. setTimeout(function () { z.scroll(z.p.y, z.p.x) }, 13);
  76. } else {
  77. st = ((-Math.cos(p * Math.PI) / 2) + 0.5) * (z.p.y - z.s.t) + z.s.t;
  78. sl = ((-Math.cos(p * Math.PI) / 2) + 0.5) * (z.p.x - z.s.l) + z.s.l;
  79. z.scroll(st, sl);
  80. }
  81. };
  82. z.scroll = function (t, l) { window.scrollTo(l, t) };
  83. z.timer = setInterval(function () { z.step(); }, 13);
  84. };
  85. /*
  86. http://hovertree.com
  87. */