Skip to content

Commit f5a4993

Browse files
committed
Improving scroll performance in in latest vue version. #72
1 parent 7352b73 commit f5a4993

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

index.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,21 @@
133133
return
134134
}
135135

136-
delta.end = zone.end
137-
delta.start = zone.start
138-
this.$forceUpdate()
136+
// we'd better make sure calls as less as possible.
137+
if (zone.start !== delta.start || zone.end !== delta.end) {
138+
delta.end = zone.end
139+
delta.start = zone.start
140+
this.forceRender()
141+
}
142+
},
143+
144+
// force render ui list if we needed.
145+
// call this before the next repaint to get better performance.
146+
forceRender () {
147+
var that = this
148+
window.requestAnimationFrame(function () {
149+
that.$forceUpdate()
150+
})
139151
},
140152

141153
// return the scroll passed items count in variable.
@@ -358,7 +370,7 @@
358370
this.alter = ''
359371
delta.end = zone.end
360372
delta.start = zone.start
361-
this.$forceUpdate()
373+
this.forceRender()
362374
}
363375
},
364376

0 commit comments

Comments
 (0)