Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert scrollwindow patches breaking function wizard (master) #9926

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 20 additions & 57 deletions browser/src/control/jsdialog/Widget.ScrolledWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function _scrolledWindowControl(parentContainer, data, builder) {
scrollwindow.style.overflowX = 'scroll';

var realContentHeight = scrollwindow.scrollHeight;
var realContentWidth = scrollwindow.scrollWidth;
var realContentWidth = scrollwindow.scrollwidth;

var margin = 15;

Expand All @@ -89,90 +89,53 @@ function _scrolledWindowControl(parentContainer, data, builder) {
if (horizontalSteps < 0 || noHorizontal)
horizontalSteps = 0;

var rowHeight = 0;

var timeoutLimit = 2;
var updateSize = function () {
realContentHeight = scrollwindow.scrollHeight;
realContentWidth = scrollwindow.scrollWidth;
realContentWidth = scrollwindow.scrollwidth;
if (realContentHeight === 0 || realContentWidth === 0) {
if (timeoutLimit--)
setTimeout(updateSize, 100);
return;
}

if (!noVertical && data.vertical.upper > 0) {
if (rowHeight == 0) {
// determine the height a row
rowHeight = content.clientHeight / Math.min(data.vertical.upper, data.vertical.page_size);
// the content height might not include a new row being added, take it into account with the -1
if (!Number.isInteger(rowHeight)) {
rowHeight = content.clientHeight / (Math.min(data.vertical.upper, data.vertical.page_size) - 1);
}
}
var viewHeight = data.vertical.page_size * rowHeight;
var totalContentHeight = (data.vertical.upper -1) * rowHeight;

if (totalContentHeight != scrollwindow.scrollHeight) {
// only if view has changed
var marginTop = data.vertical.value * rowHeight;

content.style.marginBlockStart = marginTop + 'px';
content.style.height = (totalContentHeight - marginTop) + 'px';
scrollwindow.style.height = viewHeight + 'px';
scrollwindow.scrollTop = marginTop;
}
if (!noVertical) {
content.style.height = (realContentHeight + verticalSteps) + 'px';
scrollwindow.style.height = (realContentHeight + margin) + 'px';
}
if (!noHorizontal) {
content.style.width = (realContentWidth + horizontalSteps) + 'px';
scrollwindow.style.width = (realContentWidth + margin) + 'px';
}

content.scrollTop = data.vertical.value * 10;
content.scrollLeft = data.horizontal.value * 10;
content.style.marginInlineEnd = margin + 'px';
content.style.marginInlineStart = content.scrollLeft + 'px';

content.style.margin = content.scrollTop + 'px ' + margin + 'px ' + margin + 'px ' + content.scrollLeft + 'px';
};

if (data.user_managed_scrolling !== false) {
if (data.user_managed_scrolling !== false)
setTimeout(updateSize, 0);

var resizeObserver = new ResizeObserver(function () {
updateSize();
});
resizeObserver.observe(content);
}

var lastScrollV = null;
var lastScrollH = null;
var sendTimer = null;

if ((!noVertical && verticalSteps) || (!noHorizontal && horizontalSteps)) {
scrollwindow.addEventListener('scroll', function() {
scrollwindow.addEventListener('scroll', function () {
// keep content at the same place on the screen
var scrollTop = scrollwindow.scrollTop;
var scrollLeft = scrollwindow.scrollLeft;

if (data.user_managed_scrolling !== false) {
var viewHeight = data.vertical.page_size * rowHeight;
var totalContentHeight = Math.max((data.vertical.upper - 1) * rowHeight, viewHeight);
var marginTop = Math.round(scrollwindow.scrollTop / rowHeight) * rowHeight;

content.style.marginBlockStart = marginTop + 'px';
content.style.height = (totalContentHeight - marginTop) + 'px';
content.style.width = (realContentWidth - scrollwindow.scrollLeft + horizontalSteps) + 'px';
content.style.marginInlineStart = scrollwindow.scrollLeft + 'px';
content.style.margin = scrollTop + 'px ' + margin + 'px ' + margin + 'px ' + scrollLeft + 'px';
content.style.height = (realContentHeight - scrollTop + verticalSteps) + 'px';
content.style.width = (realContentWidth - scrollLeft + horizontalSteps) + 'px';
}

if (sendTimer)
clearTimeout(sendTimer);
sendTimer = setTimeout(function () {
var newScrollV = Math.round(scrollwindow.scrollTop / rowHeight);
if (lastScrollV !== newScrollV) {
lastScrollV = newScrollV;
builder.callback('scrolledwindow', 'scrollv', scrollwindow, newScrollV, builder);
}

var newScrollH = Math.round(scrollwindow.scrollLeft / 10);
if (lastScrollH !== newScrollH) {
lastScrollH = newScrollH;
builder.callback('scrolledwindow', 'scrollh', scrollwindow, newScrollH, builder);
}
}, 50);
builder.callback('scrolledwindow', 'scrollv', scrollwindow, Math.round(scrollTop / 10), builder);
builder.callback('scrolledwindow', 'scrollh', scrollwindow, Math.round(scrollLeft / 10), builder); }, 50);
});
}

Expand Down
Loading