@madj2k/fe-frontend-kit 2.0.17 → 2.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @author Steffen Kroggel <developer@steffenkroggel.de>
|
|
14
14
|
* @copyright 2025 Steffen Kroggel
|
|
15
|
-
* @version 2.0.
|
|
15
|
+
* @version 2.0.2
|
|
16
16
|
* @license GNU General Public License v3.0
|
|
17
17
|
* @see https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
18
18
|
*
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* // Initialize with custom config
|
|
25
25
|
* const scrolling = new Madj2kScrolling({
|
|
26
26
|
* anchorScrolling: {
|
|
27
|
-
* selector: ['a[href
|
|
27
|
+
* selector: ['a[href*="#"]'],
|
|
28
28
|
* offsetSelector: null,
|
|
29
29
|
* disableSelector: '.js-no-scroll',
|
|
30
30
|
* collapsibleSelector: ['.collapse'],
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
class Madj2kScrolling {
|
|
74
74
|
config = {
|
|
75
75
|
anchorScrolling: {
|
|
76
|
-
selector: ['a[href
|
|
76
|
+
selector: ['a[href*="#"]'],
|
|
77
77
|
offsetSelector: null,
|
|
78
78
|
disableSelector: '.js-no-scroll',
|
|
79
79
|
collapsibleSelector: ['.collapse'],
|
|
@@ -232,11 +232,20 @@ class Madj2kScrolling {
|
|
|
232
232
|
};
|
|
233
233
|
|
|
234
234
|
const jumpToAnchorByLink = (event) => {
|
|
235
|
-
event.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if
|
|
239
|
-
|
|
235
|
+
const href = event.currentTarget.getAttribute('href');
|
|
236
|
+
if (!href) return;
|
|
237
|
+
|
|
238
|
+
// check if link is to the same page - with or without path
|
|
239
|
+
const [linkPath, hash] = href.split('#');
|
|
240
|
+
const currentUrl = window.location.origin + window.location.pathname;
|
|
241
|
+
const isSamePage = (
|
|
242
|
+
href.startsWith('#') ||
|
|
243
|
+
(window.location.origin + linkPath) === currentUrl
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
if (isSamePage && hash) {
|
|
247
|
+
event.preventDefault();
|
|
248
|
+
const anchor = document.getElementById(hash);
|
|
240
249
|
if (anchor) scrollToElement(anchor);
|
|
241
250
|
}
|
|
242
251
|
};
|