|
1 | | -import type { PropType } from 'vue' |
2 | 1 | import { computed, defineComponent, onMounted, reactive, shallowRef, watch, onBeforeUnmount } from "vue"; |
3 | 2 | import { debounce, throttle } from 'lodash-es'; |
4 | 3 | import isIntersectionObserverAvailable from '../utils/intersection-observer'; |
5 | 4 | import getScrollAncestor from '../utils/get-scroll-ancestor'; |
6 | 5 | import { getScrollX, getScrollY } from "../utils"; |
7 | | -import { ScrollPosition, VueNode } from "./interface"; |
| 6 | +import { LazyLoadComponentPropsFunc } from './interface'; |
8 | 7 |
|
9 | 8 | export type TrackWindowScroll = (Component: ReturnType<typeof defineComponent>) => ReturnType<typeof defineComponent> |
10 | 9 |
|
11 | 10 | export const trackWindowScroll: TrackWindowScroll = (Component) => { |
12 | 11 | const ScrollAwareComponent = defineComponent({ |
13 | 12 | name: "ScrollAwareComponent", |
14 | | - props: { |
15 | | - scrollPosition: { |
16 | | - type: Object as PropType<ScrollPosition>, |
17 | | - default: null |
18 | | - }, |
19 | | - useIntersectionObserver: { |
20 | | - type: Boolean, |
21 | | - default: true |
22 | | - }, |
23 | | - threshold: { |
24 | | - type: Number, |
25 | | - default: 300 |
26 | | - }, |
27 | | - onVisible: { |
28 | | - type: Function as PropType<() => void>, |
29 | | - default: () => { } |
30 | | - }, |
31 | | - height: { |
32 | | - type: Number, |
33 | | - default: 0 |
34 | | - }, |
35 | | - width: { |
36 | | - type: Number, |
37 | | - default: 0 |
38 | | - }, |
39 | | - delayMethod: { |
40 | | - type: String as PropType<'debounce' | 'throttle'>, |
41 | | - default: 'throttle' |
42 | | - }, |
43 | | - delayTime: { |
44 | | - type: Number, |
45 | | - default: 300 |
46 | | - }, |
47 | | - placeholder: { |
48 | | - type: Object as PropType<VueNode>, |
49 | | - default: () => { } |
50 | | - } |
51 | | - }, |
| 13 | + props: LazyLoadComponentPropsFunc(), |
52 | 14 | setup(props, { attrs }) { |
53 | 15 | const useIntersectionObserver = computed(() => props.useIntersectionObserver && isIntersectionObserverAvailable()) |
54 | 16 | const baseComponentRef = shallowRef(null) |
|
0 commit comments