0
1

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 3 years have passed since last update.

垂直スクロールを水平に変換

Posted at

垂直スクロールを水平スクロールへ変換

// タブ部分を上下にスクロールすると左右に
document
  .querySelector("#tab-scroll-container")
  .addEventListener("wheel", transformScroll);

// 上下方向のスクロールをそれぞれ左右方向に変換
function transformScroll(event) {
  if (!event.deltaY) {
    return;
  }
  event.currentTarget.scrollLeft += event.deltaY + event.deltaX;
  event.preventDefault();
}

要素の最大スクロール値を取得する

// 横スクロールの最大値を取得
const scroll_max = scroll_element.scrollWidth - scroll_element.clientWidth;
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?