Skip to content

scrollend イベントを使わないようにしたい (古めのブラウザ対応) #45

@dynamis

Description

@dynamis

うっかり気付くのが遅れてしまったのだが、scrollend という比較的最近サポートされたイベントを利用しており、Chrome 114, Firefox 109 以降でなければ横スクロールボタンの切り替えが行われない。

https://developer.mozilla.org/ja/docs/Web/API/Element/scrollend_event

homeWrapper.addEventListener("scrollend", (event) => {
scrollButtons.forEach((button) => {
button.setAttribute("aria-hidden", false);
});
if (homeWrapper.scrollLeft === 0) {
document.querySelector(".scroll-prev").setAttribute("aria-hidden", true);
} else if (
homeWrapper.scrollLeft ===
homeWrapper.scrollWidth - homeWrapper.clientWidth
) {
document.querySelector(".scroll-next").setAttribute("aria-hidden", true);
}
});

諸都合で Chromium 109, Firefox 102 という微妙に足りないバージョンでデモする必要があるため scrollend イベント非依存コードに変更したい。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions