mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 1329158 - Optimize maintaining scroll position in RequestListContent r=Honza
MozReview-Commit-ID: 1WUcBS3xyxb --HG-- extra : rebase_source : f22aa9c9f8ec3aa7cde11370f92fa1ab38d0eb8a
This commit is contained in:
parent
daf6e74a28
commit
3d9f9c2935
@ -40,14 +40,16 @@ const RequestListContent = createClass({
|
||||
this.refs.contentEl.addEventListener("scroll", this.onScroll, true);
|
||||
},
|
||||
|
||||
componentWillUpdate() {
|
||||
// Check if the list is scrolled to bottom, before UI update
|
||||
this.shouldScrollBottom = this.isScrolledToBottom();
|
||||
componentWillUpdate(nextProps) {
|
||||
// Check if the list is scrolled to bottom before the UI update.
|
||||
// The scroll is ever needed only if new rows are added to the list.
|
||||
const delta = nextProps.displayedRequests.size - this.props.displayedRequests.size;
|
||||
this.shouldScrollBottom = delta > 0 && this.isScrolledToBottom();
|
||||
},
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
// Update the CSS variables for waterfall scaling after props change
|
||||
this.setScalingStyles();
|
||||
this.setScalingStyles(prevProps);
|
||||
|
||||
// Keep the list scrolled to bottom if a new row was added
|
||||
if (this.shouldScrollBottom) {
|
||||
@ -72,12 +74,10 @@ const RequestListContent = createClass({
|
||||
*/
|
||||
setScalingStyles(prevProps) {
|
||||
const { scale } = this.props;
|
||||
if (scale == this.currentScale) {
|
||||
if (prevProps && prevProps.scale === scale) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentScale = scale;
|
||||
|
||||
const { style } = this.refs.contentEl;
|
||||
style.removeProperty("--timings-scale");
|
||||
style.removeProperty("--timings-rev-scale");
|
||||
|
Loading…
Reference in New Issue
Block a user