-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
84 lines (78 loc) · 2.04 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Vue Line Image Gallery</title>
<base href="/">
<meta name="viewport"
content="width=device-width, initial-scale=1">
<style href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css"></style>
<style>
body {
margin: 0;
padding: 0;
}
#app {
background-color: #f1f1f1;
}
[v-cloak] {
display: none;
}
</style>
</head>
<body>
<div id="app"
v-cloak>
<div :style="{ 'width': Width + 'px', 'padding': Padding + 'px' }">
<div v-for="line in AllLines"
:style="{ 'height': Size + 'px', 'margin-bottom': Margin + 'px' }">
<div v-for="image in line"
:style="image.BoxStyle">
<img :src="image.Src"
:style="image.ImgStyle" />
</div>
</div>
</div>
</div>
<script src="https://unpkg.com/vue"></script>
<script src="Scripts/utility.js"></script>
<script src="Scripts/images.js"></script>
<script>
shuffle(images)
// images = images.slice(0, 10)
const scrollbarWidth = getScrollbarWidth()
var app = new Vue({
el: '#app',
data: {
Size: 200,
Margin: 10,
Padding: 20,
BodyWidth: 'auto',
Width: 0,
AllLines: []
},
methods: {
handleResize: function () {
var result = getAllLinesAndWidth(images, scrollbarWidth, this.BodyWidth, this.Margin, this.Padding, this.Size)
Vue.set(this, 'Width', result.width)
Vue.set(this, 'AllLines', result.allLines)
}
},
mounted: function () {
if (this.BodyWidth === 'auto') {
window.addEventListener('resize', this.handleResize)
}
this.handleResize()
setTimeout(function () {
this.handleResize()
}.bind(this))
},
beforeDestroy: function () {
if (this.BodyWidth === 'auto') {
window.removeEventListener('resize', this.handleResize)
}
}
})
</script>
</body>
</html>