You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -15,38 +14,38 @@ $ npm i --save vue-lazy-load-image-component
15
14
<template>
16
15
<div>
17
16
<MyImage :image="image" />
18
-
<span>{{image.caption}}</span>
17
+
<span>{{image.caption}}</span>
19
18
</div>
20
19
</template>
21
-
<script lang='ts' setup>
22
-
import { LazyLoadImage } from 'vue-lazy-load-image-component';
20
+
<script lang="ts" setup>
21
+
import { LazyLoadImage } from "vue-lazy-load-image-component";
23
22
const image = ref({
24
-
alt: 'My image',
23
+
alt: "My image",
25
24
height: 100,
26
-
src: 'https://example.com/image.jpg',
25
+
src: "https://example.com/image.jpg",
27
26
width: 100,
28
-
caption: 'My image caption',
27
+
caption: "My image caption",
29
28
});
30
29
</script>
31
30
```
32
31
33
32
### Props
34
33
35
-
| Prop | Type | Default | Description |
36
-
|:---|:---|:---|:---|
37
-
| afterLoad |`Function`|| Function called after the image has been completely loaded. |
38
-
| beforeLoad |`Function`|| Function called right before the placeholder is replaced with the image element. |
39
-
| delayMethod |`String`|`throttle`| Method from lodash to use to delay the scroll/resize events. It can be `throttle` or `debounce`. |
40
-
| delayTime |`Number`| 300 | Time in ms sent to the delayMethod. |
41
-
| effect |`String`|| Name of the effect to use. Please, read next section with an explanation on how to use them. |
42
-
| placeholder |`ReactClass`|`<span>`| React element to use as a placeholder. |
43
-
| placeholderSrc |`String`|| Image src to display while the image is not visible or loaded. |
44
-
| threshold |`Number`| 100 | Threshold in pixels. So the image starts loading before it appears in the viewport. |
45
-
| useIntersectionObserver |`Boolean`| true | Whether to use browser's IntersectionObserver when available. |
46
-
| visibleByDefault |`Boolean`| false | Whether the image must be visible from the beginning. |
47
-
| wrapperClassName |`String`|| In some occasions (for example, when using a placeholderSrc) a wrapper span tag is rendered. This prop allows setting a class to that element. |
48
-
| wrapperProps |`Object`| null | Props that should be passed to the wrapper span when it is rendered (for example, when using placeholderSrc or effect) |
| afterLoad |`Function`|| Function called after the image has been completely loaded.|
37
+
| beforeLoad |`Function`|| Function called right before the placeholder is replaced with the image element.|
38
+
| delayMethod |`String`|`throttle`| Method from lodash to use to delay the scroll/resize events. It can be `throttle` or `debounce`.|
39
+
| delayTime |`Number`| 300 | Time in ms sent to the delayMethod.|
40
+
| effect |`String`|| Name of the effect to use. Please, read next section with an explanation on how to use them.|
41
+
| placeholder |`ReactClass`|`<span>`| React element to use as a placeholder.|
42
+
| placeholderSrc |`String`|| Image src to display while the image is not visible or loaded.|
43
+
| threshold |`Number`| 100 | Threshold in pixels. So the image starts loading before it appears in the viewport.|
44
+
| useIntersectionObserver |`Boolean`| true | Whether to use browser's IntersectionObserver when available.|
45
+
| visibleByDefault |`Boolean`| false | Whether the image must be visible from the beginning.|
46
+
| wrapperClassName |`String`|| In some occasions (for example, when using a placeholderSrc) a wrapper span tag is rendered. This prop allows setting a class to that element. |
47
+
| wrapperProps |`Object`| null | Props that should be passed to the wrapper span when it is rendered (for example, when using placeholderSrc or effect)|
48
+
| ... ||| Any other image attribute|
50
49
51
50
### Using effects
52
51
@@ -60,29 +59,29 @@ They rely on CSS and the corresponding CSS file must be imported:
60
59
<MyImage :image="image" />
61
60
</div>
62
61
</template>
63
-
<script lang='ts' setup>
64
-
import { LazyLoadImage } from 'vue-lazy-load-image-component';
*`blur`: renders a blurred image based on `placeholderSrc` and transitions to a non-blurred one when the image specified in the src is loaded.
76
+
-`blur`: renders a blurred image based on `placeholderSrc` and transitions to a non-blurred one when the image specified in the src is loaded.
78
77
79
78

80
79
81
-
*`black-and-white`: renders a black and white image based on `placeholderSrc` and transitions to a colorful image when the image specified in the src is loaded.
80
+
-`black-and-white`: renders a black and white image based on `placeholderSrc` and transitions to a colorful image when the image specified in the src is loaded.
82
81
83
82

84
83
85
-
*`opacity`: renders a blank space and transitions to full opacity when the image is loaded.
84
+
-`opacity`: renders a blank space and transitions to full opacity when the image is loaded.
86
85
87
86

88
87
@@ -96,24 +95,24 @@ The current available effects are:
96
95
</LazyLoadComponent>
97
96
</div>
98
97
</template>
99
-
<script lang='ts' setup>
100
-
import { LazyLoadComponent } from 'vue-lazy-load-image-component';
101
-
import MyComponent from './MyComponent.vue';
98
+
<script lang="ts" setup>
99
+
import { LazyLoadComponent } from "vue-lazy-load-image-component";
100
+
import MyComponent from "./MyComponent.vue";
102
101
</script>
103
102
```
104
103
105
104
### Props
106
105
107
-
| Prop | Type | Default | Description |
108
-
|:---|:---|:---|:---|
109
-
| afterLoad |`Function`|| Function called after the component has been rendered. |
110
-
| beforeLoad |`Function`|| Function called right before the component is rendered. |
111
-
| delayMethod |`String`|`throttle`| Method from lodash to use to delay the scroll/resize events. It can be `throttle` or `debounce`. |
112
-
| delayTime |`Number`| 300 | Time in ms sent to the delayMethod from lodash. |
113
-
| placeholder |`ReactClass`|`<span>`| React element to use as a placeholder. |
114
-
| threshold |`Number`| 100 | Threshold in pixels. So the component starts loading before it appears in the viewport. |
115
-
| useIntersectionObserver |`Boolean`| true | Whether to use browser's IntersectionObserver when available. |
116
-
| visibleByDefault |`Boolean`| false | Whether the component must be visible from the beginning. |
@@ -160,24 +158,24 @@ You must set the prop `scrollPosition` to the lazy load components. This way, th
160
158
161
159
`LazyLoadImage`
162
160
163
-
| Prop | Type | Default | Description |
164
-
|:---|:---|:---|:---|
165
-
| scrollPosition |`Object`|| Object containing `x` and `y` with the curent window scroll position. Required. |
166
-
| afterLoad |`Function`|| Function called after the image has been rendered. |
167
-
| beforeLoad |`Function`|| Function called right before the image is rendered. |
168
-
| placeholder |`ReactClass`|`<span>`| React element to use as a placeholder. |
169
-
| threshold |`Number`| 100 | Threshold in pixels. So the image starts loading before it appears in the viewport. |
170
-
| visibleByDefault |`Boolean`| false | Whether the image must be visible from the beginning. |
171
-
| wrapperProps |`Object`| null | Props that should be passed to the wrapper span when it is rendered (for example, when using placeholderSrc or effect) |
| scrollPosition |`Object`|| Object containing `x` and `y` with the curent window scroll position. Required.|
164
+
| afterLoad |`Function`|| Function called after the image has been rendered.|
165
+
| beforeLoad |`Function`|| Function called right before the image is rendered.|
166
+
| placeholder |`ReactClass`|`<span>`| React element to use as a placeholder.|
167
+
| threshold |`Number`| 100 | Threshold in pixels. So the image starts loading before it appears in the viewport.|
168
+
| visibleByDefault |`Boolean`| false | Whether the image must be visible from the beginning.|
169
+
| wrapperProps |`Object`| null| Props that should be passed to the wrapper span when it is rendered (for example, when using placeholderSrc or effect) |
170
+
| ... ||| Any other image attribute|
173
171
174
172
Component wrapped with `trackWindowScroll` (in the example, `Gallery`)
175
173
176
-
| Prop | Type | Default | Description |
177
-
|:---|:---|:---|:---|
178
-
| delayMethod |`String`|`throttle`| Method from lodash to use to delay the scroll/resize events. It can be `throttle` or `debounce`. |
179
-
| delayTime |`Number`| 300 | Time in ms sent to the delayMethod from lodash. |
180
-
| useIntersectionObserver |`Boolean`| true | Whether to use browser's IntersectionObserver when available. |
0 commit comments