Skip to content

Commit 9e1031a

Browse files
Add new url to browser history
1 parent 30feca1 commit 9e1031a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

package/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ window.addEventListener('message', ({ data: { action, payload } }) => { //runs a
1313
switch (action) {
1414
case 'jumpToSnap':
1515
timeJump(payload);
16+
// Get the pathname from payload and add new entry to browser history
17+
// MORE: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
18+
if (payload.children[0].state && payload.children[0].state.location) {
19+
const route = payload.children[0].state.location.pathname;
20+
window.history.pushState(route);
21+
}
1622
break;
1723
case 'setLock':
1824
mode.locked = payload;

0 commit comments

Comments
 (0)