Skip to content

Commit

Permalink
Merge pull request #4054 from c2corg/swipe-navigation
Browse files Browse the repository at this point in the history
fix: closing swipe gallery on back navigation and fix #4053
  • Loading branch information
brunobesson authored Oct 18, 2024
2 parents 6cceaa5 + c4d029f commit ab1ebe6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 0 additions & 8 deletions src/components/image-viewer/ImageViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ export default {
};
this.$refs.swiper.addEventListener('init', () => {
window.history.pushState(null, null, '#swipe-gallery');
// close when the user goes back in history
window.addEventListener('popstate', this.close);
// close on mouse wheel
Expand Down Expand Up @@ -213,12 +211,6 @@ export default {
this.zt = null;
}
this.hideButtons = false;
// if we closed without hitting back, go back once in history
// to remove the hash
if (window.location.hash === '#swipe-gallery') {
window.history.back();
}
},
onKeydown(event) {
Expand Down
6 changes: 5 additions & 1 deletion src/views/document/utils/document-view-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export default {
},

handleRedirection() {
if (this.document.redirects_to) {
if (this.document?.redirects_to) {
this.$router.push({ params: { id: this.document.redirects_to } });
}
},
Expand Down Expand Up @@ -265,6 +265,10 @@ export default {
},

updateUrl() {
if (!this.document) {
return;
}

const currentPath = this.getCurrentPath();
if (this.$route.path !== currentPath) {
this.$router.replace(currentPath);
Expand Down

0 comments on commit ab1ebe6

Please sign in to comment.