Skip to content

Commit 947c188

Browse files
authored
Merge pull request #175 from hotwired/same-page-anchors
Support same-page anchor scrolling
2 parents 42b4883 + b836b8d commit 947c188

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

turbo/src/main/assets/js/turbo_bridge.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@
9292
// Adapter interface
9393

9494
visitProposedToLocation(location, options) {
95+
if (window.Turbo && typeof Turbo.navigator.locationWithActionIsSamePage === "function") {
96+
if (Turbo.navigator.locationWithActionIsSamePage(location, options.action)) {
97+
Turbo.navigator.view.scrollToAnchorFromLocation(location)
98+
return
99+
}
100+
}
101+
95102
TurboSession.visitProposedToLocation(location.toString(), JSON.stringify(options))
96103
}
97104

0 commit comments

Comments
 (0)