Skip to content

Commit

Permalink
Fixed Glightbox integration
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGruson committed Jun 26, 2024
1 parent d549605 commit fc8dd94
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build/multimedia-gallery-image/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "maxgruson/multimedia-gallery-image",
"version": "1.0.6",
"version": "1.0.7",
"title": "Afbeelding",
"category": "media",
"icon": "format-image",
Expand Down
2 changes: 1 addition & 1 deletion build/multimedia-gallery-video/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "maxgruson/multimedia-gallery-video",
"version": "1.0.6",
"version": "1.0.7",
"title": "Video",
"category": "media",
"icon": "format-video",
Expand Down
2 changes: 1 addition & 1 deletion build/multimedia-gallery/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "maxgruson/multimedia-gallery",
"version": "1.0.6",
"version": "1.0.7",
"title": "Multimediagalerij",
"category": "design",
"icon": "format-gallery",
Expand Down
2 changes: 1 addition & 1 deletion build/multimedia-gallery/view.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '72db024aaf2c1cc5b41f');
<?php return array('dependencies' => array(), 'version' => 'c67f42f5199291841a68');
2 changes: 1 addition & 1 deletion build/multimedia-gallery/view.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion multimedia-gallery-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: A block to add a gallery of images and/or YouTube/Vimeo-videos.
* Requires at least: 6.1
* Requires PHP: 7.0
* Version: 1.0.5
* Version: 1.0.7
* Author: <a href="https://max.gruson.studio" target="_blank">Max Gruson</a>
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "multimedia-gallery-block",
"version": "1.0.6",
"version": "1.0.7",
"description": "Een blok om een gallerij van afbeeldingen en/of YouTube/Vimeo-video’s te maken.",
"author": "Max Gruson",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion src/multimedia-gallery-image/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "maxgruson/multimedia-gallery-image",
"version": "1.0.6",
"version": "1.0.7",
"title": "Afbeelding",
"category": "media",
"icon": "format-image",
Expand Down
2 changes: 1 addition & 1 deletion src/multimedia-gallery-video/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "maxgruson/multimedia-gallery-video",
"version": "1.0.6",
"version": "1.0.7",
"title": "Video",
"category": "media",
"icon": "format-video",
Expand Down
2 changes: 1 addition & 1 deletion src/multimedia-gallery/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "maxgruson/multimedia-gallery",
"version": "1.0.6",
"version": "1.0.7",
"title": "Multimediagalerij",
"category": "design",
"icon": "format-gallery",
Expand Down
55 changes: 30 additions & 25 deletions src/multimedia-gallery/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,48 @@ import './view.scss';

document.addEventListener( 'DOMContentLoaded', () => {

// Init lightbox
let i = 1;
document.querySelectorAll( '.wp-block-maxgruson-multimedia-gallery' ).forEach( ( gallery ) => {
gallery.querySelectorAll( '.multimedia-gallery__link' ).forEach( ( link ) => {
link.setAttribute( `data-gallery-${i}`, '' );
} );
GLightbox( {
selector: `data-gallery-${i}`,
loop: true,
} );
i += 1;
// Lazy load images
const galleryImages = document.querySelectorAll( '.wp-block-maxgruson-multimedia-gallery img' );
galleryImages.forEach( el => {
if ( el.complete ) {
el.style.opacity = 1;
} else {
el.addEventListener( 'load', () => {
el.style.opacity = 1;
} );
}
} );

// Init carousel
const splides = document.querySelectorAll( '.splide' );
if(!!splides && splides.length > 0){
splides.forEach(splide => {
new Splide(splide, {
splides.forEach(splideEl => {
const splide = new Splide(splideEl, {
type: 'loop',
// autoplay: true,
perPage: 1,
padding: '4em',
gap: '1em',
heightRatio: 0.5625
} ).mount();
} );

splide.on( 'ready', () => {
// Init lightbox
let i = 1;
document.querySelectorAll( '.wp-block-maxgruson-multimedia-gallery' ).forEach( ( gallery ) => {
gallery.querySelectorAll( '.multimedia-gallery__link' ).forEach( ( link ) => {
link.setAttribute( `data-gallery-${i}`, '' );
} );
GLightbox( {
selector: `data-gallery-${i}`,
loop: true,
} );
i += 1;
} );
} );

splide.mount();
})
}

// Lazy load images
const galleryImages = document.querySelectorAll( '.wp-block-maxgruson-multimedia-gallery img' );
galleryImages.forEach( el => {
if ( el.complete ) {
el.style.opacity = 1;
} else {
el.addEventListener( 'load', () => {
el.style.opacity = 1;
} );
}
} );
} );

0 comments on commit fc8dd94

Please sign in to comment.