From aad21f1788d71b9cca4a440ce923c1a8284cab30 Mon Sep 17 00:00:00 2001 From: Darren Date: Tue, 6 Nov 2012 19:32:12 +0000 Subject: [PATCH] Client: Not scrolling down a panel if scrolled up #59 --- client/assets/css/style.css | 2 +- client/assets/dev/view.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/client/assets/css/style.css b/client/assets/css/style.css index d9abe58..e0cd34a 100644 --- a/client/assets/css/style.css +++ b/client/assets/css/style.css @@ -108,7 +108,7 @@ a img { border:none; } .messages { overflow-x:wrap; border:none; display: none; - height: 100%; + /*height: 100%;*/ color: #333333; } .messages a { diff --git a/client/assets/dev/view.js b/client/assets/dev/view.js index 147e094..81c9228 100644 --- a/client/assets/dev/view.js +++ b/client/assets/dev/view.js @@ -374,12 +374,12 @@ _kiwi.view.Panel = Backbone.View.extend({ } _kiwi.app.view.doLayout(); - - this.scrollToBottom(); this.alert('none'); this.trigger('active', this.model); _kiwi.app.panels.trigger('active', this.model); + + this.scrollToBottom(true); }, @@ -420,9 +420,14 @@ _kiwi.view.Panel = Backbone.View.extend({ // Scroll to the bottom of the panel - scrollToBottom: function () { - // TODO: Don't scroll down if we're scrolled up the panel a little - this.$container[0].scrollTop = this.$container[0].scrollHeight; + scrollToBottom: function (force_down) { + // If this isn't the active panel, don't scroll + if (this.model !== _kiwi.app.panels.active) return; + + // Don't scroll down if we're scrolled up the panel a little + if (force_down || this.$container.scrollTop() + this.$container.height() > this.$el.outerHeight() - 150) { + this.$container[0].scrollTop = this.$container[0].scrollHeight; + } } }); -- 2.25.1