new_list.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. $(function () {
  2. // 图片懒加载
  3. $("img").lazyload();
  4. // 显示区高度
  5. let ch = document.documentElement.clientHeight || document.body.clientHeight;
  6. let lock = false;
  7. $(window).scroll(function () {
  8. if (lock) return false;
  9. // 滑动区高度
  10. let sh = document.documentElement.scrollHeight || document.body.scrollHeight;
  11. // 滑动位置
  12. let st = document.documentElement.scrollTop || document.body.scrollTop;
  13. let c = sh * 1 - ch * 1 - st * 1;
  14. if (c == 0) {
  15. lock = true;
  16. $(".my-loading").show();
  17. data().then(res => { lock = res; $(".my-loading").hide(); })
  18. }
  19. })
  20. // 加载数据
  21. function data () {
  22. let str = `<a target="_blank" href="https://www.baidu.com" class="list-item">
  23. <div class="item-img">
  24. <img data-original="https://dss2.bdstatic.com/8_V1bjqh_Q23odCf/pacific/1975401466.png"
  25. src="../imgs/app.png"
  26. alt="">
  27. </div>
  28. <div class="item-detail">
  29. <div class="title">广东省警察学院:从未委托任何个人或机构进行招生宣传;广东省警察学院:从未委托任何个人或机构进行招生宣传</div>
  30. <div class="time">高考动态<span>2021-04-21</span></div>
  31. </div>
  32. </a>`
  33. return new Promise(resolve => {
  34. setTimeout(() => {
  35. $(".list").append(str);
  36. $("img").lazyload();
  37. resolve(false)
  38. }, 2000)
  39. })
  40. }
  41. })