From 88f6442cbfe6f8454d42376031f9c189390de769 Mon Sep 17 00:00:00 2001 From: Daniel Schreiber Date: Mon, 7 Aug 2017 11:57:52 +0300 Subject: [PATCH 1/4] Show leader on first load --- packages/rocketchat-ui/client/views/app/room.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/rocketchat-ui/client/views/app/room.js b/packages/rocketchat-ui/client/views/app/room.js index cca77b686a86..8514901e5bdc 100644 --- a/packages/rocketchat-ui/client/views/app/room.js +++ b/packages/rocketchat-ui/client/views/app/room.js @@ -310,6 +310,7 @@ let touchMoved = false; let lastTouchX = null; let lastTouchY = null; let lastScrollTop; +let leaderLoaded = false; Template.room.events({ 'click .iframe-toolbar button'() { @@ -501,10 +502,14 @@ Template.room.events({ }, 'scroll .wrapper': _.throttle(function(e, t) { - if (e.target.scrollTop < lastScrollTop) { - t.hideLeaderHeader.set(false); - } else if (e.target.scrollTop > $('.room-leader').height()) { - t.hideLeaderHeader.set(true); + const $roomLeader = $('.room-leader'); + if ($roomLeader.length) { + if (e.target.scrollTop < lastScrollTop || !leaderLoaded) { + t.hideLeaderHeader.set(false); + } else if (e.target.scrollTop > $('.room-leader').height()) { + t.hideLeaderHeader.set(true); + } + leaderLoaded = true; } lastScrollTop = e.target.scrollTop; From a587ca054e5576787cb79adc441ca27eca21dab3 Mon Sep 17 00:00:00 2001 From: Daniel Schreiber Date: Thu, 10 Aug 2017 16:07:46 +0300 Subject: [PATCH 2/4] Show leader at top when switching rooms --- packages/rocketchat-ui/client/views/app/room.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-ui/client/views/app/room.js b/packages/rocketchat-ui/client/views/app/room.js index 8514901e5bdc..3dbe0f5142d1 100644 --- a/packages/rocketchat-ui/client/views/app/room.js +++ b/packages/rocketchat-ui/client/views/app/room.js @@ -310,7 +310,7 @@ let touchMoved = false; let lastTouchX = null; let lastTouchY = null; let lastScrollTop; -let leaderLoaded = false; +let leaderLoaded; Template.room.events({ 'click .iframe-toolbar button'() { @@ -678,6 +678,7 @@ Template.room.events({ Template.room.onCreated(function() { // this.scrollOnBottom = true // this.typing = new msgTyping this.data._id + leaderLoaded = false; this.showUsersOffline = new ReactiveVar(false); this.atBottom = FlowRouter.getQueryParam('msg') ? false : true; this.unreadCount = new ReactiveVar(0); From 9879960bc308c79a8602bbe24a05707bba38af14 Mon Sep 17 00:00:00 2001 From: Daniel Schreiber Date: Sun, 13 Aug 2017 11:52:04 +0300 Subject: [PATCH 3/4] Remove second scroll-to-bottom --- packages/rocketchat-ui/client/views/app/room.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rocketchat-ui/client/views/app/room.js b/packages/rocketchat-ui/client/views/app/room.js index 3dbe0f5142d1..59a7de87908e 100644 --- a/packages/rocketchat-ui/client/views/app/room.js +++ b/packages/rocketchat-ui/client/views/app/room.js @@ -831,7 +831,7 @@ Template.room.onRendered(function() { template.sendToBottomIfNecessaryDebounced = _.debounce(template.sendToBottomIfNecessary, 10); - template.sendToBottomIfNecessary(); + //template.sendToBottomIfNecessary(); //Only need one of these if ((window.MutationObserver == null)) { wrapperUl.addEventListener('DOMSubtreeModified', () => template.sendToBottomIfNecessaryDebounced()); From 9bec7de07743eb1d77f4f917fcb05b814b765798 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 22 Aug 2017 22:29:14 -0300 Subject: [PATCH 4/4] Show leader at top when switching rooms --- packages/rocketchat-ui/client/views/app/room.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/rocketchat-ui/client/views/app/room.js b/packages/rocketchat-ui/client/views/app/room.js index 59a7de87908e..4642120fb9b0 100644 --- a/packages/rocketchat-ui/client/views/app/room.js +++ b/packages/rocketchat-ui/client/views/app/room.js @@ -310,7 +310,6 @@ let touchMoved = false; let lastTouchX = null; let lastTouchY = null; let lastScrollTop; -let leaderLoaded; Template.room.events({ 'click .iframe-toolbar button'() { @@ -504,12 +503,11 @@ Template.room.events({ 'scroll .wrapper': _.throttle(function(e, t) { const $roomLeader = $('.room-leader'); if ($roomLeader.length) { - if (e.target.scrollTop < lastScrollTop || !leaderLoaded) { + if (e.target.scrollTop < lastScrollTop) { t.hideLeaderHeader.set(false); - } else if (e.target.scrollTop > $('.room-leader').height()) { + } else if (t.isAtBottom(100) === false && e.target.scrollTop > $('.room-leader').height()) { t.hideLeaderHeader.set(true); } - leaderLoaded = true; } lastScrollTop = e.target.scrollTop; @@ -678,7 +676,6 @@ Template.room.events({ Template.room.onCreated(function() { // this.scrollOnBottom = true // this.typing = new msgTyping this.data._id - leaderLoaded = false; this.showUsersOffline = new ReactiveVar(false); this.atBottom = FlowRouter.getQueryParam('msg') ? false : true; this.unreadCount = new ReactiveVar(0); @@ -831,7 +828,7 @@ Template.room.onRendered(function() { template.sendToBottomIfNecessaryDebounced = _.debounce(template.sendToBottomIfNecessary, 10); - //template.sendToBottomIfNecessary(); //Only need one of these + template.sendToBottomIfNecessary(); if ((window.MutationObserver == null)) { wrapperUl.addEventListener('DOMSubtreeModified', () => template.sendToBottomIfNecessaryDebounced());