index.js 688 B

12345678910111213141516171819202122
  1. //DOM操作、Ajax
  2. import 'http://code.jquery.com/jquery-2.1.1.min.js';
  3. //轮播图
  4. import Swiper from 'https://unpkg.com/swiper@8/swiper-bundle.esm.browser.min.js';
  5. window.Swiper = Swiper;
  6. // bootstrap
  7. import 'https://cdn.staticfile.org/bootstrap/5.1.3/js/bootstrap.min.js';
  8. /**
  9. * 执行动画
  10. * @param ele 元素的选择器
  11. * @description 如果元素滚动至距离底部150px以上,添加css动效
  12. */
  13. window.showAnimate = function (ele,className){
  14. //监听页面滚动
  15. window.onscroll = function(event){
  16. if($(ele).offset().top <= $(window).height() + $(window).scrollTop() - 150){
  17. $(ele).addClass(className);
  18. }
  19. }
  20. }