summaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-03-29 15:19:50 +0200
committerStas Vilchik <vilchiks@gmail.com>2016-03-29 15:19:57 +0200
commitb4c0b9c51c178c17aa6df88c9761187286dccb45 (patch)
tree73e028e525ea82e3026f02975667f32275d0aa31 /server/sonar-web/src/main/js
parent3cf7d3e72f09ec723fbd9ff9d04e42fd57d20ad7 (diff)
downloadsonarqube-b4c0b9c51c178c17aa6df88c9761187286dccb45.tar.gz
sonarqube-b4c0b9c51c178c17aa6df88c9761187286dccb45.zip
fix scrolling of source viewer inside workspace window
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/main.js31
1 files changed, 24 insertions, 7 deletions
diff --git a/server/sonar-web/src/main/js/components/source-viewer/main.js b/server/sonar-web/src/main/js/components/source-viewer/main.js
index 85f628c2751..78767410b24 100644
--- a/server/sonar-web/src/main/js/components/source-viewer/main.js
+++ b/server/sonar-web/src/main/js/components/source-viewer/main.js
@@ -542,17 +542,28 @@ export default Marionette.LayoutView.extend({
bindScrollEvents () {
const that = this;
- $(window).on('scroll.source-viewer', function () {
+ let p = this.$el.scrollParent();
+ if (p.is(document) || p.is('body')) {
+ p = $(window);
+ }
+ p.on('scroll.source-viewer', function () {
that.onScroll();
});
},
unbindScrollEvents () {
- $(window).off('scroll.source-viewer');
+ let p = this.$el.scrollParent();
+ if (p.is(document) || p.is('body')) {
+ p = $(window);
+ }
+ p.off('scroll.source-viewer');
},
onScroll () {
- const p = $(window);
+ let p = this.$el.scrollParent();
+ if (p.is(document) || p.is('body')) {
+ p = $(window);
+ }
const pTopOffset = p.offset() != null ? p.offset().top : 0;
const pPosition = p.scrollTop() + pTopOffset;
if (this.model.get('hasSourceBefore') && (pPosition <= this.ui.sourceBeforeSpinner.offset().top)) {
@@ -566,7 +577,10 @@ export default Marionette.LayoutView.extend({
scrollToLine (line) {
const row = this.$(`.source-line[data-line-number=${line}]`);
if (row.length > 0) {
- const p = $(window);
+ let p = this.$el.scrollParent();
+ if (p.is(document) || p.is('body')) {
+ p = $(window);
+ }
const pTopOffset = p.offset() != null ? p.offset().top : 0;
const pHeight = p.height();
const goal = row.offset().top - pHeight / 3 - pTopOffset;
@@ -578,7 +592,10 @@ export default Marionette.LayoutView.extend({
scrollToFirstLine (line) {
const row = this.$(`.source-line[data-line-number=${line}]`);
if (row.length > 0) {
- const p = $(window);
+ let p = this.$el.scrollParent();
+ if (p.is(document) || p.is('body')) {
+ p = $(window);
+ }
const pTopOffset = p.offset() != null ? p.offset().top : 0;
const goal = row.offset().top - pTopOffset;
p.scrollTop(goal);
@@ -589,8 +606,8 @@ export default Marionette.LayoutView.extend({
scrollToLastLine (line) {
const row = this.$(`.source-line[data-line-number=${line}]`);
if (row.length > 0) {
- let p = $(window);
- if (p.is(document)) {
+ let p = this.$el.scrollParent();
+ if (p.is(document) || p.is('body')) {
p = $(window);
}
const pTopOffset = p.offset() != null ? p.offset().top : 0;