]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12752 Improve horizontal scrolling of snippets
authorJeremy Davis <jeremy.davis@sonarsource.com>
Wed, 4 Mar 2020 16:20:20 +0000 (17:20 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 5 Mar 2020 20:04:24 +0000 (20:04 +0000)
server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/SnippetViewer.tsx

index a40025118cdde6409f8c2240b062e296fae72c54..7fc1ef11460c8c31d4b6ecbd728ba6da8bc4380d 100644 (file)
@@ -65,8 +65,6 @@ interface Props {
   snippet: T.SourceLine[];
 }
 
-const SCROLL_LEFT_OFFSET = 32;
-
 export default class SnippetViewer extends React.PureComponent<Props> {
   snippetNodeRef: React.RefObject<HTMLDivElement>;
 
@@ -82,9 +80,11 @@ export default class SnippetViewer extends React.PureComponent<Props> {
     const parent = this.snippetNodeRef.current as Element;
 
     if (parent) {
+      const offset = parent.getBoundingClientRect().width / 2;
+
       scrollHorizontally(element, {
-        leftOffset: SCROLL_LEFT_OFFSET,
-        rightOffset: parent.getBoundingClientRect().width - SCROLL_LEFT_OFFSET,
+        leftOffset: offset,
+        rightOffset: offset,
         parent
       });
     }