From 51624c16fcbe1c1baece29bf5280c2096ec2b77f Mon Sep 17 00:00:00 2001 From: Fernando Mendes Date: Tue, 4 Feb 2020 17:57:09 -0300 Subject: [PATCH 1/3] Adds autoUpdateAnchorHash option, default to true --- README.md | 11 ++++++----- src/Manager.js | 10 +++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4ad634b..950dfdb 100644 --- a/README.md +++ b/README.md @@ -65,11 +65,12 @@ configureAnchors({offset: -60, scrollDuration: 200}) ##### Options: -| option | default | -| -------------------- | ---------------- | -| `offset` | `0` | -| `scrollDuration` | `400` | -| `keepLastAnchorHash` | `false` | +| option | default | +| ---------------------- | ---------------- | +| `offset` | `0` | +| `scrollDuration` | `400` | +| `keepLastAnchorHash` | `false` | +| `autoUpdateAnchorHash` | `true` | ### 3. Utilities diff --git a/src/Manager.js b/src/Manager.js index 6d74f72..150dd3d 100644 --- a/src/Manager.js +++ b/src/Manager.js @@ -7,6 +7,7 @@ const defaultConfig = { offset: 0, scrollDuration: 400, keepLastAnchorHash: false, + autoUpdateAnchorHash: true, } class Manager { @@ -60,10 +61,13 @@ class Manager { } handleScroll = () => { - const {offset, keepLastAnchorHash} = this.config - const bestAnchorId = getBestAnchorGivenScrollLocation(this.anchors, offset) + const {offset, keepLastAnchorHash, autoUpdateAnchorHash} = this.config + let bestAnchorId; - if (bestAnchorId && getHash() !== bestAnchorId) { + if (autoUpdateAnchorHash) + bestAnchorId = getBestAnchorGivenScrollLocation(this.anchors, offset) + + if (autoUpdateAnchorHash && bestAnchorId && getHash() !== bestAnchorId) { this.forcedHash = true updateHash(bestAnchorId, false) } else if (!bestAnchorId && !keepLastAnchorHash) { From 0901b4e9549dd434c7274270a6df717c621b3caa Mon Sep 17 00:00:00 2001 From: Fernando Mendes Date: Tue, 4 Feb 2020 18:15:28 -0300 Subject: [PATCH 2/3] Update package information --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 244e691..0454ce2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "react-scrollable-anchor", + "name": "@fernando-msj/react-scrollable-anchor", "version": "0.6.2", "description": "Provide smooth scrolling anchors in React.", "main": "lib/index.js", @@ -36,12 +36,12 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/gabergg/react-scrollable-anchor.git" + "url": "https://github.com/fernando-msj/react-scrollable-anchor.git" }, "bugs": { "url": "https://github.com/gabergg/react-scrollable-anchor/issues" }, - "homepage": "https://github.com/gabergg/react-scrollable-anchor", + "homepage": "https://github.com/fernando-msj/react-scrollable-anchor", "dependencies": { "jump.js": "1.0.2", "prop-types": "^15.5.10" @@ -66,4 +66,4 @@ "mocha": "^2.2.5", "rimraf": "^2.5.0" } -} +} \ No newline at end of file From 4a0bc5b284e5e442dbf1dde61ff6d4a8221f1416 Mon Sep 17 00:00:00 2001 From: Fernando Mendes Date: Tue, 4 Feb 2020 18:18:26 -0300 Subject: [PATCH 3/3] Undo changes so they arent included in the PR --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 0454ce2..b03f711 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@fernando-msj/react-scrollable-anchor", + "name": "react-scrollable-anchor", "version": "0.6.2", "description": "Provide smooth scrolling anchors in React.", "main": "lib/index.js", @@ -36,12 +36,12 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/fernando-msj/react-scrollable-anchor.git" + "url": "https://github.com/gabergg/react-scrollable-anchor.git" }, "bugs": { "url": "https://github.com/gabergg/react-scrollable-anchor/issues" }, - "homepage": "https://github.com/fernando-msj/react-scrollable-anchor", + "homepage": "https://github.com/gabergg/react-scrollable-anchor", "dependencies": { "jump.js": "1.0.2", "prop-types": "^15.5.10"