Client: Not scrolling down a panel if scrolled up #59
authorDarren <darren@darrenwhitlen.com>
Tue, 6 Nov 2012 19:32:12 +0000 (19:32 +0000)
committerDarren <darren@darrenwhitlen.com>
Tue, 6 Nov 2012 19:32:12 +0000 (19:32 +0000)
client/assets/css/style.css
client/assets/dev/view.js

index d9abe58efb5b9d619e17e38d1c915cfa78b044e8..e0cd34af1208fb26d6710eb50a80dc3019f5fae3 100644 (file)
@@ -108,7 +108,7 @@ a img { border:none; }
 .messages {
     overflow-x:wrap;
     border:none; display: none;
-    height: 100%;
+    /*height: 100%;*/
     color: #333333;
 }
 .messages a {
index 147e094c60153853912180180b527232770eb4a9..81c92288f75caafe21973239df3dda74c28c479b 100644 (file)
@@ -374,12 +374,12 @@ _kiwi.view.Panel = Backbone.View.extend({
         }\r
 \r
         _kiwi.app.view.doLayout();\r
-\r
-        this.scrollToBottom();\r
         this.alert('none');\r
 \r
         this.trigger('active', this.model);\r
         _kiwi.app.panels.trigger('active', this.model);\r
+\r
+        this.scrollToBottom(true);\r
     },\r
 \r
 \r
@@ -420,9 +420,14 @@ _kiwi.view.Panel = Backbone.View.extend({
 \r
 \r
     // Scroll to the bottom of the panel\r
-    scrollToBottom: function () {\r
-        // TODO: Don't scroll down if we're scrolled up the panel a little\r
-        this.$container[0].scrollTop = this.$container[0].scrollHeight;\r
+    scrollToBottom: function (force_down) {\r
+        // If this isn't the active panel, don't scroll\r
+        if (this.model !== _kiwi.app.panels.active) return;\r
+\r
+        // Don't scroll down if we're scrolled up the panel a little\r
+        if (force_down || this.$container.scrollTop() + this.$container.height() > this.$el.outerHeight() - 150) {\r
+            this.$container[0].scrollTop = this.$container[0].scrollHeight;\r
+        }\r
     }\r
 });\r
 \r