ppRoll.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. function ppRoll(a)
  2. {
  3. this.myA = a;
  4. this.myA.IsPlay = 1;
  5. this.$(a.demo).style.overflow = "hidden";
  6. this.$(a.demo).style.width = a.width;
  7. this.$(a.demo).style.height = a.height;
  8. this.$(a.demo2).innerHTML=this.$(a.demo1).innerHTML;
  9. this.$(a.demo).scrollTop=this.$(a.demo).scrollHeight;
  10. this.Marquee();
  11. this.$(a.demo).onmouseover=function() {eval(a.objStr+".clearIntervalpp();");}
  12. this.$(a.demo).onmouseout=function() {eval(a.objStr+".setTimeoutpp();")}
  13. }
  14. ppRoll.prototype.$ = function(Id)
  15. {
  16. return document.getElementById(Id);
  17. }
  18. ppRoll.prototype.getV = function(){
  19. alert(this.$(this.myA.demo2).offsetWidth-this.$(this.myA.demo).scrollLeft);
  20. alert(this.$(this.myA.demo2).offsetWidth);
  21. alert(this.$(this.myA.demo).scrollLeft);}
  22. ppRoll.prototype.Marquee = function()
  23. {
  24. this.MyMar=setTimeout(this.myA.objStr+".Marquee();",this.myA.speed);
  25. if(this.myA.IsPlay == 1)
  26. {
  27. //向上滚动
  28. if(this.myA.direction == "top")
  29. {
  30. if(this.$(this.myA.demo).scrollTop>=this.$(this.myA.demo2).offsetHeight)
  31. this.$(this.myA.demo).scrollTop-=this.$(this.myA.demo2).offsetHeight;
  32. else{
  33. this.$(this.myA.demo).scrollTop++;
  34. }
  35. }
  36. //向下滚动
  37. if(this.myA.direction == "down")
  38. {
  39. if(this.$(this.myA.demo1).offsetTop-this.$(this.myA.demo).scrollTop>=0)
  40. this.$(this.myA.demo).scrollTop+=this.$(this.myA.demo2).offsetHeight;
  41. else{
  42. this.$(this.myA.demo).scrollTop--;
  43. }
  44. }
  45. //向左滚动
  46. if(this.myA.direction == "left")
  47. {
  48. if(this.$(this.myA.demo2).offsetWidth-this.$(this.myA.demo).scrollLeft<=0)
  49. this.$(this.myA.demo).scrollLeft-=this.$(this.myA.demo1).offsetWidth;
  50. else{
  51. this.$(this.myA.demo).scrollLeft++;
  52. }
  53. }
  54. //向右滚动
  55. if(this.myA.direction == "right")
  56. {
  57. if(this.$(this.myA.demo).scrollLeft<=0)
  58. this.$(this.myA.demo).scrollLeft+=this.$(this.myA.demo2).offsetWidth;
  59. else{
  60. this.$(this.myA.demo).scrollLeft--;
  61. }
  62. }
  63. }
  64. }
  65. ppRoll.prototype.clearIntervalpp = function()
  66. {
  67. this.myA.IsPlay = 0;
  68. }
  69. ppRoll.prototype.setTimeoutpp = function()
  70. {
  71. this.myA.IsPlay = 1;
  72. }