Skip to content

Commit c958bbf

Browse files
author
abluchet
committed
Redraw in a frame
1 parent ea0b1c6 commit c958bbf

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

examples/index.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!doctype html>
2+
<html class="no-js" lang="">
3+
<head>
4+
<meta charset="utf-8">
5+
<title></title>
6+
</head>
7+
<body>
8+
<div class="dpicker"></div>
9+
<div class="dpicker"></div>
10+
<div class="dpicker"></div>
11+
<div class="dpicker"></div>
12+
<div class="dpicker"></div>
13+
<div class="dpicker"></div>
14+
<div class="dpicker"></div>
15+
<div class="dpicker"></div>
16+
<div class="dpicker"></div>
17+
<div class="dpicker"></div>
18+
<div class="dpicker"></div>
19+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js"></script>
20+
<script src="../dist/dpicker.js"></script>
21+
<script>
22+
;[].slice.call(document.querySelectorAll('.dpicker')).forEach((e) => {
23+
var dp = new dpicker(e)
24+
})
25+
</script>
26+
</body>
27+
</html>

src/dpicker.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,9 @@ DPicker.prototype.modelSetter = function (newValue) {
543543
* Decorate it with modules to do things before redraw
544544
*/
545545
DPicker.prototype.redraw = function () {
546-
const newTree = this.getTree()
547-
this._tree = nanomorph(this._tree, newTree)
546+
window.requestAnimationFrame(() => {
547+
this._tree = nanomorph(this._tree, this.getTree())
548+
})
548549
}
549550

550551
Object.defineProperties(DPicker.prototype, {

0 commit comments

Comments
 (0)