PluginProbe
MyBookTable Bookstore by Stormhill Media / trunk
MyBookTable Bookstore by Stormhill Media vtrunk
3.6.5 trunk
mybooktable / js / scroll-fix.js

scroll-fix.js in MyBookTable Bookstore by Stormhill Media trunk, at js/scroll-fix.js

23 lines 991 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // ==================== START Stormhill ====================
2 // STORMHILL FIX - v3.6.4
3 // Native smooth scroll for .mbt-book-purchase-button using capture phase
4 // to bypass jQuery animate conflicts with themes like Divi.
5 // DO NOT REVERT on plugin update.
6 // ==================== END Stormhill ====================
7 document.addEventListener('DOMContentLoaded', function() {
8 var btn = document.querySelector('a.mbt-book-purchase-button');
9 if (btn) {
10 btn.addEventListener('click', function(e) {
11 e.preventDefault();
12 e.stopImmediatePropagation();
13 var adminBar = document.getElementById('wpadminbar');
14 var adminH = adminBar ? adminBar.offsetHeight : 0;
15 var target = document.querySelector('.mbt-book-purchase-section');
16 if (target) {
17 var scrollTo = target.getBoundingClientRect().top + window.pageYOffset - adminH - 100;
18 window.scrollTo({ top: scrollTo, behavior: 'smooth' });
19 }
20 }, true); // true = capture phase, fires before all bubble-phase handlers
21 }
22 });
23