From 0ce381aa0a64de9a2165843dfe6ee493940f8c26 Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Mon, 31 Aug 2015 23:14:31 +0200 Subject: Fix the horizontal canvas scrolling on card opening --- client/components/boards/boardBody.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'client/components/boards') diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js index aa9d630d..fd9ee6bc 100644 --- a/client/components/boards/boardBody.js +++ b/client/components/boards/boardBody.js @@ -44,20 +44,10 @@ BlazeComponent.extendComponent({ this.draggingActive.set(bool); }, - scrollLeft: function(position) { - position = position || 0; - var $container = $(this.listsDom); - var containerWidth = $container.width(); - var currentScrollPosition = $container.scrollLeft(); - if (position < currentScrollPosition) { - $container.animate({ - scrollLeft: position - }); - } else if (position > currentScrollPosition + containerWidth) { - $container.animate({ - scrollLeft: Math.max(0, position - containerWidth) - }); - } + scrollLeft: function(position = 0) { + this.$('.js-lists').animate({ + scrollLeft: position + }); }, currentCardIsInThisList: function() { @@ -109,10 +99,12 @@ BlazeComponent.extendComponent({ Template.boardBody.onRendered(function() { var self = BlazeComponent.getComponentForElement(this.firstNode); - self.scrollLeft(); - self.listsDom = this.find('.js-lists'); + if (! Session.get('currentCard')) { + self.scrollLeft(); + } + // We want to animate the card details window closing. We rely on CSS // transition for the actual animation. self.listsDom._uihooks = { -- cgit v1.2.3-1-g7c22