From 1dcbd368aa8c40dcdce4cedee44870d699742866 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Mon, 4 Apr 2016 15:11:48 +0200 Subject: [PATCH] SONAR-7402 improve scrolling UX --- .../apps/component-measures/details/drilldown/ListView.js | 6 +++++- .../apps/component-measures/details/drilldown/TreeView.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js index 92696dd56c7..03484927b0a 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/ListView.js @@ -51,7 +51,11 @@ export default class ListView extends React.Component { scrollToViewer () { const { container } = this.refs; const top = container.getBoundingClientRect().top + window.scrollY - 95 - 10; - window.scrollTo(0, top); + + // scroll only to top + if (window.scrollY > top) { + window.scrollTo(0, top); + } } scrollToStoredPosition () { diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeView.js b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeView.js index b66b5686bda..47fd5dbaf89 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeView.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/drilldown/TreeView.js @@ -45,7 +45,11 @@ export default class TreeView extends React.Component { scrollToViewer () { const { container } = this.refs; const top = container.getBoundingClientRect().top + window.scrollY - 95 - 10; - window.scrollTo(0, top); + + // scroll only to top + if (window.scrollY > top) { + window.scrollTo(0, top); + } } scrollToStoredPosition () { -- 2.39.5