mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Fix the horizontal canvas scrolling on card opening
This commit is contained in:
parent
549f8fee3a
commit
0ce381aa0a
3 changed files with 45 additions and 31 deletions
|
|
@ -44,20 +44,10 @@ BlazeComponent.extendComponent({
|
||||||
this.draggingActive.set(bool);
|
this.draggingActive.set(bool);
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollLeft: function(position) {
|
scrollLeft: function(position = 0) {
|
||||||
position = position || 0;
|
this.$('.js-lists').animate({
|
||||||
var $container = $(this.listsDom);
|
scrollLeft: position
|
||||||
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)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
currentCardIsInThisList: function() {
|
currentCardIsInThisList: function() {
|
||||||
|
|
@ -109,10 +99,12 @@ BlazeComponent.extendComponent({
|
||||||
Template.boardBody.onRendered(function() {
|
Template.boardBody.onRendered(function() {
|
||||||
var self = BlazeComponent.getComponentForElement(this.firstNode);
|
var self = BlazeComponent.getComponentForElement(this.firstNode);
|
||||||
|
|
||||||
self.scrollLeft();
|
|
||||||
|
|
||||||
self.listsDom = this.find('.js-lists');
|
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
|
// We want to animate the card details window closing. We rely on CSS
|
||||||
// transition for the actual animation.
|
// transition for the actual animation.
|
||||||
self.listsDom._uihooks = {
|
self.listsDom._uihooks = {
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,32 @@ BlazeComponent.extendComponent({
|
||||||
this.componentParent().mouseHasEnterCardDetails = false;
|
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() {
|
onRendered: function() {
|
||||||
var bodyBoardComponent = this.componentParent();
|
this.scrollParentContainer();
|
||||||
var additionalMargin = 550;
|
|
||||||
var $cardDetails = this.$(this.firstNode());
|
|
||||||
var scollLeft = $cardDetails.offset().left + additionalMargin;
|
|
||||||
bodyBoardComponent.scrollLeft(scollLeft);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onDestroyed: function() {
|
onDestroyed: function() {
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,12 @@ FlowRouter.route('/', {
|
||||||
name: 'home',
|
name: 'home',
|
||||||
triggersEnter: [AccountsTemplates.ensureSignedIn],
|
triggersEnter: [AccountsTemplates.ensureSignedIn],
|
||||||
action: function() {
|
action: function() {
|
||||||
EscapeActions.executeAll();
|
|
||||||
Filter.reset();
|
|
||||||
|
|
||||||
Session.set('currentBoard', null);
|
Session.set('currentBoard', null);
|
||||||
Session.set('currentCard', null);
|
Session.set('currentCard', null);
|
||||||
|
|
||||||
|
Filter.reset();
|
||||||
|
EscapeActions.executeAll();
|
||||||
|
|
||||||
BlazeLayout.render('defaultLayout', { content: 'boardList' });
|
BlazeLayout.render('defaultLayout', { content: 'boardList' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -21,15 +21,16 @@ FlowRouter.route('/b/:id/:slug', {
|
||||||
name: 'board',
|
name: 'board',
|
||||||
action: function(params) {
|
action: function(params) {
|
||||||
let currentBoard = params.id;
|
let currentBoard = params.id;
|
||||||
// If we close a card, we'll execute again this route action but we don't
|
let previousBoard = Session.get('currentBoard');
|
||||||
// want to excape every current actions (filters, etc.)
|
|
||||||
if (Session.get('currentBoard') !== currentBoard) {
|
|
||||||
EscapeActions.executeAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
Session.set('currentBoard', currentBoard);
|
Session.set('currentBoard', currentBoard);
|
||||||
Session.set('currentCard', null);
|
Session.set('currentCard', null);
|
||||||
|
|
||||||
|
// If we close a card, we'll execute again this route action but we don't
|
||||||
|
// want to excape every current actions (filters, etc.)
|
||||||
|
if (previousBoard !== currentBoard) {
|
||||||
|
EscapeActions.executeAll();
|
||||||
|
}
|
||||||
|
|
||||||
BlazeLayout.render('defaultLayout', { content: 'board' });
|
BlazeLayout.render('defaultLayout', { content: 'board' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -37,10 +38,11 @@ FlowRouter.route('/b/:id/:slug', {
|
||||||
FlowRouter.route('/b/:boardId/:slug/:cardId', {
|
FlowRouter.route('/b/:boardId/:slug/:cardId', {
|
||||||
name: 'card',
|
name: 'card',
|
||||||
action: function(params) {
|
action: function(params) {
|
||||||
EscapeActions.executeUpTo('inlinedForm');
|
|
||||||
Session.set('currentBoard', params.boardId);
|
Session.set('currentBoard', params.boardId);
|
||||||
Session.set('currentCard', params.cardId);
|
Session.set('currentCard', params.cardId);
|
||||||
|
|
||||||
|
EscapeActions.executeUpTo('inlinedForm');
|
||||||
|
|
||||||
BlazeLayout.render('defaultLayout', { content: 'board' });
|
BlazeLayout.render('defaultLayout', { content: 'board' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue