assets/themes/j1/core/js/template.js in j1-template-2021.3.2 vs assets/themes/j1/core/js/template.js in j1-template-2022.0.0
- old
+ new
@@ -5,11 +5,11 @@
/***/ ((module) => {
"use strict";
/*
# -----------------------------------------------------------------------------
- # ~/js/adapter/adapter.js
+ # ~/js/adapter/adapter.js BBBBB
# Provides an empty object for later loaded adapter objects
#
# Product/Info:
# https://jekyll.one
#
@@ -2492,12 +2492,16 @@
// See: https://stackoverflow.com/questions/134845/which-href-value-should-i-use-for-javascript-links-or-javascriptvoid0
//
$('a[href="#"]').click(function (e) {
e.preventDefault ? e.preventDefault() : e.returnValue = false;
- logger.info('bound click event to "#", suppress default action');
- }); // -----------------------------------------------------------------------
+ logger.info('\n' + 'bound click event to "#", suppress default action');
+ }); // $('a:contains("?#")').click(function(e) {
+ // e.preventDefault ? e.preventDefault() : e.returnValue = false;
+ // logger.info('bound click event to "?#*", suppress default action');
+ // });
+ // -----------------------------------------------------------------------
// Navbar Sticky
// -----------------------------------------------------------------------
var navSticky = $getNav.hasClass('navbar-sticky');
@@ -3057,28 +3061,31 @@
// : options.location.href;
this.scrollTo(target, {
duration: duration,
offset: offset,
- callback: null
+ callback: false
});
logText = 'scrollSmooth finished';
logger.info(logText);
},
// -------------------------------------------------------------------------
// scrollTo
+ // NOTE: Calculate the tgt (HTML heading element including the hash)
+ // This makes ids that start with a number to work:
+ // '[id="' + decodeURI(target).split('#').join('') + '"]'
+ // DecodeURI is usded for nonASCII hashes, they was encoded,
+ // but id was not encoded, it lead to not finding the tgt element by id.
// -------------------------------------------------------------------------
scrollTo: function scrollTo(target, options) {
var start = window.pageYOffset;
var opt = {
duration: options.duration,
offset: options.offset || 0,
callback: options.callback,
easing: options.easing || easeInOutQuad
- }; // This makes ids that start with a number work: ('[id="' + decodeURI(target).split('#').join('') + '"]')
- // DecodeURI for nonASCII hashes, they was encoded, but id was not encoded, it lead to not finding the tgt element by id.
- // And this is for IE: document.body.scrollTop
+ }; // calculate the tgt (HTML heading element including the hash)
var tgt = document.querySelector('[id="' + decodeURI(target).split('#').join('') + '"]');
var distance = typeof target === 'string' ? opt.offset + (target ? tgt && tgt.getBoundingClientRect().top || 0 // handle non-existent links better.
: -(document.documentElement.scrollTop || document.body.scrollTop)) : target;
var duration = typeof opt.duration === 'function' ? opt.duration(distance) : opt.duration;
@@ -3094,28 +3101,16 @@
window.scrollTo(0, opt.easing(timeElapsed, start, distance, duration));
if (timeElapsed < duration) {
requestAnimationFrame(loop);
} else {
- end();
+ postPositioning();
}
}
- function end() {
- window.scrollTo(0, start + distance); // jadams, 2020-07-04: on (some?) mobile devices, the navbar
- // background is NOT switched (always?) correctly on a
- // page RELOAD.
- //
- // Solution: scroll the page one pixel back and forth (trigger)
- // to get the right position for the Toccer and adjust the
- // Navigator to display the (tranparent) navbar correctly based
- // on their onscroll events registered.
- //
-
- $(window).scrollTop($(window).scrollTop() + 1);
- $(window).scrollTop($(window).scrollTop() - 1);
-
+ function postPositioning() {
+ // if configured
if (typeof opt.callback === 'function') {
opt.callback();
}
} // Robert Penner's easeInOutQuad - http://robertpenner.com/easing/
@@ -3761,18 +3756,27 @@
function onClick(e) {
if (!isInPageLink(e.target) || e.target.className.indexOf('no-smooth-scroll') > -1 || e.target.href.charAt(e.target.href.length - 2) === '#' && e.target.href.charAt(e.target.href.length - 1) === '!' || e.target.className.indexOf(options.linkClass) === -1) {
return;
} // Don't prevent default or hash doesn't change.
// e.preventDefault()
+ // fixing-skip-to-content-links
+ // jump(e.target.hash, {
+ // duration: duration,
+ // offset: offset,
+ // callback: function () {
+ // setFocus(e.target.hash)
+ // }
+ // })
+ // jadams, 2021-11-13
+ // fixing-skip-to-content-links, done by callback to focus(), seems
+ // NOT longer required for current browsers
jump(e.target.hash, {
duration: duration,
offset: offset,
- callback: function callback() {
- setFocus(e.target.hash);
- }
+ callback: false
});
}
}
function isInPageLink(n) {
@@ -3834,11 +3838,21 @@
end();
}
}
function end() {
- window.scrollTo(0, start + distance);
-
+ // window.scrollTo(0, start + distance)
+ // jadams, 2020-07-04: on (some?) mobile devices, the navbar
+ // background is NOT switched (always?) correctly on a
+ // page RELOAD.
+ //
+ // Solution: scroll the page one pixel back and forth (trigger)
+ // to get the right position for the Toccer and adjust the
+ // Navigator to display the (tranparent) navbar correctly based
+ // on their onscroll events registered.
+ //
+ // $(window).scrollTop($(window).scrollTop()+1);
+ // $(window).scrollTop($(window).scrollTop()-1);
if (typeof opt.callback === 'function') {
opt.callback();
}
} // Robert Penner's easeInOutQuad - http://robertpenner.com/easing/
\ No newline at end of file