mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Only update scrollTop/Left when they change
This avoids forcing a reflows in some circumnstances.
This commit is contained in:
committed by
Antonio Scandurra
parent
fadde63ec4
commit
6fefef0509
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user