2
2
<template >
3
3
<div >
4
4
<div class =" images" >
5
- <div class =" image" v-for =" image in images " :key =" image.id" >
6
- <img :src =" image.img" :alt =" image.title" />
5
+ <div class =" image" v-for =" image in loadedImages " :key =" image.id" >
6
+ <img :src =" image.img" :alt =" image.title" width = " 300 " height = " 448 " />
7
7
</div >
8
8
</div >
9
9
<div class =" loader" v-if =" isLoading" ></div >
@@ -18,10 +18,21 @@ import InfiniteAjaxScroll from '@webcreate/infinite-ajax-scroll';
18
18
export default Vue .extend ({
19
19
data() {
20
20
return {
21
- ias: null ,
22
21
isLast: false ,
23
22
isLoading: false ,
24
- images: []
23
+ images: [
24
+ ' https://m.media-amazon.com/images/M/MV5BYzFjNzIxMmEtMzY5NS00YTgzLTkwYWEtN2FjMmY0NmNkZWY3XkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_SX300.jpg' ,
25
+ ' https://m.media-amazon.com/images/M/MV5BMTM1MTk2ODQxNV5BMl5BanBnXkFtZTcwOTY5MDg0NA@@._V1_SX300.jpg' ,
26
+ ' https://m.media-amazon.com/images/M/MV5BMzRiMGE2MmMtM2RhMy00OWNiLTljYTktOThmMmE1YjY1NjYyXkEyXkFqcGdeQXVyMTMxODk2OTU@._V1_SX300.jpg' ,
27
+ ' https://ia.media-imdb.com/images/M/MV5BOTI0MzcxMTYtZDVkMy00NjY1LTgyMTYtZmUxN2M3NmQ2NWJhXkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_SX300.jpg' ,
28
+ ' https://ia.media-imdb.com/images/M/MV5BNWMxZTgzMWEtMTU0Zi00NDc5LWFkZjctMzUxNDIyNzZiMmNjXkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_SX300.jpg' ,
29
+ ' https://m.media-amazon.com/images/M/MV5BYTk5NWE2ZjAtZmRmOS00ZGYzLWI5ZmUtMDcwODI0YWY0MTRlL2ltYWdlXkEyXkFqcGdeQXVyNjQzNDI3NzY@._V1_SX300.jpg' ,
30
+ ' https://m.media-amazon.com/images/M/MV5BYjZlYmJjYWYtZDM0NS00YmZlLWIyMTAtMDY5ZTNjZTgwMDhjXkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_SX300.jpg' ,
31
+ ' https://ia.media-imdb.com/images/M/MV5BNzM4Y2FlNzYtZmY5Yy00NzU4LTk1ODItY2NjYWYzYzUyZGM3L2ltYWdlXkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_SX300.jpg' ,
32
+ ' https://ia.media-imdb.com/images/M/MV5BNjFlOTI2OGQtMzg0YS00ZGE4LTkwMjEtZDUzYThlOTU5YjQ5XkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_SX300.jpg' ,
33
+ ' https://m.media-amazon.com/images/M/MV5BYTUwMTY1YmMtN2U5NC00YjkzLTg0YWQtZmEwNTEzZjdkNzQ2XkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_SX300.jpg' ,
34
+ ],
35
+ loadedImages: [],
25
36
};
26
37
},
27
38
mounted() {
@@ -45,16 +56,17 @@ export default Vue.extend({
45
56
return Promise .all ([
46
57
this .loadNewImage (),
47
58
this .loadNewImage (),
48
- this .loadNewImage ()
59
+ this .loadNewImage (),
49
60
]).then (() => hasNextUrl );
50
61
},
51
62
loadNewImage() {
52
63
return new Promise ((resolve ) => {
53
64
// Simulate loading of new image
54
65
setTimeout (() => {
55
- this .images .push ({
56
- title: ` A nice image random image at position ${this .images .length + 1 } ` ,
57
- img: ` https://picsum.photos/266/400?random=${this .images .length } `
66
+ this .loadedImages .push ({
67
+ id: this .loadedImages .length + 1 ,
68
+ title: ` A nice image random image at position ${this .loadedImages .length + 1 } ` ,
69
+ img: this .images [this .loadedImages .length % this .images .length ],
58
70
})
59
71
resolve ()
60
72
}, 400 )
@@ -68,10 +80,12 @@ export default Vue.extend({
68
80
.images {
69
81
margin : 0 auto ;
70
82
padding : 20px ;
71
- max-width : 400px ;
83
+ display : flex ;
84
+ flex-wrap : wrap ;
85
+ gap : 20px ;
86
+ justify-content : center ;
72
87
}
73
88
.image {
74
- margin-top : 20px ;
75
89
padding : 20px ;
76
90
border : 10px solid #666 ;
77
91
0 commit comments