12345678910111213141516171819202122232425262728293031323334 |
- export default function useRollFu() {
- // 滚动事件处理器(传入滚动元素和前进后退函数)
- // const handleScroll = throttle(function (event, fu) {
- // const st = event.target.scrollTop
- // console.log(st)
- // // if (st > lastScrollTop.value) {
- // // console.log('向下滚动')
- // // fu(1)
- // // } else {
- // // console.log('向上滚动')
- // // fu(-1)
- // // }
- // // lastScrollTop.value = st <= 0 ? 0 : st // For Firefox
- // }, 1000)
- const handleScroll = function (event, fu) {
- // const st = event.target.scrollTop
- if (event.deltaY < 0) {
- console.log('滚轮上滑')
- fu(-1)
- } else if (event.deltaY > 0) {
- console.log('滚轮下滑')
- fu(1)
- }
- }
- return {
- handleScroll
- }
- }
|