Skip to content

Commit

Permalink
Merge pull request #175 from hotwired/same-page-anchors
Browse files Browse the repository at this point in the history
Support same-page anchor scrolling
  • Loading branch information
jayohms authored Sep 8, 2021
2 parents 42b4883 + b836b8d commit 947c188
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions turbo/src/main/assets/js/turbo_bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@
// Adapter interface

visitProposedToLocation(location, options) {
if (window.Turbo && typeof Turbo.navigator.locationWithActionIsSamePage === "function") {
if (Turbo.navigator.locationWithActionIsSamePage(location, options.action)) {
Turbo.navigator.view.scrollToAnchorFromLocation(location)
return
}
}

TurboSession.visitProposedToLocation(location.toString(), JSON.stringify(options))
}

Expand Down

0 comments on commit 947c188

Please sign in to comment.