5 ms·
finally, a slide deck that uses `history.replaceState` instead of `history.pushState`. no more having to hit "back" 90 times to exit the deck. how the latter ev
by leeoniya 12y ago
finally, a slide deck that uses `history.replaceState` instead of `history.pushState`. no more having to hit "back" 90 times to exit the deck. how the latter ever became a pattern is beyond me.
[EDIT] it probably became a pattern because of browsers that didnt implement the history API, so all hashchange events were pushed onto the history stack.
- 9point6 12y agoTo be honest, using replaceState for this doesn't seem to make sense to me. A user would probably want to go backward and forward through this using browser history navigation (for instance using the navigation buttons on their mouse). If you're launching a link from a page you expected to come back to, surely opening the link in a new tab would be the way to accomplish this?
- leeoniya 12y agopersonally, i've always used arrow keys, swipes, pgup/pgdn to nav between slides. i want a single-action "exit slide deck to previous page", and the browser's back is the logical place for that to be, imho.
- jmathai 12y agoI think the lines between a single page app and full page reloads needs to be blurred. Most people won't know the difference and the back button needs to behave consistently. For that reason, I think that pushState here would make more sense. The state of the page does, after all, change.
- leeoniya 12y agoit's not a mental "context switch", though. i think the way android has the back button implemented is very sensible.
- lobster_johnson 12y agoYelp does this with its photo gallery, and it's really annoying. When the user is in a linear sequence such as a slide deck, photo gallery or similar, the "previous"/"next" buttons don't map to the browser's back/forward buttons, they navigate the sequence. Littering the history with the navigation history of this sequence does not make sense. However, it'd be nice if browsers could perhaps record the history (perhaps as some kind of sub-tree history), allowing me to see that I not only visited this slide deck, but that I also visited these specific slides.
- Touche 12y agoThere's no real distinction. If the slides were implemented as separate pages you would get a new entry in your history as you navigate through each of them. Back doesn't mean to go back to the previous domain; it means the previous page. You don't think the slides should be separate pages, but that would mean you couldn't link to them.
- lobster_johnson 12y agoAnd that's bad. A lot of people pine for the simplicity of the early days of the web, but single-page pagination was arguably even more horribly broken then.
- leeoniya 12y agowith replaceState, you get the best of both worlds - bookmarkable slides and no history foo.
- nilliams 12y agoExcept you can accidentally exit the deck when you actually meant to just go to the previous slide. I don't think this is better personally. I prefer the use of pushState and back button taking me to the previous slide. If I really want to back all the way out of the slide deck I will notice after a couple of clicks I need to do something further to go 'all the way back' and right click the back button and click a 'non-slide-deck' selection from that menu.
- dugmartin 12y agoMy rule is pushState() makes sense in apps when changing views , say from a "List of X" to the "Edit X" view. The back button should then take me back to a "List of X". In this case it doesn't make sense as you remain in the "slide" view the entire time.
- SerpentJoe 12y agoYou could always do it right with `location.replace`, but that was never as common as it should have been. https://developer.mozilla.org/en-US/docs/Web/API/Location.replace https://developer.mozilla.org/en-US/docs/Web/API/Location.re...
- TazeTSchnitzel 12y agoMaking each slide its own navigation event isn't bad, the problem is that browsers somehow still don't let you jump back to the previous website, not sub-page.
- leeoniya 12y agohow do you imagine this would work?
- nunull 12y agoI'd like to have CMD+Backspace do that.
- TazeTSchnitzel 12y agoCollapsing entries on the same page in the back button right-click menu.
- leeoniya 12y agothat may be a good solution, if all hashchanges get grouped.
- Touche 12y agoWhat are you defining as a website? A domain? If I have a: * myname.com/about.html * myname.com/projects.html Would you want to jump out of myname.com entirely when you press back? If not, how do you differentiate that from slides with myname.com/slide1, myname.com/slide2?