Skip to content

Commit 5b1ac5d

Browse files
author
liangzhenlin
committed
backup
1 parent f125b17 commit 5b1ac5d

File tree

6 files changed

+586
-363
lines changed

6 files changed

+586
-363
lines changed

demo/img/lenna.png

463 KB
Loading

demo/src/App.vue

Lines changed: 78 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,103 @@
11
<style lang="less">
2+
.container {
3+
height: 640px;
4+
overflow: auto;
5+
}
6+
7+
.lazy-ref {
8+
}
9+
10+
img {
11+
width: 200px;
12+
height: 200px;
13+
}
14+
15+
.lazy-loading {
16+
&:before {
17+
content: "";
18+
display: block;
19+
width: 40px;
20+
height: 40px;
21+
position: absolute;
22+
left: 50%;
23+
top: 50%;
24+
margin: -20px 0 0 -20px;
25+
background-color: #333;
26+
-webkit-animation: sk-rotateplane 1.2s infinite ease-in-out;
27+
animation: sk-rotateplane 1.2s infinite ease-in-out;
28+
}
29+
position: relative;
30+
width: 200px;
31+
height: 200px;
32+
}
33+
34+
@-webkit-keyframes sk-rotateplane {
35+
0% {
36+
-webkit-transform: perspective(120px)
37+
}
38+
50% {
39+
-webkit-transform: perspective(120px) rotateY(180deg)
40+
}
41+
100% {
42+
-webkit-transform: perspective(120px) rotateY(180deg) rotateX(180deg)
43+
}
44+
}
45+
46+
@keyframes sk-rotateplane {
47+
0% {
48+
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
49+
-webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg)
50+
}
51+
50% {
52+
transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
53+
-webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg)
54+
}
55+
100% {
56+
transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
57+
-webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
58+
}
59+
}
260
</style>
361
<template>
462
<div>
5-
<lazy-ref ref="lazyRef" class="lazy-ref" v-if="show">
6-
<div>
7-
<img v-lazy="{ref:'lazyRef', src:img}">
8-
</div>
9-
</lazy-ref>
63+
<div class="container">
64+
<div class="lazy-loading"></div>
65+
<lazy-ref ref="lazyRef" class="lazy-ref" opts="{classTarget:'parent'}">
66+
<div>
67+
<img v-lazy="{ref:'lazyRef', src:img}">
68+
</div>
69+
</lazy-ref>
70+
</div>
1071
<button @click="changeImg">Change img</button>
11-
<button @click="changeShow">Change show</button>
1272
</div>
1373
</template>
1474
<script>
15-
import { LazyRef, Lazy } from '../../src/index';
16-
1775
let i = 0;
1876
77+
function genImgSrc() {
78+
return 'img/lenna.png?_t=' + Math.floor(Math.random() * 100000) + '.' + Date.now();
79+
}
80+
1981
export default {
2082
data() {
2183
return {
22-
img: 'img/lena1.png',
84+
img: genImgSrc(),
2385
show: true
2486
};
2587
},
2688
methods: {
2789
changeImg() {
28-
this.img = 'img/lena' + (i++) + '.png';
90+
this.img = genImgSrc();
2991
},
3092
changeShow() {
3193
this.show = !this.show;
94+
},
95+
changeTest() {
96+
this.test = !this.test;
3297
}
33-
},
34-
components: {
35-
'lazy-target': LazyRef
36-
},
37-
directives: {
38-
'lazy': Lazy
3998
}
4099
};
100+
101+
102+
41103
</script>

demo/src/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import Vue from 'vue'
22
import app from './App'
3+
import { VueLLazyload } from '../../src/index';
4+
5+
Vue.use(VueLLazyload);
36

47
new Vue({
58
el: '#app',

0 commit comments

Comments
 (0)