File tree Expand file tree Collapse file tree 3 files changed +101
-0
lines changed Expand file tree Collapse file tree 3 files changed +101
-0
lines changed Original file line number Diff line number Diff line change 8
8
<router-link :to =" { name: 'home' }" exact >Home</router-link >
9
9
<router-link :to =" { name: 'recycle' }" >Recycle scroller demo</router-link >
10
10
<router-link :to =" { name: 'dynamic' }" >Dynamic scroller demo</router-link >
11
+ <router-link :to =" { name: 'test-chat' }" >Chat demo</router-link >
11
12
</nav >
12
13
<router-view class =" page" />
13
14
</div >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" hello" >
3
+ <div >
4
+ <button @click =" addItems()" >
5
+ Add item
6
+ </button >
7
+ <button @click =" addItems(5)" >
8
+ Add 5 items
9
+ </button >
10
+ <button @click =" addItems(10)" >
11
+ Add 10 items
12
+ </button >
13
+ </div >
14
+
15
+ <DynamicScroller
16
+ ref =" scroller"
17
+ :items =" items"
18
+ :min-item-height =" 24"
19
+ class =" scroller"
20
+ @resize =" scrollToBottom()"
21
+ >
22
+ <DynamicScrollerItem
23
+ slot-scope =" { item, index, active }"
24
+ :item =" item"
25
+ :active =" active"
26
+ :data-index =" index"
27
+ >
28
+ <div
29
+ class =" message"
30
+ :style =" {
31
+ height: `${item.size}px`,
32
+ }"
33
+ >
34
+ {{ item.text }}
35
+ </div >
36
+ </DynamicScrollerItem >
37
+ </DynamicScroller >
38
+ </div >
39
+ </template >
40
+
41
+ <script >
42
+ import faker from ' faker'
43
+
44
+ export default {
45
+ name: ' TestChat' ,
46
+
47
+ data () {
48
+ return {
49
+ items: [],
50
+ }
51
+ },
52
+
53
+ methods: {
54
+ addItems (count = 1 ) {
55
+ for (let i = 0 ; i < count; i++ ) {
56
+ this .items .push ({
57
+ text: faker .lorem .sentence (),
58
+ id: this .items .length + 1 ,
59
+ size: Math .random () * 120 + 40 ,
60
+ })
61
+ }
62
+ this .scrollToBottom ()
63
+ },
64
+
65
+ scrollToBottom () {
66
+ this .$refs .scroller .scrollToBottom ()
67
+ },
68
+ },
69
+ }
70
+ </script >
71
+
72
+ <style scoped>
73
+ h1 ,
74
+ h2 {
75
+ font-weight : normal ;
76
+ }
77
+ ul {
78
+ list-style-type : none ;
79
+ padding : 0 ;
80
+ }
81
+ li {
82
+ display : inline-block ;
83
+ margin : 0 10px ;
84
+ }
85
+ a {
86
+ color : #42b983 ;
87
+ }
88
+
89
+ .scroller {
90
+ height : 500px ;
91
+ border : 2px solid #ddd ;
92
+ }
93
+
94
+ .message {
95
+ padding : 10px 10px 9px ;
96
+ border-bottom : solid 1px #eee ;
97
+ }
98
+ </style >
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import VueRouter from 'vue-router'
4
4
import Home from './components/Home.vue'
5
5
import Recycle from './components/RecycleScrollerDemo.vue'
6
6
import Dynamic from './components/DynamicScrollerDemo.vue'
7
+ import TestChat from './components/TestChat.vue'
7
8
8
9
Vue . use ( VueRouter )
9
10
@@ -12,5 +13,6 @@ export default new VueRouter({
12
13
{ path : '/' , name : 'home' , component : Home } ,
13
14
{ path : '/recycle' , name : 'recycle' , component : Recycle } ,
14
15
{ path : '/dynamic' , name : 'dynamic' , component : Dynamic } ,
16
+ { path : '/test-chat' , name : 'test-chat' , component : TestChat } ,
15
17
] ,
16
18
} )
You can’t perform that action at this time.
0 commit comments