Skip to content

Commit

Permalink
fix loading of code in source viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
stas-vilchik committed Feb 3, 2016
1 parent 4942f28 commit de88db0
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions server/sonar-web/src/main/js/components/source-viewer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,20 +541,17 @@ export default Marionette.LayoutView.extend({

bindScrollEvents: function () {
var that = this;
this.$el.scrollParent().on('scroll.source-viewer', function () {
$(window).on('scroll.source-viewer', function () {
that.onScroll();
});
},

unbindScrollEvents: function () {
this.$el.scrollParent().off('scroll.source-viewer');
$(window).off('scroll.source-viewer');
},

onScroll: function () {
var p = this.$el.scrollParent();
if (p.is(document)) {
p = $(window);
}
var p = $(window);
var pTopOffset = p.offset() != null ? p.offset().top : 0,
pPosition = p.scrollTop() + pTopOffset;
if (this.model.get('hasSourceBefore') && (pPosition <= this.ui.sourceBeforeSpinner.offset().top)) {
Expand All @@ -568,10 +565,7 @@ export default Marionette.LayoutView.extend({
scrollToLine: function (line) {
var row = this.$('.source-line[data-line-number=' + line + ']');
if (row.length > 0) {
var p = this.$el.scrollParent();
if (p.is(document)) {
p = $(window);
}
var p = $(window);
var pTopOffset = p.offset() != null ? p.offset().top : 0,
pHeight = p.height(),
goal = row.offset().top - pHeight / 3 - pTopOffset;
Expand All @@ -583,10 +577,7 @@ export default Marionette.LayoutView.extend({
scrollToFirstLine: function (line) {
var row = this.$('.source-line[data-line-number=' + line + ']');
if (row.length > 0) {
var p = this.$el.scrollParent();
if (p.is(document)) {
p = $(window);
}
var p = $(window);
var pTopOffset = p.offset() != null ? p.offset().top : 0,
goal = row.offset().top - pTopOffset;
p.scrollTop(goal);
Expand All @@ -597,7 +588,7 @@ export default Marionette.LayoutView.extend({
scrollToLastLine: function (line) {
var row = this.$('.source-line[data-line-number=' + line + ']');
if (row.length > 0) {
var p = this.$el.scrollParent();
var p = $(window);
if (p.is(document)) {
p = $(window);
}
Expand Down

0 comments on commit de88db0

Please sign in to comment.