diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-08-31 23:14:31 +0200 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-08-31 23:27:31 +0200 |
commit | 0ce381aa0a64de9a2165843dfe6ee493940f8c26 (patch) | |
tree | a8c48e79c58f1e651b45f74614be25477979de8c /client/components/cards/cardDetails.js | |
parent | 549f8fee3aee3675ae2c04fa14b88f4a783df2c6 (diff) | |
download | wekan-0ce381aa0a64de9a2165843dfe6ee493940f8c26.tar.gz wekan-0ce381aa0a64de9a2165843dfe6ee493940f8c26.tar.bz2 wekan-0ce381aa0a64de9a2165843dfe6ee493940f8c26.zip |
Fix the horizontal canvas scrolling on card opening
Diffstat (limited to 'client/components/cards/cardDetails.js')
-rw-r--r-- | client/components/cards/cardDetails.js | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index 5a7071e8..aba7254a 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -23,12 +23,32 @@ BlazeComponent.extendComponent({ this.componentParent().mouseHasEnterCardDetails = false; }, + scrollParentContainer: function() { + const cardPanelWidth = 510; + let bodyBoardComponent = this.componentParent(); + + let $cardContainer = bodyBoardComponent.$('.js-lists'); + let $cardView = this.$(this.firstNode()); + let cardContainerScroll = $cardContainer.scrollLeft(); + let cardContainerWidth = $cardContainer.width(); + + let cardViewStart = $cardView.offset().left; + let cardViewEnd = cardViewStart + cardPanelWidth; + + let offset = false; + if (cardViewStart < 0) { + offset = cardViewStart; + } else if(cardViewEnd > cardContainerWidth) { + offset = cardViewEnd - cardContainerWidth; + } + + if (offset) { + bodyBoardComponent.scrollLeft(cardContainerScroll + offset); + } + }, + onRendered: function() { - var bodyBoardComponent = this.componentParent(); - var additionalMargin = 550; - var $cardDetails = this.$(this.firstNode()); - var scollLeft = $cardDetails.offset().left + additionalMargin; - bodyBoardComponent.scrollLeft(scollLeft); + this.scrollParentContainer(); }, onDestroyed: function() { |