8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IEだと固定背景がスクロール時にカクつく件

Last updated at Posted at 2019-09-02

IEでbackground-attachment:fixed;を使用すると
スクロール時に固定背景がカクつく事象が発生したため、備忘録として回避方法を載せます。

ちなみに、カクつきの原因はIEのスムーズスクロールという設定のよう。。
参考 : https://souken-blog.com/2017/08/25/ie11-smoothscroll/

デフォルトで設定チェックが入っているため、WEBページを読み込む際に
JSで設定をOFFにする必要がある。

実施環境

検証日:2019/08/23
OS:Windows10 Pro
ブラウザ:IEバージョン 11.295

JavaScript
// 利用ブラウザがIE10か11か
if(navigator.userAgent.match(/MSIE 10/i) || navigator.userAgent.match(/Trident\/7\./)) {
  // マウスホイールでのスクロール時
  $('body').on("mousewheel", function (){
    // デフォルトの設定値をOFFに切り替える
    event.preventDefault();
    var wd = event.wheelDelta;
    var csp = window.pageYOffset;
    window.scrollTo(0, csp - wd);
  });
}

ハマった方、ぜひご活用ください。

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?