iOSのSafariでスクロール固定
クソコードなので実務で使うとしたらリファクタ必須だけどだいたいこんな感じで固定できる
code:js
export const setFixedScroll = (isFixed) => {
const style = document.body.style;
if (isFixed) {
fixedScrollTop = document.documentElement.scrollTop || -(document.body.getBoundingClientRect().top) || 0;
style.position = 'fixed';
style.top = -fixedScrollTop + 'px';
style.left = '0';
style.right = '0';
style.bottom = '0';
} else {
style.position = '';
style.top = '';
style.left = '';
style.right = '';
style.bottom = '';
}
};