6
7

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.

CSSのtouch-actionプロパティでハマった話

Posted at

CSSのtouch-actionプロパティを設定しているサイトでjQueryプラグインを使ったときにハマった話です。

touch-actionプロパティとは

タッチデバイスにおいてユーザーの操作を制御できるプロパティです。
詳しい内容についてはこちらを参照してください。

ハマったときの状況

タッチデバイスへの対応として、CSSで以下のようにtouch-actionプロパティを設定していました。

body {
  -ms-touch-action: manipulation;
      touch-action: manipulation;
}

その上で、Swipeboxを設置しました。
スマートフォンで表示を確認すると・・・

Screenshot_2019-10-17-15-58-16.png

画像が拡大表示されたとき、フォーカスが外れず画面全体が青くなってしまいました。
ちなみにSwipebox以外のlightbox系プラグインをいくつか試しましたが同じでした。

解決策

body全体にtouch-actionプロパティを設定していたのが原因のようで、以下のように要素を限定すると問題なく動作します。

a,area,button,[role="button"],input:not([type=range]),
label,select,summary,textarea {
  -ms-touch-action: manipulation;
      touch-action: manipulation;
}

参考になったサイト・ブログなど

6
7
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
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?