index-list.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // let over = document.querySelector('.infoContent .tab-content').offsetHeight+600;
  2. const navCollapse = document.querySelector('#nav-collapse');
  3. const navCollapse2 = document.querySelector('.scroll-nav-collapse');
  4. if (screen.width < 600) {
  5. // window.location.href = `./index_designerList.html?cid=${cid}`;
  6. let over = document.querySelector('.infoContent .tab-content').offsetHeight+500;
  7. function fixedOnOver() {
  8. if(window.pageYOffset >= over){
  9. navCollapse.classList.add('sticky');
  10. } else {
  11. navCollapse.classList.remove('sticky');
  12. }
  13. }
  14. }
  15. else{
  16. let over = document.querySelector('.infoContent .tab-content').offsetHeight+600;
  17. function fixedOnOver() {
  18. if(window.pageYOffset >= over){
  19. navCollapse.classList.add('sticky');
  20. navCollapse2.classList.add('pt-5')
  21. } else {
  22. navCollapse.classList.remove('sticky');
  23. navCollapse2.classList.remove('pt-5')
  24. }
  25. }
  26. }
  27. window.addEventListener('scroll', fixedOnOver);
  28. // function fixedOnOver() {
  29. // if(window.pageYOffset >= over){
  30. // navCollapse.classList.add('sticky');
  31. // } else {
  32. // navCollapse.classList.remove('sticky');
  33. // }
  34. // }
  35. function scrollTest() {
  36. let page = 2;
  37. let cardData;
  38. let is_update = 0;
  39. $(window).scroll(function() {
  40. if($(window).scrollTop() + $(window).height() >= ($(document).height() - 400) && is_update == 0) {
  41. is_update = 1;
  42. if(is_update == 1) {
  43. $.ajax({
  44. method: "GET",
  45. url: `https://m3.hhh.com.tw:18686/gencase?id=14151&sort=new&page=${page}`,
  46. headers: {'accept': 'application/json'}
  47. }).done(function (msg) {
  48. $('.CaseNews-Card').append(CaseNews);
  49. if(cardData.length > 0) {
  50. is_update = 0;
  51. page ++;
  52. } else {
  53. is_update = 1;
  54. }
  55. });
  56. }
  57. }
  58. })
  59. }