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

Calc toolbar/statusbar: fix scroll button issues on horizontal scroll #10944

Merged
merged 4 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions browser/css/toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
}
.ui-scroll-right::after {
rotate: 270deg;
left: 0px;
}
.ui-scroll-left:hover,
.ui-scroll-right:hover {
Expand Down
27 changes: 22 additions & 5 deletions browser/src/control/jsdialog/Util.ScrollableBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,52 @@ function showArrow(arrow: HTMLElement, show: boolean) {
function setupResizeHandler(container: Element, scrollable: Element) {
const left = container.querySelector('.ui-scroll-left') as HTMLElement;
const right = container.querySelector('.ui-scroll-right') as HTMLElement;
var isRTL: boolean = document.documentElement.dir === 'rtl';
var timer: any; // for shift + mouse wheel up/down

const handler = function () {
const rootContainer = scrollable.querySelector('div');
if (!rootContainer) return;

if (rootContainer.scrollWidth > window.innerWidth) {
// we have overflowed content
const direction = this._RTL ? -1 : 1;
const direction = isRTL ? -1 : 1;
if (direction * scrollable.scrollLeft > 0) {
if (this._RTL) showArrow(right, true);
if (isRTL) showArrow(right, true);
else showArrow(left, true);
} else if (this._RTL) showArrow(right, false);
} else if (isRTL) showArrow(right, false);
else showArrow(left, false);

if (
direction * scrollable.scrollLeft <
rootContainer.scrollWidth - window.innerWidth - 1
) {
if (this._RTL) showArrow(left, true);
if (isRTL) showArrow(left, true);
else showArrow(right, true);
} else if (this._RTL) showArrow(left, false);
} else if (isRTL) showArrow(left, false);
else showArrow(right, false);
} else {
showArrow(left, false);
showArrow(right, false);
}
}.bind(this);

// handler for toolbar and statusbar
// runs if shift + mouse wheel up/down are used
const shiftHandler = (e: MouseEvent) => {
const rootContainer = scrollable.querySelector('div');
if (!rootContainer || !e.shiftKey) return;

clearTimeout(timer);
// wait until mouse wheel stops scrolling
timer = setTimeout(function () {
JSDialog.RefreshScrollables();
}, 350);
};

window.addEventListener('resize', handler);
window.addEventListener('scroll', handler);
scrollable.addEventListener('wheel', shiftHandler);
}

JSDialog.MakeScrollable = function (parent: Element, scrollable: Element) {
Expand Down
Loading