index-list.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. let over = document.querySelector('.infoContent .tab-content').offsetHeight+200;
  2. window.addEventListener('scroll', fixedOnOver);
  3. const navCollapse = document.querySelector('#nav-collapse');
  4. function fixedOnOver() {
  5. if(window.pageYOffset >= over){
  6. navCollapse.classList.add('sticky');
  7. } else {
  8. navCollapse.classList.remove('sticky');
  9. }
  10. }
  11. function scrollTest() {
  12. let page = 2;
  13. let cardData;
  14. let is_update = 0;
  15. $(window).scroll(function() {
  16. if($(window).scrollTop() + $(window).height() >= ($(document).height() - 400) && is_update == 0) {
  17. is_update = 1;
  18. if(is_update == 1) {
  19. $.ajax({
  20. method: "GET",
  21. url: `https://m3.hhh.com.tw:18686/gencase?id=14151&sort=new&page=${page}`,
  22. headers: {'accept': 'application/json'}
  23. }).done(function (msg) {
  24. $('.CaseNews-Card').append(CaseNews);
  25. if(cardData.length > 0) {
  26. is_update = 0;
  27. page ++;
  28. } else {
  29. is_update = 1;
  30. }
  31. });
  32. }
  33. }
  34. })
  35. }