Skip to content
Open
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
2 changes: 1 addition & 1 deletion assets/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class HeaderComponent extends Component {
this.#observeStickyPosition(stickyMode === 'always');

if (stickyMode === 'scroll-up' || stickyMode === 'always') {
document.addEventListener('scroll', this.#handleWindowScroll);
document.addEventListener('scroll', this.#handleWindowScroll, { passive: true });
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions assets/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LocalizationFormComponent extends Component {

this.refs.search && this.refs.search.addEventListener('keydown', this.#onSearchKeyDown);
this.refs.countryList && this.refs.countryList.addEventListener('keydown', this.#onContainerKeyDown);
this.refs.countryList && this.refs.countryList.addEventListener('scroll', this.#onCountryListScroll);
this.refs.countryList && this.refs.countryList.addEventListener('scroll', this.#onCountryListScroll, { passive: true });

// Resizing the language input can be expensive for browsers that don't support field-sizing: content.
// Spliting it into separate tasks at least helps when there are multiple localization forms on the page.
Expand Down Expand Up @@ -515,7 +515,7 @@ class DrawerLocalizationComponent extends Component {
const countryList = localizationForm.querySelector('.country-selector-form__wrapper');

if (target.open) {
if (countryList) countryList.addEventListener('scroll', this.#onCountryListScroll);
if (countryList) countryList.addEventListener('scroll', this.#onCountryListScroll, { passive: true });
onAnimationEnd(target, localizationForm.focusSearchInput);
} else {
countryList?.removeEventListener('scroll', this.#onCountryListScroll);
Expand Down
32 changes: 16 additions & 16 deletions assets/scrolling.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class Scroller {
this.#onScrollEnd = options.onScrollEnd;

this.element = element;
this.element.addEventListener('scroll', this.#handleScroll);
this.element.addEventListener('scroll', this.#handleScroll, { passive: true });
}

/**
Expand Down Expand Up @@ -342,25 +342,25 @@ export function scrollIntoView(element, { ancestor, behavior = 'smooth', block =
const scrollTop =
ancestor.scrollHeight > ancestor.clientHeight
? calculateScrollOffset(
block,
ancestorRect.top,
ancestor.clientHeight,
elemRect.top,
elemRect.height,
ancestor.scrollTop
)
block,
ancestorRect.top,
ancestor.clientHeight,
elemRect.top,
elemRect.height,
ancestor.scrollTop
)
: ancestor.scrollTop;

const scrollLeft =
ancestor.scrollWidth > ancestor.clientWidth
? calculateScrollOffset(
inline,
ancestorRect.left,
ancestor.clientWidth,
elemRect.left,
elemRect.width,
ancestor.scrollLeft
)
inline,
ancestorRect.left,
ancestor.clientWidth,
elemRect.left,
elemRect.width,
ancestor.scrollLeft
)
: ancestor.scrollLeft;

ancestor.scrollTo({ top: scrollTop, left: scrollLeft, behavior });
Expand All @@ -372,7 +372,7 @@ class ScrollHint extends HTMLElement {
#rafId = null;

connectedCallback() {
this.addEventListener('scroll', this.#handleScroll);
this.addEventListener('scroll', this.#handleScroll, { passive: true });
this.#resizeObserver.observe(this);
}

Expand Down
4 changes: 2 additions & 2 deletions assets/zoom-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class ZoomDialog extends Component {

connectedCallback() {
super.connectedCallback();
this.refs.dialog.addEventListener('scroll', this.handleScroll);
this.refs.dialog.addEventListener('scroll', this.handleScroll, { passive: true });
}

disconnectedCallback() {
Expand Down Expand Up @@ -275,7 +275,7 @@ function getMostVisibleElement(elements) {
current.intersectionRatio > prev.intersectionRatio ? current : prev
);
observer.disconnect();
resolve(/** @type {HTMLElement} */ (mostVisible.target));
resolve(/** @type {HTMLElement} */(mostVisible.target));
},
{
threshold: Array.from({ length: 100 }, (_, i) => i / 100),
Expand Down