mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
improve navigation effects
This commit is contained in:
parent
7995ba452d
commit
6e30d97248
@ -165,31 +165,46 @@ const NavigationController = (props) => {
|
||||
state = {}
|
||||
}
|
||||
|
||||
app.location.last = window.location
|
||||
|
||||
await navigate(to, {
|
||||
state
|
||||
})
|
||||
|
||||
app.eventBus.emit("router.navigate", to, {
|
||||
state,
|
||||
})
|
||||
|
||||
app.location.last = window.location
|
||||
|
||||
return navigate(to, {
|
||||
state
|
||||
})
|
||||
return {
|
||||
to,
|
||||
state,
|
||||
}
|
||||
}
|
||||
|
||||
async function backLocation() {
|
||||
app.eventBus.emit("router.navigate")
|
||||
|
||||
app.location.last = window.location
|
||||
|
||||
return window.history.back()
|
||||
}
|
||||
|
||||
async function onHistoryChange() {
|
||||
setTimeout(() => {
|
||||
app.eventBus.emit("router.navigate", window.location.pathname, {
|
||||
state: window.location.state,
|
||||
})
|
||||
}, 0)
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
app.location = {
|
||||
last: window.location,
|
||||
push: setLocation,
|
||||
back: backLocation,
|
||||
}
|
||||
|
||||
window.addEventListener("popstate", onHistoryChange)
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("popstate", onHistoryChange)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return props.children
|
||||
|
Loading…
x
Reference in New Issue
Block a user