Routing mechanism #614
Replies: 5 comments
-
This is where the routing logic is: https://github.com/mint-lang/mint-runtime/blob/master/source/Program.js#L128 the routes in |
Beta Was this translation helpful? Give feedback.
-
Thank you. This explains why the scrolling happens, In my opinion, that is not so good. (when the jumping happens in the router) Consider this code: routes {
/known {
Debug.log("/known")
}
}
component Main {
style margin {
margin: 90vh 0;
}
fun render : Html {
<div::margin>
<button onClick={() { Window.navigate("/known") }}>
"/known"
</button>
" "
<button onClick={() { Window.navigate("/unknown") }}>
"/unknown"
</button>
" "
<a href="/known">
"/known"
</a>
", "
<a href="/unknown">
"/unknown"
</a>
</div>
}
} This table shows when the page will scroll to the start and when not:
In my opinion, all clicks on links should always scroll, and the clicks on the buttons should scroll depending on if the developer calls And because calling two functions, in order to do the probably most desired thing, is a bit clumsy, I also would like to suggest an addition of a function What is your opinion on this? @gdotdesign, @Sija ? |
Beta Was this translation helpful? Give feedback.
-
I will just implement this and make a PR, then we can see clearer :-) |
Beta Was this translation helpful? Give feedback.
-
This is implemented, so I'm closing this discussion. |
Beta Was this translation helpful? Give feedback.
-
Ah thx, forgot. |
Beta Was this translation helpful? Give feedback.
-
When I do something like this, which code gets called internally?
I am asking because
Window.navigate()
jumps, when the target URL is defined in a route, but not otherwise. So I assume this is something done in the route logic.Beta Was this translation helpful? Give feedback.
All reactions