Skip to content

Commit

Permalink
MenuRenderer, OverflowMenu: Improve scroll fade effect in older brows…
Browse files Browse the repository at this point in the history
…ers (#1664)
  • Loading branch information
felixhabib authored Dec 9, 2024
1 parent e8eddf8 commit 91df12c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {

export const container = style({
WebkitOverflowScrolling: 'touch',
WebkitMaskComposite: 'destination-in', // Fallback for browsers that don't support mask-composite
maskComposite: 'intersect',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ import { throttle } from 'throttle-debounce';

import * as styles from './ScrollContainer.css';

const scrollOffset = 2; // 2 instead of 1 to account for rounding errors in some browsers

const maskOverflow = (
element: HTMLElement,
direction: keyof typeof styles.direction,
) => {
const atTop = element.scrollTop === 0;
const atTop = element.scrollTop <= 0;
const atBottom =
element.scrollHeight - element.offsetHeight - element.scrollTop < 1;
const atLeft = element.scrollLeft === 0;
element.scrollHeight - element.offsetHeight - element.scrollTop <
scrollOffset;
const atLeft = element.scrollLeft <= 0;
const atRight =
element.scrollWidth - element.offsetWidth - element.scrollLeft < 1;
element.scrollWidth - element.offsetWidth - element.scrollLeft <
scrollOffset;

if (direction === 'vertical' || direction === 'all') {
element.classList[atTop ? 'remove' : 'add'](styles.maskTop);
Expand Down

0 comments on commit 91df12c

Please sign in to comment.