0
0

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.

mousewheel.jsでのエラーを解決して横スクロールができるようになった

Last updated at Posted at 2021-02-01
main.js
//マウス上下で横スクロール
$(document).ready(function() {
	$('html, body, *').mousewheel(function(e, delta) {
	this.scrollLeft -= (delta);
	document.addEventListener('mousewheel DOMMouseScroll', { passive: false });
	});
	});

で動作する。
横スクロールする度にエラーが増幅して困ってた。また、googleのconsoleでは動くのにページで表示すると動かなかった。エラーはconsoleでも出ていた。
エラーメッセージは、

[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive.

元の.js
$(document).ready(function() {
$('html, body, *').mousewheel(function(e, delta) {
this.scrollLeft -= (delta);
e.preventDefault();
});
});

修正した箇所は、最後のところ
e.preventDefault();document.addEventListener('mousewheel DOMMouseScroll', { passive: false });に変更

解決のお世話になったURL
https://github.com/peachananr/onepage-scroll/issues/346#issuecomment-547004469
らぶ!Mr.stayacid

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?