Skip to content

Instantly share code, notes, and snippets.

@Crocoblock
Last active January 21, 2025 18:07
Show Gist options
  • Save Crocoblock/6db7f99e8a9353183aecb8409348cecd to your computer and use it in GitHub Desktop.
Save Crocoblock/6db7f99e8a9353183aecb8409348cecd to your computer and use it in GitHub Desktop.
JetPopup Scroll JetEngine Listing Grid slider to a corresponding slide on opening popup
<script>
jQuery( document ).ready( function( $ ){
$( window ).on( 'jet-popup-open-trigger', function( event ) {
let id = event?.popupData?.postId;
if ( ! id ) {
return;
}
let slider = $( `#${event.popupData.popupId} .jet-popup__inner .gallery-list .jet-listing-grid__items.slick-initialized` );
if ( ! slider.length ) {
return;
}
let slide = slider.find( `[data-post-id='${id}']` );
if ( ! slide?.length ) {
return;
}
let index = slide[0]?.dataset?.slickIndex;
if ( ! index ) {
return;
}
slider.slick( 'slickGoTo', `${index}` );
} );
} );
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment