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/package.json b/package.json index 244e691..b03f711 100644 --- a/package.json +++ b/package.json @@ -66,4 +66,4 @@ "mocha": "^2.2.5", "rimraf": "^2.5.0" } -} +} \ No newline at end of file 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) {