-
Notifications
You must be signed in to change notification settings - Fork 28
/
index.html
170 lines (163 loc) Β· 4.09 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!doctype html>
<html>
<head>
<title>An example of vue-draggable-virtual-scroll-list</title>
<script src="https://unpkg.com/[email protected]"></script>
<script src="https://cdn.rawgit.com/Marak/faker.js/v4.1.0/examples/browser/js/faker.min.js"></script>
<script src="../dist/bundle.js"></script>
<style>
html {
font: 16px/1.6 Helvetica Neue,Helvetica,Arial,sans-serif;
margin: 0;
padding 0;
}
body {
background-color: #fafafe;
margin: 2rem;
color: #000;
}
h1, h2 {
color: #fe5366;
}
#main {
font-size: 16px;
}
.example {
padding: 10px;
}
.container {
display: flex;
width: 100%;
align-items: flex-start;
}
.phrase-list {
overflow-y: auto;
height: 200px;
width: 45%;
margin: 0 2.5% 0;
border-radius: 3%;
}
.example .phrase-list:nth-child(1) {
height: 500px;
}
.example .phrase-list:nth-child(2) {
height: 300px;
}
.phrase {
display: flex;
align-items: center;
padding: 0 1em;
height: 3rem;
border-bottom: 1px solid;
background-color: #F4F1F9;
border-color: #d3d3d3;
cursor: pointer;
-webkit-transition: background-color .2s, color .2s;
transition: background-color .2s, color .2s;
}
.phrase:hover {
background-color: #fe5366;
color: #fff;
}
::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-track {
border-radius: 10px;
box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
}
::-webkit-scrollbar-thumb {
background-color: rgba(0, 0, 50, .5);
border-radius: 10px;
box-shadow:0 0 0 1px rgba(255, 255, 255, .3);
}
</style>
</head>
<body>
<div id="main">
<h1>vue-draggable-virtual-scroll-list</h1>
<section class="example">
<h2>Simple</h2>
<div class="container">
<draggable-virtual-list
class="phrase-list"
v-model="items"
:size="50"
:keeps="20"
:data-key="'id'"
:data-sources="items"
:data-component="Item"
>
</draggable-virtual-list>
</div>
</section>
<section class="example">
<h2>Two Lists</h2>
<div class="container">
<draggable-virtual-list
class="phrase-list"
group="phrase-list"
v-model="items2"
:size="50"
:keeps="20"
:data-key="'id'"
:data-sources="items2"
:data-component="Item"
>
</draggable-virtual-list>
<draggable-virtual-list
class="phrase-list"
group="phrase-list"
v-model="items3"
:size="50"
:keeps="20"
:data-key="'id'"
:data-sources="items3"
:data-component="Item"
>
</draggable-virtual-list>
</div>
</section>
</div>
<script>
const Item = {
props: {
source: {
type: Object,
default () {
return {}
},
},
},
template: `
<div class="phrase" :key="source.id">
{{ source.content }}
</div>
`
}
function generateItems(length = 100, prefix = '') {
return Array.from(
{ length },
(_, id) => ({
id: prefix ? `${prefix}-${id}` : id + '',
content: `${id}οΌ${faker.name.findName()}`
}));
}
new Vue({
el: '#main',
components: {
DraggableVirtualList,
},
data() {
return {
items: generateItems(10000),
// Make sure that elements of two lists have unique ids.
items2: generateItems(500, 'lhs-'),
items3: generateItems(100, 'rhs-'),
Item
}
},
})
</script>
</body>
</html>