Skip to content

Commit

Permalink
Add forward/backward support for same-page anchor scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
jayohms committed Sep 8, 2021
1 parent 105041c commit b836b8d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions turbo/src/main/assets/js/turbo_bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@
// Adapter interface

visitProposedToLocation(location, options) {
if (window.Turbo && Turbo.navigator.locationWithActionIsSamePage(location, options.action)) {
Turbo.navigator.view.scrollToAnchorFromLocation(location)
} else {
TurboSession.visitProposedToLocation(location.toString(), JSON.stringify(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))
}

// Turbolinks 5
Expand Down

0 comments on commit b836b8d

Please sign in to comment.