index.js 598 B

1234567891011121314151617181920
  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. /**
  7. * 执行动画
  8. * @param ele 元素的选择器
  9. * @description 如果元素滚动至距离底部150px以上,添加css动效
  10. */
  11. window.showAnimate = function (ele,className){
  12. //监听页面滚动
  13. window.onscroll = function(event){
  14. if($(ele).offset().top <= $(window).height() + $(window).scrollTop() - 150){
  15. $(ele).addClass(className);
  16. }
  17. }
  18. }