diff --git a/README.md b/README.md index ce66b67..6c9c8f5 100755 --- a/README.md +++ b/README.md @@ -139,18 +139,23 @@ To highlight the current target element, use the `data-swup-scroll-target` attri ### Offset -Offset to substract from the final scroll position, to account for fixed headers. Can be either a number or a function that returns the offset. +Offset to substract from the final scroll position, to account for fixed headers. Can be either a +static number or a function that returns a value based on the scroll target. To apply differing +offsets for vertical and horizontal scrolling, return an object with `top` and `left` properties. ```javascript { // Number: fixed offset in px offset: 30, + // Object: fixed vertical and horizontal offset in px + offset: { top: 30, left: 10 }, + // Function: calculate offset before scrolling offset: () => document.querySelector('#header').offsetHeight, - // The scroll target element is passed into the function - offset: target => target.offsetHeight * 2, + // The scroll target and container are passed into the function + offset: (scrollTarget, scrollContainer) => target.offsetHeight * 2, } ``` diff --git a/package-lock.json b/package-lock.json index fa65c3a..87fc95d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,9 +23,6 @@ "tailwindcss": "^4.1.8", "typescript": "^5.8.3", "vitest": "^3.2.2" - }, - "peerDependencies": { - "swup": "^4.2.0" } }, "node_modules/@ampproject/remapping": { diff --git a/package.json b/package.json index c62783b..69d0e03 100755 --- a/package.json +++ b/package.json @@ -25,9 +25,9 @@ "lint": "swup package:lint", "format": "swup package:format", "prepublishOnly": "npm run build", - "fixtures:dev": "astro dev --root tests/e2e/fixtures", - "fixtures:build": "astro build --root tests/e2e/fixtures", - "fixtures:serve": "astro build --root tests/e2e/fixtures && astro preview --root tests/e2e/fixtures", + "playground:dev": "astro dev --root playground", + "playground:build": "astro build --root playground", + "playground:serve": "astro build --root playground && astro preview --root playground", "test": "npm run test:unit && npm run test:e2e", "test:unit": "vitest run --config ./tests/unit/vitest.config.ts", "test:unit:watch": "vitest --config ./tests/unit/vitest.config.ts", @@ -73,9 +73,6 @@ "typescript": "^5.8.3", "vitest": "^3.2.2" }, - "peerDependencies": { - "swup": "^4.2.0" - }, "browserslist": [ "extends @swup/browserslist-config" ], diff --git a/tests/e2e/fixtures/.astro/content-assets.mjs b/playground/.astro/content-assets.mjs similarity index 100% rename from tests/e2e/fixtures/.astro/content-assets.mjs rename to playground/.astro/content-assets.mjs diff --git a/tests/e2e/fixtures/.astro/content-modules.mjs b/playground/.astro/content-modules.mjs similarity index 100% rename from tests/e2e/fixtures/.astro/content-modules.mjs rename to playground/.astro/content-modules.mjs diff --git a/tests/e2e/fixtures/.astro/content.d.ts b/playground/.astro/content.d.ts similarity index 100% rename from tests/e2e/fixtures/.astro/content.d.ts rename to playground/.astro/content.d.ts diff --git a/tests/e2e/fixtures/.astro/data-store.json b/playground/.astro/data-store.json similarity index 100% rename from tests/e2e/fixtures/.astro/data-store.json rename to playground/.astro/data-store.json diff --git a/tests/e2e/fixtures/.astro/settings.json b/playground/.astro/settings.json similarity index 100% rename from tests/e2e/fixtures/.astro/settings.json rename to playground/.astro/settings.json diff --git a/tests/e2e/fixtures/.astro/types.d.ts b/playground/.astro/types.d.ts similarity index 100% rename from tests/e2e/fixtures/.astro/types.d.ts rename to playground/.astro/types.d.ts diff --git a/tests/e2e/fixtures/astro.config.mjs b/playground/astro.config.mjs similarity index 100% rename from tests/e2e/fixtures/astro.config.mjs rename to playground/astro.config.mjs diff --git a/playground/src/components/AnchorsPageContent.astro b/playground/src/components/AnchorsPageContent.astro new file mode 100644 index 0000000..f4fa30f --- /dev/null +++ b/playground/src/components/AnchorsPageContent.astro @@ -0,0 +1,149 @@ +--- +import Tiles from './Tiles.astro'; +import Table from './Table.astro'; +import Nav from './Nav.astro'; +--- + +
+
+

Vertical

+
+ +
+
+ +