Comments (9)
You want to use both pushState and hashes at the same time? As you've noticed - cherrytree in pushState mode will replace #/foo to /foo on startup. I will implement an option to disable this behaviour. This way, cherrytree will just use the URL as is and leave the hash alone. I might even look into exposing the hash as part of the router params.
The tricky bit here is that the automatic fallback to hash behaviour will kind of break. Tbh I don't know if browsers without pushState
is still a thing. Perhaps, in this case, the router will go into hash mode and will simply drop the other hash. Would that be acceptable?
from cherrytree.
Actually this happens in location-bar lib on
https://github.com/KidkArolis/location-bar/blob/master/location-bar.js#L198
on start replaces /#something with /something
from cherrytree.
ok I solved it by settings location to BrowserLocation with custom options. Setting hashChange: false do the trick
const router = Cherrytree({
interceptLinks: true,
pushState:true,
location: new Cherrytree.BrowserLocation({pushState: true, hashChange: false, root: '/'})
})
from cherrytree.
ahh.. that only works for initial router call, further transitions don't work anymore :/
from cherrytree.
I just want to use pushState (without legacy hash change) where urls may also include hashes.
An hash as part of router params and option to enable or disable fallback, yes that will be great.
from cherrytree.
With hashes included what would then happen when you'll navigate to same path and only the hash part will change? Transition won't fire, right? ..just hash part will change in url?
from cherrytree.
That's a good question, will have to try and find out. If I start passing hash as one of the params, then it might make sense to fire a transition (just like if a query param changes). If I don't pass hash as one of the router params to transition middleware, then perhaps I should ignore hash changes. Also - I'm not sure if I can even detect hash changes and push state changes at the same time in any sensible way.
from cherrytree.
I wouldn't fire transition if only the hash part changes, but url should be updated anyway. It looks like hash change won't fire a page jump (http://lea.verou.me/2011/05/change-url-hash-without-page-jump/) when changed via pushState, but thats ok I guess. If you are using pushState, you control what happens.
from cherrytree.
Hey, so this is still a very interesting issue for me, as making it possible to utilise hashes in cherrytree sounds like it could be a useful feature, e.g. for anchoring/scrolling to page elements like it's intended, or to encode some clientside params.
I don't have the time to look into how to implement this right away, but I'll keep this issue open for now.
from cherrytree.
Related Issues (20)
- Add routes dinamically. Is it possible? HOT 2
- Fix tests. Oopsy. HOT 1
- Handle url Entries HOT 2
- Menu has dark blue highlights on black text HOT 1
- Menu has dark blue highlights on black text HOT 1
- Feature request: Ability to drag-and-drop images or to embed files HOT 2
- query param with urlencoded newline breakes route detection HOT 1
- Clarify Route Nesting example in the guide HOT 1
- Error transitioning to an abstract route with an index route HOT 3
- Transition silently
- Transition resolve handler added by middleware runs after handler added by application HOT 10
- Saucelabs build is failing HOT 2
- Route names must be unique error! But different leaf nodes. HOT 1
- Unable to generate url for abstract routes HOT 4
- The latest release in npm is not compiled to ES5 (?) HOT 1
- Consider replacing webpack by rollup
- cherrytree abandoned? HOT 3
- Interest in keeping cherrytree development HOT 7
- Provide typescript definitions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cherrytree.