前提・実現したいこと
Railsでaタグを押したら該当のidまでスクロールする動きをjQueryで実装しています。
しかし、aタグを押すと無限にエラーが吐かれて困っています
発生している問題・エラーメッセージ
TypeError: jQuery.easing[this.easing] is not a function
該当のソースコード
js
1$(document).on("turbolinks:load", function() { 2 3 (function ($) { 4 "use strict"; // Start of use strict 5 6 // Smooth scrolling using jQuery easing 7 $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function () { 8 if ( 9 window.location.pathname.replace(/^//, "") == 10 this.pathname.replace(/^//, "") && 11 window.location.hostname == this.hostname 12 ) { 13 var target = $(this.hash); 14 target = target.length 15 ? target 16 : $("[name=" + this.hash.slice(1) + "]"); 17 if (target.length) { 18 $("html, body").animate( 19 { 20 scrollTop: target.offset().top - 72, 21 }, 22 1000, 23 "easeInOutExpo" 24 ); 25 return false; 26 } 27 } 28 }); 29 })(jQuery); // End of use strict 30});
補足情報(FW/ツールのバージョンなど)
cloud9
Rails 5.2.4.3
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。