Only update scrollTop/Left when they change

This avoids forcing a reflows in some circumnstances.
This commit is contained in:
Nathan Sobo
2017-03-22 16:57:03 -06:00
committed by Antonio Scandurra
parent fadde63ec4
commit 6fefef0509

View File

@@ -1866,13 +1866,26 @@ class DummyScrollbarComponent {
constructor (props) {
this.props = props
etch.initialize(this)
this.updateScrollPosition()
if (this.props.orientation === 'horizontal') {
this.element.scrollLeft = this.props.scrollLeft
} else {
this.element.scrollTop = this.props.scrollTop
}
}
update (props) {
this.props = props
update (newProps) {
const oldProps = this.props
this.props = newProps
etch.updateSync(this)
this.updateScrollPosition()
if (this.props.orientation === 'horizontal') {
if (newProps.scrollLeft !== oldProps.scrollLeft) {
this.element.scrollLeft = this.props.scrollLeft
}
} else {
if (newProps.scrollTop !== oldProps.scrollTop) {
this.element.scrollTop = this.props.scrollTop
}
}
}
// Scroll position must be updated after the inner element is updated to