From 24cb536da6de460ab82ecb981ea238922844084d Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Sat, 1 Jul 2023 13:44:07 +0200 Subject: [PATCH 01/17] Rename readme --- readme.md => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename readme.md => README.md (100%) diff --git a/readme.md b/README.md similarity index 100% rename from readme.md rename to README.md From e658971629f99de2c2134946475cef7c72fe44e4 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Sat, 1 Jul 2023 13:44:14 +0200 Subject: [PATCH 02/17] Rename plugin class --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index f911d99..da4489c 100755 --- a/src/index.js +++ b/src/index.js @@ -6,8 +6,8 @@ import Scrl from 'scrl'; * Class representing a Scroll Plugin. * @extends Plugin */ -export default class ScrollPlugin extends Plugin { - name = 'ScrollPlugin'; +export default class SwupScrollPlugin extends Plugin { + name = 'SwupScrollPlugin'; /** * Constructor From bbdb9221f9d1aeb7e7bbd3332f09dfa979b62360 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Sat, 1 Jul 2023 14:49:55 +0200 Subject: [PATCH 03/17] Update description --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f9f67b8..ff2d625 100755 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@swup/scroll-plugin", "amdName": "SwupScrollPlugin", "version": "2.0.3", - "description": "Swup scroll plugin.", + "description": "A swup plugin for smooth scrolling", "type": "module", "source": "src/index.js", "main": "./dist/index.cjs", From 7473085803c0ca71f37cf79e8be9e12744325c6b Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Sat, 1 Jul 2023 14:50:02 +0200 Subject: [PATCH 04/17] Bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d4e577e..6e41177 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@swup/scroll-plugin", - "version": "2.0.3", + "version": "3.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@swup/scroll-plugin", - "version": "2.0.3", + "version": "3.0.0", "license": "MIT", "dependencies": { "@swup/plugin": "^2.0.0", diff --git a/package.json b/package.json index ff2d625..31a860c 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@swup/scroll-plugin", "amdName": "SwupScrollPlugin", - "version": "2.0.3", + "version": "3.0.0", "description": "A swup plugin for smooth scrolling", "type": "module", "source": "src/index.js", From 18fede19f3e7e82ad502e30f78cf9e92316e6779 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Sat, 1 Jul 2023 14:50:13 +0200 Subject: [PATCH 05/17] Update readme --- README.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7385ea4..43561d9 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # Swup Scroll plugin -Adds awesome "acceleration based" automatic scrolling into the process of page transitions. The scrolling behaviour is customizable using options (see below). +A [swup](https://swup.js.org) plugin for smooth scrolling. + +- Enables acceleration-based smooth scrolling +- Animates scroll position between page visits +- Animates scrolling to anchors +- Define a custom offset for scroll positions ## Installation @@ -17,7 +22,7 @@ import SwupScrollPlugin from '@swup/scroll-plugin'; Or include the minified production file from a CDN: ```html - + ``` ## Usage @@ -103,7 +108,7 @@ Customize how the scroll target is found on the page. Defaults to standard brows ```javascript { // Use a custom data attribute instead of id - getAnchorElement: hash => { + getAnchorElement: (hash) => { hash = hash.replace('#', '') return document.querySelector(`[data-scroll-target="${hash}"]`) } @@ -168,27 +173,25 @@ new SwupScrollPlugin({ getAnchorElement: null, offset: 0, scrollContainers: `[data-swup-scroll-container]`, - shouldResetScrollPosition: htmlAnchorElement => true + shouldResetScrollPosition: (link) => true }); ``` -## Changes of the swup instance +## Methods on the swup instance Scroll Plugin adds the method `scrollTo` to the swup instance, which can be used for custom scrolling. -The method accepts an offset in pixels and a boolean, if the scroll position should be animated: +The method accepts a scroll position in pixels and a boolean whether the scroll position should be animated: ```js // will animate the scroll position of the window to 2000px swup.scrollTo(2000, true); ``` -The Plugin also adds two new events `scrollStart` and `scrollDone` to swup, that can be listened to with the `on` method: +## Hooks + +The plugin adds two new hooks `scrollStart` and `scrollDone` : ```js -swup.on('scrollStart', () => { - console.log('Swup started scrolling'); -}); -swup.on('scrollDone', () => { - console.log('Swup finished scrolling'); -}); +swup.hooks.on('scrollStart', () => console.log('Swup started scrolling')); +swup.hooks.on('scrollDone', () => console.log('Swup finished scrolling')); ``` From 91397067973d0ba097d131add283b24921ce8b05 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Sat, 1 Jul 2023 14:50:27 +0200 Subject: [PATCH 06/17] Refactor init --- src/index.js | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/index.js b/src/index.js index da4489c..d231436 100755 --- a/src/index.js +++ b/src/index.js @@ -3,37 +3,34 @@ import { getCurrentUrl, Location, queryAll } from 'swup'; import Scrl from 'scrl'; /** - * Class representing a Scroll Plugin. + * Scroll Plugin * @extends Plugin */ export default class SwupScrollPlugin extends Plugin { name = 'SwupScrollPlugin'; + defaults = { + doScrollingRightAway: false, + animateScroll: { + betweenPages: true, + samePageWithHash: true, + samePage: true + }, + scrollFriction: 0.3, + scrollAcceleration: 0.04, + getAnchorElement: null, + offset: 0, + scrollContainers: `[data-swup-scroll-container]`, + shouldResetScrollPosition: (link) => true + }; + /** * Constructor * @param {object|undefined} options the plugin options */ constructor(options = {}) { super(); - const defaultOptions = { - doScrollingRightAway: false, - animateScroll: { - betweenPages: true, - samePageWithHash: true, - samePage: true - }, - scrollFriction: 0.3, - scrollAcceleration: 0.04, - getAnchorElement: null, - offset: 0, - scrollContainers: `[data-swup-scroll-container]`, - shouldResetScrollPosition: (htmlAnchorElement) => true - }; - - this.options = { - ...defaultOptions, - ...options - }; + this.options = { ...this.defaults, ...options }; } /** From acbb8284c288d3011720970ef8cd80874888179b Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Sat, 1 Jul 2023 14:50:40 +0200 Subject: [PATCH 07/17] Refactor to hooks and context --- src/index.js | 158 +++++++++++++++++++++++---------------------------- 1 file changed, 71 insertions(+), 87 deletions(-) diff --git a/src/index.js b/src/index.js index d231436..57d3e85 100755 --- a/src/index.js +++ b/src/index.js @@ -34,32 +34,31 @@ export default class SwupScrollPlugin extends Plugin { } /** - * Runs if the plugin is mounted + * Runs when the plugin is mounted */ mount() { const swup = this.swup; - // add empty handlers array for scroll events - swup._handlers.scrollDone = []; - swup._handlers.scrollStart = []; + swup.hooks.create('scrollStart'); + swup.hooks.create('scrollDone'); - // Initialize Scrl for smooth animations + // Initialize Scrl lib for smooth animations this.scrl = new Scrl({ - onStart: () => swup.triggerEvent('scrollStart'), - onEnd: () => swup.triggerEvent('scrollDone'), - onCancel: () => swup.triggerEvent('scrollDone'), + onStart: () => swup.hooks.triggerSync('scrollStart'), + onEnd: () => swup.hooks.triggerSync('scrollDone'), + onCancel: () => swup.hooks.triggerSync('scrollDone'), friction: this.options.scrollFriction, acceleration: this.options.scrollAcceleration }); - // set scrollTo method of swup and animate based on current animateScroll option + // Add scrollTo method to swup and animate based on current animateScroll option swup.scrollTo = (offset, animate = true) => { if (animate) { this.scrl.scrollTo(offset); } else { - swup.triggerEvent('scrollStart'); + swup.hooks.triggerSync('scrollStart'); window.scrollTo(0, offset); - swup.triggerEvent('scrollDone'); + swup.hooks.triggerSync('scrollDone'); } }; @@ -76,20 +75,23 @@ export default class SwupScrollPlugin extends Plugin { window.history.scrollRestoration = 'manual'; } + // reset scroll positions + swup.hooks.on('clickLink', this.onClickLink); + // scroll to the top of the page - swup.on('samePage', this.onSamePage); + swup.hooks.replace('samePage', this.onSamePage); // scroll to referenced element on the same page - swup.on('samePageWithHash', this.onSamePageWithHash); + swup.hooks.replace('samePageWithHash', this.onSamePageWithHash); - // scroll to the referenced element - swup.on('transitionStart', this.onTransitionStart); + // scroll to the top of the page when transition starts, before replacing the content + swup.hooks.on('transitionStart', this.onTransitionStart); - // scroll to the referenced element when it's in the page (after render) - swup.on('contentReplaced', this.onContentReplaced); + // store the current scroll positions before replacing the content + swup.hooks.before('replaceContent', this.onBeforeReplaceContent); - swup.on('willReplaceContent', this.onWillReplaceContent); - swup.on('clickLink', this.onClickLink); + // scroll to the top or target element after replacing the content + swup.hooks.replace('scrollToContent', this.onScrollToContent); } /** @@ -97,22 +99,17 @@ export default class SwupScrollPlugin extends Plugin { */ unmount() { const swup = this.swup; - swup.scrollTo = null; - + delete swup.scrollTo; delete this.scrl; - this.scrl = null; - - swup.off('samePage', this.onSamePage); - swup.off('samePageWithHash', this.onSamePageWithHash); - swup.off('transitionStart', this.onTransitionStart); - swup.off('contentReplaced', this.onContentReplaced); - swup.off('willReplaceContent', this.onWillReplaceContent); - swup.off('clickLink', this.onClickLink); - - swup._handlers.scrollDone = null; - swup._handlers.scrollStart = null; window.history.scrollRestoration = this.previousScrollRestoration; + + swup.hooks.off('clickLink', this.onClickLink); + swup.hooks.off('samePage', this.onSamePage); + swup.hooks.off('samePageWithHash', this.onSamePageWithHash); + swup.hooks.off('transitionStart', this.onTransitionStart); + swup.hooks.off('scrollToContent', this.onScrollToContent); + swup.hooks.off('replaceContent', this.onBeforeReplaceContent); } /** @@ -136,13 +133,9 @@ export default class SwupScrollPlugin extends Plugin { // Look for a custom function provided via the plugin options if (typeof this.options.getAnchorElement === 'function') { return this.options.getAnchorElement(hash); - } - // Look for a the built-in function in swup, added in swup 2.0.16 - if (typeof this.swup.getAnchorElement === 'function') { + } else { return this.swup.getAnchorElement(hash); } - // Finally, return a native browser query - return document.querySelector(hash); }; /** @@ -168,11 +161,9 @@ export default class SwupScrollPlugin extends Plugin { /** * Handles `onSamePageWithHash` - * @param {PointerEvent} event */ - onSamePageWithHash = (event) => { - const link = event.delegateTarget; - this.maybeScrollToAnchor(link.hash, 'samePageWithHash'); + onSamePageWithHash = (context, { hash }) => { + this.maybeScrollToAnchor(hash, 'samePageWithHash'); }; /** @@ -182,69 +173,73 @@ export default class SwupScrollPlugin extends Plugin { * @returns {boolean} */ maybeScrollToAnchor(hash, context) { - // Bail early if the hash is null - if (hash == null) { + if (!hash) { return false; } + const element = this.getAnchorElement(hash); if (!element) { - console.warn(`Element ${hash} not found`); + console.warn(`Anchor target ${hash} not found`); return false; } if (!(element instanceof Element)) { - console.warn(`Element ${hash} is not a DOM node`); + console.warn(`Anchor target ${hash} is not a DOM node`); return false; } - const top = - element.getBoundingClientRect().top + window.pageYOffset - this.getOffset(element); + + const { top: elementTop } = element.getBoundingClientRect(); + const top = elementTop + window.scrollY - this.getOffset(element); this.swup.scrollTo(top, this.shouldAnimate(context)); + return true; } /** * Handles `transitionStart` - * @param {PopStateEvent} popstate */ - onTransitionStart = (popstate) => { - if (this.options.doScrollingRightAway && !this.swup.scrollToElement) { - this.doScrollingBetweenPages(popstate); + onTransitionStart = (context) => { + if (this.options.doScrollingRightAway && !context.scroll.target) { + context.scroll.scrolledToContent = true; + this.doScrollingBetweenPages(context); } }; /** - * Handles `contentReplaced` - * @param {PopStateEvent} popstate + * Handles `scrollToContent` */ - onContentReplaced = (popstate) => { - if (!this.options.doScrollingRightAway || this.swup.scrollToElement) { - this.doScrollingBetweenPages(popstate); + onScrollToContent = (context) => { + if (!context.scroll.scrolledToContent) { + this.doScrollingBetweenPages(context); } - - this.restoreScrollContainers(popstate); + this.restoreScrollContainers(context); }; /** * Scrolls the window, based on context - * @param {(PopStateEvent|boolean)} popstate * @returns {void} */ - doScrollingBetweenPages = (popstate) => { + doScrollingBetweenPages = (context) => { const swup = this.swup; - // Bail early on popstate and inactive `animateHistoryBrowsing` - if (popstate && !swup.options.animateHistoryBrowsing) { + // Bail early on popstate if not animated: browser will handle it + if (context.history.popstate && !context.transition.animate) { return; } // Try scrolling to a given anchor - if (this.maybeScrollToAnchor(swup.scrollToElement, 'betweenPages')) { - swup.scrollToElement = null; + if (this.maybeScrollToAnchor(context.scroll.target, 'betweenPages')) { + return; + } + + // Allow not resetting scroll position + if (!context.scroll.reset) { return; } // Finally, scroll to either the stored scroll position or to the very top of the page const scrollPositions = this.getStoredScrollPositions(this.getCurrentCacheKey()) || {}; const top = (scrollPositions.window && scrollPositions.window.top) || 0; + // Give possible JavaScript time to execute before scrolling requestAnimationFrame(() => swup.scrollTo(top, this.shouldAnimate('betweenPages'))); }; @@ -252,31 +247,30 @@ export default class SwupScrollPlugin extends Plugin { /** * Stores the current scroll positions for the URL we just came from */ - onWillReplaceContent = () => { + onBeforeReplaceContent = () => { this.storeScrollPositions(this.currentCacheKey); this.currentCacheKey = this.getCurrentCacheKey(); }; /** * Handles `clickLink` - * @param {PointerEvent} * @returns {void} */ - onClickLink = (event) => { - this.maybeResetScrollPositions(event.delegateTarget); + onClickLink = (context, { el }) => { + this.maybeResetScrollPositions(context.trigger.el); }; /** * Deletes the scroll positions for the URL a link is pointing to, * if shouldResetScrollPosition evaluates to true - * @param {HTMLAnchorElement} htmlAnchorElement + * @param {HTMLElement} el * @returns {void} */ - maybeResetScrollPositions(htmlAnchorElement) { - if (!this.options.shouldResetScrollPosition(htmlAnchorElement)) { + maybeResetScrollPositions(el) { + if (!this.options.shouldResetScrollPosition(el)) { return; } - const { url } = Location.fromElement(htmlAnchorElement); + const { url } = Location.fromElement(el); this.resetScrollPositions(url); } @@ -304,7 +298,7 @@ export default class SwupScrollPlugin extends Plugin { * @param {string} url */ resetScrollPositions(url) { - const cacheKey = this.getResolvedUrl(url); + const cacheKey = this.swup.resolveUrl(url); delete this.scrollPositionsStore[cacheKey]; this.scrollPositionsStore[cacheKey] = null; } @@ -314,7 +308,7 @@ export default class SwupScrollPlugin extends Plugin { * @returns {(object|undefined)} */ getStoredScrollPositions(url) { - const cacheKey = this.getResolvedUrl(url); + const cacheKey = this.swup.resolveUrl(url); return this.scrollPositionsStore[cacheKey]; } @@ -322,7 +316,7 @@ export default class SwupScrollPlugin extends Plugin { * Restore the scroll positions for all matching scrollContainers * @returns void */ - restoreScrollContainers(popstate) { + restoreScrollContainers() { // get the stored scroll positions from the cache const scrollPositions = this.getStoredScrollPositions(this.getCurrentCacheKey()) || {}; if (scrollPositions.containers == null) { @@ -337,22 +331,12 @@ export default class SwupScrollPlugin extends Plugin { el.scrollLeft = scrollPosition.left; }); } + /** * Get the current cache key for the scroll positions. * @returns {string} */ getCurrentCacheKey() { - return this.getResolvedUrl(getCurrentUrl()); - } - /** - * Apply `swup.resolveUrl` to a given URL - * - * @returns {string} - */ - getResolvedUrl(url) { - if (typeof this.swup.resolveUrl === 'function') { - return this.swup.resolveUrl(url); - } - return url; + return this.swup.resolveUrl(getCurrentUrl()); } } From 85180fa5d14ae2cf02ecd239d90fde0b43beb098 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Sat, 1 Jul 2023 14:54:38 +0200 Subject: [PATCH 08/17] Require swup 4 --- src/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.js b/src/index.js index 57d3e85..334f978 100755 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,8 @@ import Scrl from 'scrl'; export default class SwupScrollPlugin extends Plugin { name = 'SwupScrollPlugin'; + requires = { swup: '>=4' }; + defaults = { doScrollingRightAway: false, animateScroll: { From d6a60080f36e2d05bcff5b69a7772f2c23348f36 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Sat, 1 Jul 2023 15:03:22 +0200 Subject: [PATCH 09/17] Create changelog --- CHANGELOG.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..61a55ea --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,65 @@ +# Changelog + + + +## [3.0.0] - 2023-07 + +- Update for swup 4 compatibility + +## [2.0.3] - 2023-06-12 + +- Make the plugin options optional + +## [2.0.2] - 2023-03-02 + +- Correctly resolve URLs + +## [2.0.1] - 2023-03-29 + +- Use shared browserslist config + +## [2.0.0] - 2023-01-18 + +- Switch to microbundle +- Export native ESM module +- Upgrade scroll library + +## [1.3.1] - 2022-08-30 + +- Wait for the next animationFrame before scrolling between pages + +## [1.3.0] - 2022-08-19 + +- Store and restore scroll positions on the window and on overflowing divs +- Restore browser scrollRestoration on unmount + +## [1.2.0] - 2022-08-07 + +- Allow fine-grained control over when to animate scroll +- Allow customizing how anchor element is found + +## [1.1.1] - 2022-06-30 + +- Improve handling of scroll anchors with special characters + +## [1.1.0] - 2021-03-13 + +- Allow setting custom scroll offset + +## [1.0.0] - 2019-05-01 + +- Initial release + +[Unreleased]: https://github.com/swup/scroll-plugin/compare/3.0.0...HEAD + +[3.0.0]: https://github.com/swup/scroll-plugin/releases/tag/3.0.0 +[2.0.3]: https://github.com/swup/scroll-plugin/releases/tag/2.0.3 +[2.0.2]: https://github.com/swup/scroll-plugin/releases/tag/2.0.2 +[2.0.1]: https://github.com/swup/scroll-plugin/releases/tag/2.0.1 +[2.0.0]: https://github.com/swup/scroll-plugin/releases/tag/2.0.0 +[1.3.1]: https://github.com/swup/scroll-plugin/releases/tag/1.3.1 +[1.3.0]: https://github.com/swup/scroll-plugin/releases/tag/1.3.0 +[1.2.0]: https://github.com/swup/scroll-plugin/releases/tag/1.2.0 +[1.1.1]: https://github.com/swup/scroll-plugin/releases/tag/1.1.1 +[1.1.0]: https://github.com/swup/scroll-plugin/releases/tag/1.1.0 +[1.0.0]: https://github.com/swup/scroll-plugin/releases/tag/1.0.0 From 2d87b0b02a6812f8133e923fe6f4c40afd67fb4d Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Sat, 1 Jul 2023 15:03:32 +0200 Subject: [PATCH 10/17] Update description --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 43561d9..d4b9285 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Swup Scroll plugin -A [swup](https://swup.js.org) plugin for smooth scrolling. +A [swup](https://swup.js.org) plugin for customizable smooth scrolling. - Enables acceleration-based smooth scrolling - Animates scroll position between page visits diff --git a/package.json b/package.json index 31a860c..f565005 100755 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@swup/scroll-plugin", "amdName": "SwupScrollPlugin", "version": "3.0.0", - "description": "A swup plugin for smooth scrolling", + "description": "A swup plugin for customizable smooth scrolling", "type": "module", "source": "src/index.js", "main": "./dist/index.cjs", From c4d4000d6123003fb578f468bec6d61b79bb5e81 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Sat, 1 Jul 2023 15:05:29 +0200 Subject: [PATCH 11/17] Bump swup version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f565005..d10fe1e 100755 --- a/package.json +++ b/package.json @@ -46,10 +46,10 @@ "scrl": "^2.0.0" }, "devDependencies": { - "swup": "^3.0.0" + "swup": "^4.0.0" }, "peerDependencies": { - "swup": "^3.0.0" + "swup": "^4.0.0" }, "browserslist": [ "extends @swup/browserslist-config" From c9571db1222caedb3bb08adb01138a0e9e1e1828 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Wed, 12 Jul 2023 19:37:12 +0200 Subject: [PATCH 12/17] Update hook names --- README.md | 6 +++--- src/index.js | 58 ++++++++++++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index d4b9285..dd0c8b2 100755 --- a/README.md +++ b/README.md @@ -189,9 +189,9 @@ swup.scrollTo(2000, true); ## Hooks -The plugin adds two new hooks `scrollStart` and `scrollDone` : +The plugin adds two new hooks `scroll:start` and `scroll:end` : ```js -swup.hooks.on('scrollStart', () => console.log('Swup started scrolling')); -swup.hooks.on('scrollDone', () => console.log('Swup finished scrolling')); +swup.hooks.on('scroll:start', () => console.log('Swup started scrolling')); +swup.hooks.on('scroll:end', () => console.log('Swup finished scrolling')); ``` diff --git a/src/index.js b/src/index.js index 334f978..379aa0a 100755 --- a/src/index.js +++ b/src/index.js @@ -41,14 +41,14 @@ export default class SwupScrollPlugin extends Plugin { mount() { const swup = this.swup; - swup.hooks.create('scrollStart'); - swup.hooks.create('scrollDone'); + swup.hooks.create('scroll:start'); + swup.hooks.create('scroll:end'); // Initialize Scrl lib for smooth animations this.scrl = new Scrl({ - onStart: () => swup.hooks.triggerSync('scrollStart'), - onEnd: () => swup.hooks.triggerSync('scrollDone'), - onCancel: () => swup.hooks.triggerSync('scrollDone'), + onStart: () => swup.hooks.triggerSync('scroll:start'), + onEnd: () => swup.hooks.triggerSync('scroll:end'), + onCancel: () => swup.hooks.triggerSync('scroll:end'), friction: this.options.scrollFriction, acceleration: this.options.scrollAcceleration }); @@ -58,9 +58,9 @@ export default class SwupScrollPlugin extends Plugin { if (animate) { this.scrl.scrollTo(offset); } else { - swup.hooks.triggerSync('scrollStart'); + swup.hooks.triggerSync('scroll:start'); window.scrollTo(0, offset); - swup.hooks.triggerSync('scrollDone'); + swup.hooks.triggerSync('scroll:end'); } }; @@ -78,22 +78,22 @@ export default class SwupScrollPlugin extends Plugin { } // reset scroll positions - swup.hooks.on('clickLink', this.onClickLink); + swup.hooks.on('link:click', this.onLinkClick); // scroll to the top of the page - swup.hooks.replace('samePage', this.onSamePage); + swup.hooks.replace('link:self', this.onLinkToSelf); // scroll to referenced element on the same page - swup.hooks.replace('samePageWithHash', this.onSamePageWithHash); + swup.hooks.replace('link:anchor', this.onLinkToAnchor); // scroll to the top of the page when transition starts, before replacing the content - swup.hooks.on('transitionStart', this.onTransitionStart); + swup.hooks.on('visit:start', this.onVisitStart); // store the current scroll positions before replacing the content - swup.hooks.before('replaceContent', this.onBeforeReplaceContent); + swup.hooks.before('content:replace', this.onBeforeReplaceContent); // scroll to the top or target element after replacing the content - swup.hooks.replace('scrollToContent', this.onScrollToContent); + swup.hooks.replace('content:scroll', this.onScrollToContent); } /** @@ -106,12 +106,12 @@ export default class SwupScrollPlugin extends Plugin { window.history.scrollRestoration = this.previousScrollRestoration; - swup.hooks.off('clickLink', this.onClickLink); - swup.hooks.off('samePage', this.onSamePage); - swup.hooks.off('samePageWithHash', this.onSamePageWithHash); - swup.hooks.off('transitionStart', this.onTransitionStart); - swup.hooks.off('scrollToContent', this.onScrollToContent); - swup.hooks.off('replaceContent', this.onBeforeReplaceContent); + swup.hooks.off('link:click', this.onLinkClick); + swup.hooks.off('link:self', this.onLinkToSelf); + swup.hooks.off('link:anchor', this.onLinkToAnchor); + swup.hooks.off('visit:start', this.onVisitStart); + swup.hooks.off('content:scroll', this.onScrollToContent); + swup.hooks.off('content:replace', this.onBeforeReplaceContent); } /** @@ -155,17 +155,17 @@ export default class SwupScrollPlugin extends Plugin { }; /** - * Handles `samePage` + * Scroll to top on `link:self` hook */ - onSamePage = () => { - this.swup.scrollTo(0, this.shouldAnimate('samePage')); + onLinkToSelf = () => { + this.swup.scrollTo(0, this.shouldAnimate('link:self')); }; /** - * Handles `onSamePageWithHash` + * Scroll to fragment on `link:anchor` hook */ - onSamePageWithHash = (context, { hash }) => { - this.maybeScrollToAnchor(hash, 'samePageWithHash'); + onLinkToAnchor = (context, { hash }) => { + this.maybeScrollToAnchor(hash, 'link:anchor'); }; /** @@ -197,9 +197,9 @@ export default class SwupScrollPlugin extends Plugin { } /** - * Handles `transitionStart` + * Check whether to scroll in `visit:start` hook */ - onTransitionStart = (context) => { + onVisitStart = (context) => { if (this.options.doScrollingRightAway && !context.scroll.target) { context.scroll.scrolledToContent = true; this.doScrollingBetweenPages(context); @@ -207,7 +207,7 @@ export default class SwupScrollPlugin extends Plugin { }; /** - * Handles `scrollToContent` + * Check whether to scroll in `content:scroll` hook */ onScrollToContent = (context) => { if (!context.scroll.scrolledToContent) { @@ -258,7 +258,7 @@ export default class SwupScrollPlugin extends Plugin { * Handles `clickLink` * @returns {void} */ - onClickLink = (context, { el }) => { + onLinkClick = (context, { el }) => { this.maybeResetScrollPositions(context.trigger.el); }; From b03fa39b3b98f6fb7d4fc519b190551e5294a951 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Fri, 21 Jul 2023 02:24:28 +0200 Subject: [PATCH 13/17] Update for recent changes --- package.json | 4 +-- src/index.js | 82 +++++++++++++++++++++------------------------------- 2 files changed, 35 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index d10fe1e..87a835d 100755 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "dev": "swup-plugin dev", "lint": "swup-plugin lint", "format": "swup-plugin format", - "prepublish": "npm run build" + "prepublishOnly": "npm run build" }, "author": { "name": "Georgy Marchuk", @@ -42,7 +42,7 @@ "url": "https://github.com/swup/scroll-plugin.git" }, "dependencies": { - "@swup/plugin": "^2.0.0", + "@swup/plugin": "^3.0.0", "scrl": "^2.0.0" }, "devDependencies": { diff --git a/src/index.js b/src/index.js index 379aa0a..e226f24 100755 --- a/src/index.js +++ b/src/index.js @@ -26,18 +26,11 @@ export default class SwupScrollPlugin extends Plugin { shouldResetScrollPosition: (link) => true }; - /** - * Constructor - * @param {object|undefined} options the plugin options - */ constructor(options = {}) { super(); this.options = { ...this.defaults, ...options }; } - /** - * Runs when the plugin is mounted - */ mount() { const swup = this.swup; @@ -46,9 +39,9 @@ export default class SwupScrollPlugin extends Plugin { // Initialize Scrl lib for smooth animations this.scrl = new Scrl({ - onStart: () => swup.hooks.triggerSync('scroll:start'), - onEnd: () => swup.hooks.triggerSync('scroll:end'), - onCancel: () => swup.hooks.triggerSync('scroll:end'), + onStart: () => swup.hooks.callSync('scroll:start'), + onEnd: () => swup.hooks.callSync('scroll:end'), + onCancel: () => swup.hooks.callSync('scroll:end'), friction: this.options.scrollFriction, acceleration: this.options.scrollAcceleration }); @@ -58,9 +51,9 @@ export default class SwupScrollPlugin extends Plugin { if (animate) { this.scrl.scrollTo(offset); } else { - swup.hooks.triggerSync('scroll:start'); + swup.hooks.callSync('scroll:start'); window.scrollTo(0, offset); - swup.hooks.triggerSync('scroll:end'); + swup.hooks.callSync('scroll:end'); } }; @@ -78,40 +71,33 @@ export default class SwupScrollPlugin extends Plugin { } // reset scroll positions - swup.hooks.on('link:click', this.onLinkClick); + this.on('link:click', this.onLinkClick); // scroll to the top of the page - swup.hooks.replace('link:self', this.onLinkToSelf); + this.replace('link:self', this.onLinkToSelf); // scroll to referenced element on the same page - swup.hooks.replace('link:anchor', this.onLinkToAnchor); + this.replace('link:anchor', this.onLinkToAnchor); // scroll to the top of the page when transition starts, before replacing the content - swup.hooks.on('visit:start', this.onVisitStart); + this.on('visit:start', this.onVisitStart); // store the current scroll positions before replacing the content - swup.hooks.before('content:replace', this.onBeforeReplaceContent); + this.before('content:replace', this.onBeforeReplaceContent); // scroll to the top or target element after replacing the content - swup.hooks.replace('content:scroll', this.onScrollToContent); + this.replace('content:scroll', this.onScrollToContent); } /** * Runs when the plugin is unmounted */ unmount() { - const swup = this.swup; - delete swup.scrollTo; - delete this.scrl; + super.unmount(); window.history.scrollRestoration = this.previousScrollRestoration; - - swup.hooks.off('link:click', this.onLinkClick); - swup.hooks.off('link:self', this.onLinkToSelf); - swup.hooks.off('link:anchor', this.onLinkToAnchor); - swup.hooks.off('visit:start', this.onVisitStart); - swup.hooks.off('content:scroll', this.onScrollToContent); - swup.hooks.off('content:replace', this.onBeforeReplaceContent); + delete this.swup.scrollTo; + delete this.scrl; } /** @@ -164,7 +150,7 @@ export default class SwupScrollPlugin extends Plugin { /** * Scroll to fragment on `link:anchor` hook */ - onLinkToAnchor = (context, { hash }) => { + onLinkToAnchor = (visit, { hash }) => { this.maybeScrollToAnchor(hash, 'link:anchor'); }; @@ -199,51 +185,49 @@ export default class SwupScrollPlugin extends Plugin { /** * Check whether to scroll in `visit:start` hook */ - onVisitStart = (context) => { - if (this.options.doScrollingRightAway && !context.scroll.target) { - context.scroll.scrolledToContent = true; - this.doScrollingBetweenPages(context); + onVisitStart = (visit) => { + if (this.options.doScrollingRightAway && !visit.scroll.target) { + visit.scroll.scrolledToContent = true; + this.doScrollingBetweenPages(visit); } }; /** * Check whether to scroll in `content:scroll` hook */ - onScrollToContent = (context) => { - if (!context.scroll.scrolledToContent) { - this.doScrollingBetweenPages(context); + onScrollToContent = (visit) => { + if (!visit.scroll.scrolledToContent) { + this.doScrollingBetweenPages(visit); } - this.restoreScrollContainers(context); + this.restoreScrollContainers(visit); }; /** - * Scrolls the window, based on context + * Scrolls the window * @returns {void} */ - doScrollingBetweenPages = (context) => { - const swup = this.swup; - + doScrollingBetweenPages = (visit) => { // Bail early on popstate if not animated: browser will handle it - if (context.history.popstate && !context.transition.animate) { + if (visit.history.popstate && !visit.transition.animate) { return; } // Try scrolling to a given anchor - if (this.maybeScrollToAnchor(context.scroll.target, 'betweenPages')) { + if (this.maybeScrollToAnchor(visit.scroll.target, 'betweenPages')) { return; } // Allow not resetting scroll position - if (!context.scroll.reset) { + if (!visit.scroll.reset) { return; } // Finally, scroll to either the stored scroll position or to the very top of the page const scrollPositions = this.getStoredScrollPositions(this.getCurrentCacheKey()) || {}; - const top = (scrollPositions.window && scrollPositions.window.top) || 0; + const top = scrollPositions.window?.top || 0; // Give possible JavaScript time to execute before scrolling - requestAnimationFrame(() => swup.scrollTo(top, this.shouldAnimate('betweenPages'))); + requestAnimationFrame(() => this.swup.scrollTo(top, this.shouldAnimate('betweenPages'))); }; /** @@ -255,11 +239,11 @@ export default class SwupScrollPlugin extends Plugin { }; /** - * Handles `clickLink` + * Handles `link:click` hook * @returns {void} */ - onLinkClick = (context, { el }) => { - this.maybeResetScrollPositions(context.trigger.el); + onLinkClick = (visit, { el }) => { + this.maybeResetScrollPositions(visit.trigger.el); }; /** From 20e16b45d9449a14b766a890aeb1d15eccf81533 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Mon, 24 Jul 2023 17:06:51 +0200 Subject: [PATCH 14/17] Update to use scroll hooks --- src/index.js | 61 +++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/src/index.js b/src/index.js index e226f24..cf8ea7e 100755 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ import Plugin from '@swup/plugin'; -import { getCurrentUrl, Location, queryAll } from 'swup'; +import { getCurrentUrl, queryAll } from 'swup'; import Scrl from 'scrl'; /** @@ -70,16 +70,10 @@ export default class SwupScrollPlugin extends Plugin { window.history.scrollRestoration = 'manual'; } - // reset scroll positions - this.on('link:click', this.onLinkClick); + // reset scroll positions when a visit starts + this.on('visit:start', this.maybeResetScrollPositions); - // scroll to the top of the page - this.replace('link:self', this.onLinkToSelf); - - // scroll to referenced element on the same page - this.replace('link:anchor', this.onLinkToAnchor); - - // scroll to the top of the page when transition starts, before replacing the content + // scroll to the top of the page when a visit starts, before replacing the content this.on('visit:start', this.onVisitStart); // store the current scroll positions before replacing the content @@ -87,6 +81,12 @@ export default class SwupScrollPlugin extends Plugin { // scroll to the top or target element after replacing the content this.replace('content:scroll', this.onScrollToContent); + + // scroll to the top of the page + this.replace('scroll:top', this.handleScrollToTop); + + // scroll to an anchor on the same page + this.replace('scroll:anchor', this.handleScrollToAnchor); } /** @@ -141,26 +141,27 @@ export default class SwupScrollPlugin extends Plugin { }; /** - * Scroll to top on `link:self` hook + * Scroll to top on `scroll:top` hook */ - onLinkToSelf = () => { - this.swup.scrollTo(0, this.shouldAnimate('link:self')); + handleScrollToTop = () => { + this.swup.scrollTo(0, this.shouldAnimate('samePage')); + return true; }; /** - * Scroll to fragment on `link:anchor` hook + * Scroll to anchor on `scroll:anchor` hook */ - onLinkToAnchor = (visit, { hash }) => { - this.maybeScrollToAnchor(hash, 'link:anchor'); + handleScrollToAnchor = (visit, { hash }) => { + return this.maybeScrollToAnchor(hash, this.shouldAnimate('samePageWithHash')); }; /** * Attempts to scroll to an anchor * @param {string} hash - * @param {string} context + * @param {boolean} animate * @returns {boolean} */ - maybeScrollToAnchor(hash, context) { + maybeScrollToAnchor(hash, animate = false) { if (!hash) { return false; } @@ -177,7 +178,7 @@ export default class SwupScrollPlugin extends Plugin { const { top: elementTop } = element.getBoundingClientRect(); const top = elementTop + window.scrollY - this.getOffset(element); - this.swup.scrollTo(top, this.shouldAnimate(context)); + this.swup.scrollTo(top, animate); return true; } @@ -213,7 +214,7 @@ export default class SwupScrollPlugin extends Plugin { } // Try scrolling to a given anchor - if (this.maybeScrollToAnchor(visit.scroll.target, 'betweenPages')) { + if (this.maybeScrollToAnchor(visit.scroll.target, this.shouldAnimate('betweenPages'))) { return; } @@ -238,26 +239,18 @@ export default class SwupScrollPlugin extends Plugin { this.currentCacheKey = this.getCurrentCacheKey(); }; - /** - * Handles `link:click` hook - * @returns {void} - */ - onLinkClick = (visit, { el }) => { - this.maybeResetScrollPositions(visit.trigger.el); - }; - /** * Deletes the scroll positions for the URL a link is pointing to, * if shouldResetScrollPosition evaluates to true - * @param {HTMLElement} el * @returns {void} */ - maybeResetScrollPositions(el) { - if (!this.options.shouldResetScrollPosition(el)) { - return; + maybeResetScrollPositions(visit) { + const { url } = visit.to; + const { el } = visit.trigger; + const shouldReset = !el || this.options.shouldResetScrollPosition(el); + if (shouldReset) { + this.resetScrollPositions(url); } - const { url } = Location.fromElement(el); - this.resetScrollPositions(url); } /** From 04758e018a7d6bfee9a50eef02756e63265be3ff Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Wed, 26 Jul 2023 00:58:30 +0200 Subject: [PATCH 15/17] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61a55ea..bbe5a94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ -## [3.0.0] - 2023-07 +## [3.0.0] - 2023-07-26 - Update for swup 4 compatibility From 15f6deb11d2bdfaff6e3f4608787632bcc5f1603 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Wed, 26 Jul 2023 09:26:29 +0200 Subject: [PATCH 16/17] Fix animation key --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index cf8ea7e..7d0befb 100755 --- a/src/index.js +++ b/src/index.js @@ -209,7 +209,7 @@ export default class SwupScrollPlugin extends Plugin { */ doScrollingBetweenPages = (visit) => { // Bail early on popstate if not animated: browser will handle it - if (visit.history.popstate && !visit.transition.animate) { + if (visit.history.popstate && !visit.animation.animate) { return; } From 103150d9dba8c499552c08837c0bd66005da1b66 Mon Sep 17 00:00:00 2001 From: Philipp Daun Date: Wed, 26 Jul 2023 11:46:56 +0200 Subject: [PATCH 17/17] Pin versions --- package-lock.json | 86 +++++++++++++++++++++++++++-------------------- package.json | 3 -- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6e41177..3545faf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,14 +9,11 @@ "version": "3.0.0", "license": "MIT", "dependencies": { - "@swup/plugin": "^2.0.0", + "@swup/plugin": "^3.0.0", "scrl": "^2.0.0" }, - "devDependencies": { - "swup": "^3.0.0" - }, "peerDependencies": { - "swup": "^3.0.0" + "swup": "^4.0.0" } }, "node_modules/@ampproject/remapping": { @@ -1930,9 +1927,9 @@ "integrity": "sha512-/3nBqG7LqmK1uqaCSTA6s2NwQBDQXNyLAFBzlX6uaxqjIQcAZyq6K+sgcQ40oj02Vn/2mLSkeL9DOfP7BPOwVA==" }, "node_modules/@swup/plugin": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@swup/plugin/-/plugin-2.0.2.tgz", - "integrity": "sha512-pde/zKIgXpbI+qy8rhuy8De8KniZRuwAoxuOoGTvhErolrW2khlYKtVXgPACRmmPJvGI5ZTfBzBN5txKfIGefQ==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@swup/plugin/-/plugin-3.0.0.tgz", + "integrity": "sha512-dCFhmFmucMY4ae4qo01fGocU74YrLwffTTtxCUO21OyDgFdywjO4RLP0pgjsiXueBbpcXkexbj4q+O19dWQRoA==", "dependencies": { "@swup/browserslist-config": "^1.0.0", "@swup/prettier-config": "^1.0.0", @@ -1941,7 +1938,7 @@ "prettier": "^2.7.1", "shelljs": "^0.8.5", "shelljs-live": "^0.0.5", - "swup": "^3.0.0" + "swup": "^4.0.0" }, "bin": { "swup-plugin": "bin/swup-plugin.js" @@ -2573,11 +2570,14 @@ } }, "node_modules/delegate-it": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/delegate-it/-/delegate-it-3.0.1.tgz", - "integrity": "sha512-XU8H4pjDGBW74hFIbjdLPnvtU3HF3P9bbZvoFBSBLb5JgNaTkRb/2lvC1V+9kmZsxVR0kad4bU3rYhQ/4Ij+Gw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/delegate-it/-/delegate-it-6.0.1.tgz", + "integrity": "sha512-ZS2hRm/SaoPzaeWcWyYjzVVF4/PgALZqma9FXsunFt4XQGVAtQ79Vx7v57vNQNaI75Rl12C+x6TkLqHS5PNKLg==", "dependencies": { - "typed-query-selector": "^2.6.1" + "typed-query-selector": "^2.10.0" + }, + "funding": { + "url": "https://github.com/sponsors/fregante" } }, "node_modules/dom-serializer": { @@ -4132,6 +4132,11 @@ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" }, + "node_modules/path-to-regexp": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz", + "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw==" + }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -5386,13 +5391,14 @@ } }, "node_modules/swup": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/swup/-/swup-3.0.3.tgz", - "integrity": "sha512-nSJUeMdyynZIyjHt62OZmnz/JBlDZo/87WkdylGatliTFWn7dSxoM2nsIYbU+uxokmXE5P/wZuCIfzzyBvD/vQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/swup/-/swup-4.0.0.tgz", + "integrity": "sha512-GQX9WKFJBe4mZaryKkb8QZHsVP9u0GbMauD/B/msthNFB7rbUOqO1eSvaZB9d4TypHCjbviZ6kKac0v9vChOOA==", "hasInstallScript": true, "dependencies": { - "delegate-it": "^3.0.1", - "opencollective-postinstall": "^2.0.2" + "delegate-it": "^6.0.0", + "opencollective-postinstall": "^2.0.2", + "path-to-regexp": "^6.2.1" } }, "node_modules/terser": { @@ -5453,9 +5459,9 @@ } }, "node_modules/typed-query-selector": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.8.0.tgz", - "integrity": "sha512-jo9NLGQ0b7sT9TK3mxzemATQqTb/uh8TRvcOK6WSwKNewALt3AA8q2m7cdpF/uUbd/cdixaBxCGe6fpzpEWbGw==" + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.11.0.tgz", + "integrity": "sha512-qBs4sfmnLlPOyo2oSdvHbIFHe2CPgU54/1UGfSNceb7LARpIEVxUaeRX0Doje6oKpuySS2stqy90R3YrynR8Kg==" }, "node_modules/typescript": { "version": "4.9.4", @@ -6978,9 +6984,9 @@ "integrity": "sha512-/3nBqG7LqmK1uqaCSTA6s2NwQBDQXNyLAFBzlX6uaxqjIQcAZyq6K+sgcQ40oj02Vn/2mLSkeL9DOfP7BPOwVA==" }, "@swup/plugin": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@swup/plugin/-/plugin-2.0.2.tgz", - "integrity": "sha512-pde/zKIgXpbI+qy8rhuy8De8KniZRuwAoxuOoGTvhErolrW2khlYKtVXgPACRmmPJvGI5ZTfBzBN5txKfIGefQ==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@swup/plugin/-/plugin-3.0.0.tgz", + "integrity": "sha512-dCFhmFmucMY4ae4qo01fGocU74YrLwffTTtxCUO21OyDgFdywjO4RLP0pgjsiXueBbpcXkexbj4q+O19dWQRoA==", "requires": { "@swup/browserslist-config": "^1.0.0", "@swup/prettier-config": "^1.0.0", @@ -6989,7 +6995,7 @@ "prettier": "^2.7.1", "shelljs": "^0.8.5", "shelljs-live": "^0.0.5", - "swup": "^3.0.0" + "swup": "^4.0.0" } }, "@swup/prettier-config": { @@ -7420,11 +7426,11 @@ } }, "delegate-it": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/delegate-it/-/delegate-it-3.0.1.tgz", - "integrity": "sha512-XU8H4pjDGBW74hFIbjdLPnvtU3HF3P9bbZvoFBSBLb5JgNaTkRb/2lvC1V+9kmZsxVR0kad4bU3rYhQ/4Ij+Gw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/delegate-it/-/delegate-it-6.0.1.tgz", + "integrity": "sha512-ZS2hRm/SaoPzaeWcWyYjzVVF4/PgALZqma9FXsunFt4XQGVAtQ79Vx7v57vNQNaI75Rl12C+x6TkLqHS5PNKLg==", "requires": { - "typed-query-selector": "^2.6.1" + "typed-query-selector": "^2.10.0" } }, "dom-serializer": { @@ -8537,6 +8543,11 @@ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" }, + "path-to-regexp": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz", + "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw==" + }, "path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -9367,12 +9378,13 @@ } }, "swup": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/swup/-/swup-3.0.3.tgz", - "integrity": "sha512-nSJUeMdyynZIyjHt62OZmnz/JBlDZo/87WkdylGatliTFWn7dSxoM2nsIYbU+uxokmXE5P/wZuCIfzzyBvD/vQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/swup/-/swup-4.0.0.tgz", + "integrity": "sha512-GQX9WKFJBe4mZaryKkb8QZHsVP9u0GbMauD/B/msthNFB7rbUOqO1eSvaZB9d4TypHCjbviZ6kKac0v9vChOOA==", "requires": { - "delegate-it": "^3.0.1", - "opencollective-postinstall": "^2.0.2" + "delegate-it": "^6.0.0", + "opencollective-postinstall": "^2.0.2", + "path-to-regexp": "^6.2.1" } }, "terser": { @@ -9423,9 +9435,9 @@ } }, "typed-query-selector": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.8.0.tgz", - "integrity": "sha512-jo9NLGQ0b7sT9TK3mxzemATQqTb/uh8TRvcOK6WSwKNewALt3AA8q2m7cdpF/uUbd/cdixaBxCGe6fpzpEWbGw==" + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.11.0.tgz", + "integrity": "sha512-qBs4sfmnLlPOyo2oSdvHbIFHe2CPgU54/1UGfSNceb7LARpIEVxUaeRX0Doje6oKpuySS2stqy90R3YrynR8Kg==" }, "typescript": { "version": "4.9.4", diff --git a/package.json b/package.json index 87a835d..892b6fc 100755 --- a/package.json +++ b/package.json @@ -45,9 +45,6 @@ "@swup/plugin": "^3.0.0", "scrl": "^2.0.0" }, - "devDependencies": { - "swup": "^4.0.0" - }, "peerDependencies": { "swup": "^4.0.0" },