]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5718 Fix scrolling between issues
authorStas Vilchik <stasvilchik@Stas-Vilchik-iMac.local>
Wed, 10 Dec 2014 09:41:45 +0000 (10:41 +0100)
committerStas Vilchik <stasvilchik@Stas-Vilchik-iMac.local>
Wed, 10 Dec 2014 09:41:45 +0000 (10:41 +0100)
server/sonar-web/src/main/coffee/issues/component-viewer/main.coffee
server/sonar-web/src/main/coffee/issues/workspace-list-view.coffee

index 098e878aa454783a3e1457175a3de06b76ab20b9..2b0be2c80b30f31df8b0a823e3beb92734e66537 100644 (file)
@@ -91,8 +91,7 @@ define [
       selected = @options.app.state.get 'selectedIndex'
       selectedIssue = @options.app.issues.at selected
       if selectedIssue.get('component') == @model.get('key')
-        selectedKey = selectedIssue.get 'key'
-        @scrollToIssue selectedKey
+        @scrollToLine selectedIssue.get('line')
       else
         @unbindShortcuts()
         @options.app.controller.showComponentViewer selectedIssue
index e0fd474ce6329fd5567feabef106f79dbc031799..ac346acc243b895a478f8bc1285821898bd4acc3 100644 (file)
@@ -12,7 +12,8 @@ define [
 
   $ = jQuery
 
-  TOP_OFFSET = 72
+  TOP_OFFSET = 43
+  COMPONENT_HEIGHT = 29
   BOTTOM_OFFSET = 10
 
 
@@ -124,14 +125,16 @@ define [
       selectedIssue = @collection.at @options.app.state.get 'selectedIndex'
       return unless selectedIssue?
       selectedIssueView = @children.findByModel selectedIssue
-      viewTop = selectedIssueView.$el.offset().top
-      viewBottom = viewTop + selectedIssueView.$el.outerHeight()
+      viewTop = selectedIssueView.$el.offset().top - TOP_OFFSET
+      if selectedIssueView.$el.prev().is('.issues-workspace-list-component')
+        viewTop -= COMPONENT_HEIGHT
+      viewBottom = selectedIssueView.$el.offset().top + selectedIssueView.$el.outerHeight() + BOTTOM_OFFSET
       windowTop = $(window).scrollTop()
       windowBottom = windowTop + $(window).height()
       if viewTop < windowTop
-        $(window).scrollTop viewTop - TOP_OFFSET
+        $(window).scrollTop viewTop
       if viewBottom > windowBottom
-        $(window).scrollTop $(window).scrollTop() - windowBottom + viewBottom + BOTTOM_OFFSET
+        $(window).scrollTop $(window).scrollTop() - windowBottom + viewBottom
 
 
     appendHtml: (compositeView, itemView, index) ->