Rolling_load.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. Namespace.register("U.Rolling.load"); //命名空间 14互联网1 刘希鹏
  2. /*window.onload = function () {
  3. //U.Rolling.Create();
  4. //U.Rolling.load();
  5. }*/
  6. window.onload = function () { }
  7. U.Rolling.load.Create = function () {
  8. //创建div容器
  9. var over = $$("div", { "class": "U_Rolling_over" }, $("body")[0]);
  10. var testa = $$("div", { "class": "U_Rolling_testa" }, over);
  11. var wrap = $$("div", { "id": "U_Rolling_wrap", "class": "U_Rolling_wrap" }, testa);
  12. for (var i = 0; i < 6; i++) { //打印实际数据
  13. var main = $$("div", { "class": "U_Rolling_main" }, wrap);
  14. var test = $$("div", { "class": "U_Rolling_test" }, main);
  15. test.innerText = i;
  16. }
  17. var b = $("#U_Rolling_wrap")[0];
  18. b.onscroll = function () { U.Rolling.load.start(b); }
  19. return over;
  20. }
  21. U.Rolling.load.start = function (str) { //参数str1 获取滚动距离的div, str2表示获取全文高度的div
  22. //alert(str1);
  23. //获取滚动条的滚动的距离
  24. getScrollTop = function () {
  25. /*var scrollTop = 0;
  26. if (document.body) {
  27. !--scrollTop = document.body.scrollTop;
  28. }*/
  29. return str.scrollTop;
  30. };
  31. //获取屏幕的可见范围
  32. getClientHeight = function () {
  33. return str.clientHeight;
  34. };
  35. //获取全文的高度
  36. getScrollHeight = function () {
  37. return str.scrollHeight;
  38. };
  39. //滚动条+可视范围=完整高度
  40. if (getScrollTop() + getClientHeight() >= getScrollHeight()) {
  41. //var a = document.getElementById("wrap");
  42. //a.scrollTop+=25;
  43. //var loding = $$("div",{"id":"loding","style":"background:red;width:100%;height:25px;"},$("#wrap")[0]);
  44. //alert(1)
  45. if (document.getElementById('UCD_CT_SM_IF').contentWindow.document.getElementById('U_Rolling_txt') == undefined) { //判断这个loding的gif是否存在 不加这个限制的话 用户可以一直创建loding的gif
  46. var main = $$("div", { "class": "U_Rolling_main" }, str);
  47. var test = $$("div", { "id": "U_Rolling_txt", "class": "U_Rolling_testb" }, main);
  48. str.scrollTop += 150;
  49. var txt = setInterval(function () { //3秒后消失 有了实际的数据就不用这个计时器的 数据获取到后 就可以把gif remove掉
  50. document.getElementById('UCD_CT_SM_IF').contentWindow.document.getElementById('U_Rolling_txt').remove(); //gif remove
  51. clearInterval(txt);
  52. for (var i = 0; i < 6; i++) { //打印实际数据
  53. var main = $$("div", { "class": "U_Rolling_main" }, str);
  54. var test = $$("div", { "class": "U_Rolling_test" }, main);
  55. test.innerText = i;
  56. }
  57. }, 3000)
  58. } else { return; }
  59. }
  60. };