Skip to content

Commit 7413b11

Browse files
committed
fix: style
1 parent 5dad796 commit 7413b11

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-lazy-load-image-component",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"description": "vue-lazy-load-image-component",
55
"main": "lib/index.js",
66
"module": "lib/index.js",

src/components/LazyLoadComponent.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export default defineComponent({
6363
threshold={props.threshold}
6464
useIntersectionObserver={props.useIntersectionObserver}
6565
width={props.width}
66+
style={props.style}
67+
class={props.class}
6668
/>
6769
) : (
6870
<PlaceholderWithTracking
@@ -73,6 +75,8 @@ export default defineComponent({
7375
threshold={props.threshold}
7476
useIntersectionObserver={props.useIntersectionObserver}
7577
width={props.width}
78+
style={props.style}
79+
class={props.class}
7680
/>
7781
);
7882
};

src/components/LazyLoadImage.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export type LazyLoadImageProps = Partial<
1010

1111
const LazyLoadImage = defineComponent({
1212
name: 'LazyLoadImage',
13-
compatConfig: { MODE: 3 },
1413
inheritAttrs: false,
14+
compatConfig: { MODE: 3 },
1515
props: LazyLoadImagePropsFunc(),
1616
setup(props, { attrs }) {
1717
const loaded = ref(false);
@@ -27,7 +27,6 @@ const LazyLoadImage = defineComponent({
2727
function getImg() {
2828
const imgProps = computed(() => {
2929
const {
30-
class: className,
3130
afterLoad,
3231
beforeLoad,
3332
delayMethod,
@@ -41,8 +40,8 @@ const LazyLoadImage = defineComponent({
4140
visibleByDefault,
4241
wrapperClassName,
4342
wrapperProps,
44-
style,
4543
loadedClassName,
44+
onImageError,
4645
...imgProps
4746
} = props;
4847
return imgProps;
@@ -103,7 +102,6 @@ const LazyLoadImage = defineComponent({
103102
</span>
104103
);
105104
}
106-
107105
return () => {
108106
const lazyLoadImage = getLazyLoadImage();
109107
const needsWrapper = (props.effect || props.placeholderSrc) && !props.visibleByDefault;

src/components/PlaceholderWithoutTracking.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { PlaceholderWithoutTrackingPropsFunc } from './interface';
77

88
export default defineComponent({
99
name: 'PlaceholderWithoutTracking',
10+
inheritAttrs: false,
1011
props: PlaceholderWithoutTrackingPropsFunc(),
1112
setup(props) {
1213
const placeholder = shallowRef<HTMLElement>();
@@ -74,6 +75,7 @@ export default defineComponent({
7475
display: 'inline-block',
7576
height: `${props.height}px`,
7677
width: `${props.width}px`,
78+
...props.style,
7779
};
7880
});
7981
return () => {

src/components/interface.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ export const LazyLoadImagePropsFunc = () => {
9292
};
9393

9494
export const PlaceholderWithoutTrackingPropsFunc = () => ({
95+
style: {
96+
type: Object as PropType<Partial<CSSProperties>>,
97+
default: () => {},
98+
},
99+
class: {
100+
type: String,
101+
default: '',
102+
},
95103
scrollPosition: {
96104
type: Object as PropType<ScrollPosition>,
97105
default: null,

0 commit comments

Comments
 (0)