Skip to content

Commit

Permalink
Fix browser back/forward button behavior.
Browse files Browse the repository at this point in the history
Sholuld fix #2703. I removed the history.pushState line since it
was making some of the history (images viewed) to disappear after
the gallery was closed and the buttons were used.
  • Loading branch information
osiux committed Sep 17, 2015
1 parent e9e01b6 commit 36e529d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions modules/carousel/jetpack-carousel.js
Expand Up @@ -379,12 +379,8 @@ jQuery(document).ready(function($) {
$(window).scrollTop(scroll);
})
.bind('jp_carousel.afterClose', function(){
if ( history.pushState ) {
history.pushState('', document.title, window.location.pathname + window.location.search);
} else {
last_known_location_hash = '';
window.location.hash = '';
}
last_known_location_hash = '';
window.location.hash = '';
gallery.opened = false;
})
.on( 'transitionend.jp-carousel ', '.jp-carousel-slide', function ( e ) {
Expand Down Expand Up @@ -1434,10 +1430,14 @@ jQuery(document).ready(function($) {
matches, attachmentId, galleries, selectedThumbnail;

if ( ! window.location.hash || ! hashRegExp.test( window.location.hash ) ) {
if ( gallery.opened ) {
container.jp_carousel('close');
}

return;
}

if ( window.location.hash === last_known_location_hash ) {
if ( ( window.location.hash === last_known_location_hash ) && gallery.opened ) {
return;
}

Expand Down

0 comments on commit 36e529d

Please sign in to comment.