feat: sync current slide with a URL query parameter - #190
Merged
Merged
Conversation
With urlHash enabled, the carousel jumps to the slide given in the URL hash on start and on hashchange (shbatm#3 = third slide, or a slide name in slides mode) and writes the current slide number back on every transition via history.replaceState, so no feedback loop and no history entries. Navigation reuses handleCarouselGoto, so transitionTimeout and homeSlide behave as with any manual navigation. Not supported in positional mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Thanks for the PR! This seems like a useful feature. What do you think of a namespaced query parameter such as |
Author
|
you are right about the namespace. |
Collaborator
|
Nice. Would you like to adapt your PR? :) |
Author
|
@KristjanESPERANTO yes. i let claude rework the patch |
Collaborator
|
Thanks :) I saw your commit. I'll need a little time to review it. |
Merged
Collaborator
|
I did some more fine-tuning and included it in the new release 😃 Thanks again! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
New option
urlHash(defaultfalse). When enabled:http://localhost:8080/#3.CAROUSEL_GOTO. Inslidesmode, a slide name works too, e.g.#Home.Why
Many setups show the mirror in a browser (tablet, second screen,
serveronly). A URL per page makes it possible to bookmark a page, share a link to it, or have a kiosk browser start on a given page. Before this change, there was no way to do that without a remote-control module.How
decodeUrlHash,parseUrlHash) returns the same payloads thathandleCarouselGotoaccepts. Navigation therefore goes through the existingCAROUSEL_GOTOpath, includingrestartTimer, sotransitionTimeoutandhomeSlidebehave the same as with any other manual navigation.moduleTransitioncallsupdateUrlHash, which useshistory.replaceState. This does not firehashchange, so there is no feedback loop, and automatic rotation does not add browser history entries.updateUrlHashis inactive untilsetupUrlHashhas run. Without that guard, the initial transition would overwrite the start hash with#1before it was read.positionalmode is not supported, because each position has its own index. A warning is logged, the same as forenableKeyboardControl.Tests
parseUrlHash,setupUrlHashandupdateUrlHash. Thewindowmock in the test context is now a named object so tests can stublocation,historyandaddEventListener.node --run testpasses: unit tests, eslint, prettier and cspell.slidesmode and MMM-KeyBindings 3.1.0:#2🤖 Generated with Claude Code