Skip to content

Commit 3e35a59

Browse files
committed
feat: refactor type
1 parent c3f5aa0 commit 3e35a59

File tree

3 files changed

+9
-79
lines changed

3 files changed

+9
-79
lines changed

src/components/PlaceholderWithTracking.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { defineComponent } from 'vue';
22
import { trackWindowScroll } from './trackWindowScroll.tsx';
33
import PlaceholderWithoutTracking from './PlaceholderWithoutTracking';
4-
import { PlaceholderWithTrackingPropsFunc } from './interface.ts';
4+
import { LazyLoadComponentPropsFunc } from './interface.ts';
55
const PlaceholderWithTracking = defineComponent({
66
compatConfig: { MODE: 3 },
77
name: 'PlaceholderWithTracking',
88
inheritAttrs: false,
9-
props: PlaceholderWithTrackingPropsFunc(),
9+
props: LazyLoadComponentPropsFunc(),
1010
setup(props) {
1111
return () => <PlaceholderWithoutTracking {...props} />;
1212
},

src/components/PlaceholderWithoutTracking.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { computed, onMounted, shallowRef, defineComponent } from 'vue';
33

44
import isIntersectionObserverAvailable from '../utils/intersection-observer';
55
import { getObserver } from '../utils';
6-
import { PlaceholderWithoutTrackingPropsFunc } from './interface';
6+
import { LazyLoadComponentPropsFunc } from './interface';
77

88
export default defineComponent({
99
name: 'PlaceholderWithoutTracking',
1010
inheritAttrs: false,
11-
props: PlaceholderWithoutTrackingPropsFunc(),
11+
props: LazyLoadComponentPropsFunc(),
1212
setup(props, { emit }) {
1313
const placeholder = shallowRef<HTMLElement>();
1414
const supportsObserver = computed(
@@ -86,4 +86,4 @@ export default defineComponent({
8686
);
8787
};
8888
},
89-
}) as DefineComponent<ReturnType<typeof PlaceholderWithoutTrackingPropsFunc>>;
89+
}) as DefineComponent<ReturnType<typeof LazyLoadComponentPropsFunc>>;

src/components/interface.ts

Lines changed: 4 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export type Effect = 'blur' | 'black-and-white' | 'opacity';
6868
export const LazyLoadImagePropsFunc = () => {
6969
return {
7070
...LazyLoadComponentPropsFunc(),
71+
placeholderSrc: {
72+
type: String,
73+
default: '',
74+
},
7175
onImageError: {
7276
type: Function as PropType<(payload: Event) => void>,
7377
default: () => {},
@@ -76,10 +80,6 @@ export const LazyLoadImagePropsFunc = () => {
7680
type: String as PropType<Effect>,
7781
default: '',
7882
},
79-
placeholderSrc: {
80-
type: String,
81-
default: '',
82-
},
8383
wrapperClassName: {
8484
type: String,
8585
default: '',
@@ -94,73 +94,3 @@ export const LazyLoadImagePropsFunc = () => {
9494
},
9595
};
9696
};
97-
98-
export const PlaceholderWithoutTrackingPropsFunc = () => ({
99-
style: {
100-
type: Object as PropType<Partial<CSSProperties>>,
101-
default: () => {},
102-
},
103-
class: {
104-
type: String,
105-
default: '',
106-
},
107-
scrollPosition: {
108-
type: Object as PropType<ScrollPosition>,
109-
default: null,
110-
},
111-
useIntersectionObserver: {
112-
type: Boolean,
113-
default: true,
114-
},
115-
threshold: {
116-
type: Number,
117-
default: 300,
118-
},
119-
onVisible: {
120-
type: Function as PropType<(entry: IntersectionObserverEntry) => void>,
121-
default: () => {},
122-
},
123-
height: {
124-
type: Number,
125-
default: 100,
126-
},
127-
width: {
128-
type: Number,
129-
default: 100,
130-
},
131-
placeholder: {
132-
type: Object as PropType<VueNode>,
133-
default: () => {},
134-
},
135-
});
136-
137-
export const PlaceholderWithTrackingPropsFunc = () => ({
138-
scrollPosition: {
139-
type: Object as PropType<ScrollPosition>,
140-
default: null,
141-
},
142-
useIntersectionObserver: {
143-
type: Boolean,
144-
default: true,
145-
},
146-
threshold: {
147-
type: Number,
148-
default: 300,
149-
},
150-
onVisible: {
151-
type: Function as PropType<(entry: IntersectionObserverEntry) => void>,
152-
default: () => {},
153-
},
154-
height: {
155-
type: Number,
156-
default: 0,
157-
},
158-
width: {
159-
type: Number,
160-
default: 0,
161-
},
162-
placeholder: {
163-
type: Object as PropType<VueNode>,
164-
default: () => {},
165-
},
166-
});

0 commit comments

Comments
 (0)