rollFu.js 788 B

12345678910111213141516171819202122232425262728293031323334
  1. export default function useRollFu() {
  2. // 滚动事件处理器(传入滚动元素和前进后退函数)
  3. // const handleScroll = throttle(function (event, fu) {
  4. // const st = event.target.scrollTop
  5. // console.log(st)
  6. // // if (st > lastScrollTop.value) {
  7. // // console.log('向下滚动')
  8. // // fu(1)
  9. // // } else {
  10. // // console.log('向上滚动')
  11. // // fu(-1)
  12. // // }
  13. // // lastScrollTop.value = st <= 0 ? 0 : st // For Firefox
  14. // }, 1000)
  15. const handleScroll = function (event, fu) {
  16. // const st = event.target.scrollTop
  17. if (event.deltaY < 0) {
  18. console.log('滚轮上滑')
  19. fu(-1)
  20. } else if (event.deltaY > 0) {
  21. console.log('滚轮下滑')
  22. fu(1)
  23. }
  24. }
  25. return {
  26. handleScroll
  27. }
  28. }