mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
new popup scrolls to top and restore it's previous position after closing again works now at attachments too
This commit is contained in:
parent
949a3a1337
commit
8557d91468
1 changed files with 12 additions and 9 deletions
|
@ -29,13 +29,6 @@ window.Popup = new (class {
|
||||||
open(name) {
|
open(name) {
|
||||||
const self = this;
|
const self = this;
|
||||||
const popupName = `${name}Popup`;
|
const popupName = `${name}Popup`;
|
||||||
const $contentWrapper = $('.content-wrapper')
|
|
||||||
if ($contentWrapper.length > 0) {
|
|
||||||
const contentWrapper = $contentWrapper[0];
|
|
||||||
this._getTopStack().scrollTop = contentWrapper.scrollTop;
|
|
||||||
// scroll from e.g. delete comment to the top (where the confirm button is)
|
|
||||||
$contentWrapper.scrollTop(0);
|
|
||||||
}
|
|
||||||
function clickFromPopup(evt) {
|
function clickFromPopup(evt) {
|
||||||
return $(evt.target).closest('.js-pop-over').length !== 0;
|
return $(evt.target).closest('.js-pop-over').length !== 0;
|
||||||
}
|
}
|
||||||
|
@ -83,6 +76,14 @@ window.Popup = new (class {
|
||||||
dataContext: (this && this.currentData && this.currentData()) || (options && options.dataContextIfCurrentDataIsUndefined) || this,
|
dataContext: (this && this.currentData && this.currentData()) || (options && options.dataContextIfCurrentDataIsUndefined) || this,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const $contentWrapper = $('.content-wrapper')
|
||||||
|
if ($contentWrapper.length > 0) {
|
||||||
|
const contentWrapper = $contentWrapper[0];
|
||||||
|
self._getTopStack().scrollTop = contentWrapper.scrollTop;
|
||||||
|
// scroll from e.g. delete comment to the top (where the confirm button is)
|
||||||
|
$contentWrapper.scrollTop(0);
|
||||||
|
}
|
||||||
|
|
||||||
// If there are no popup currently opened we use the Blaze API to render
|
// If there are no popup currently opened we use the Blaze API to render
|
||||||
// one into the DOM. We use a reactive function as the data parameter that
|
// one into the DOM. We use a reactive function as the data parameter that
|
||||||
// return the complete along with its top element and depends on our
|
// return the complete along with its top element and depends on our
|
||||||
|
@ -139,8 +140,10 @@ window.Popup = new (class {
|
||||||
const $contentWrapper = $('.content-wrapper')
|
const $contentWrapper = $('.content-wrapper')
|
||||||
if ($contentWrapper.length > 0) {
|
if ($contentWrapper.length > 0) {
|
||||||
const contentWrapper = $contentWrapper[0];
|
const contentWrapper = $contentWrapper[0];
|
||||||
const stack = this._stack[this._stack.length - 1 - n];
|
const stack = this._stack[this._stack.length - n];
|
||||||
if (contentWrapper.scrollTopMax && stack.scrollTop > contentWrapper.scrollTopMax) {
|
// scrollTopMax and scrollLeftMax only available at Firefox (https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTopMax)
|
||||||
|
const scrollTopMax = contentWrapper.scrollTopMax || contentWrapper.scrollHeight - contentWrapper.clientHeight;
|
||||||
|
if (scrollTopMax && stack.scrollTop > scrollTopMax) {
|
||||||
// sometimes scrollTopMax is lower than scrollTop, so i need this dirty hack
|
// sometimes scrollTopMax is lower than scrollTop, so i need this dirty hack
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$contentWrapper.scrollTop(stack.scrollTop);
|
$contentWrapper.scrollTop(stack.scrollTop);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue