From d05ee9de8b919049c73647f9f574574b39c2d0d0 Mon Sep 17 00:00:00 2001 From: rdrew Date: Thu, 8 Nov 2018 10:35:52 -0400 Subject: [PATCH] added smooth scroll --- js/js.js | 18 ++++++++++++++++++ src/js/js.js | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/js/js.js b/js/js.js index e18bab3..46efe8b 100644 --- a/js/js.js +++ b/js/js.js @@ -48,6 +48,24 @@ }); } }; + + Drupal.behaviors.footnoteScroll = { + attach: function attach(context, settings) { + + + $('.see-footnote').on('click',function(e) { + e.preventDefault(); + var offset = 100; + var target = this.hash; + if ($(this).data('offset') != undefined) offset = $(this).data('offset'); + $('html, body').stop().animate({ + 'scrollTop': $(target).offset().top - offset + }, 500, 'swing', function() { + // window.location.hash = target; + }); + }); + } + }; //viii diff --git a/src/js/js.js b/src/js/js.js index e18bab3..46efe8b 100644 --- a/src/js/js.js +++ b/src/js/js.js @@ -48,6 +48,24 @@ }); } }; + + Drupal.behaviors.footnoteScroll = { + attach: function attach(context, settings) { + + + $('.see-footnote').on('click',function(e) { + e.preventDefault(); + var offset = 100; + var target = this.hash; + if ($(this).data('offset') != undefined) offset = $(this).data('offset'); + $('html, body').stop().animate({ + 'scrollTop': $(target).offset().top - offset + }, 500, 'swing', function() { + // window.location.hash = target; + }); + }); + } + }; //viii