Skip to content
Snippets Groups Projects
Commit b45a6511 authored by Martin Leblanc's avatar Martin Leblanc Committed by Kevin Paxman
Browse files

ISTWCMS-5650: Add specificity for buttons, add hidden nav state when imagesNum match dots

parent 09369aff
No related branches found
No related tags found
No related merge requests found
...@@ -14,8 +14,14 @@ $size-xlarge: 7; ...@@ -14,8 +14,14 @@ $size-xlarge: 7;
&.active { &.active {
display: flex; display: flex;
} }
&.hide {
display: none;
}
} }
.flickity-page-dots { .flickity-page-dots {
&.hide {
display: none;
}
bottom: -2rem; bottom: -2rem;
.dot { .dot {
height: var(--size-2); height: var(--size-2);
...@@ -239,7 +245,7 @@ $size-xlarge: 7; ...@@ -239,7 +245,7 @@ $size-xlarge: 7;
} }
&[data-images-num="3"] { &[data-images-num="3"] {
.uw-ig__item { .uw-ig__item {
max-width: 32%; max-width: 32.5%;
} }
} }
&[data-images-num="4"] { &[data-images-num="4"] {
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
Drupal.behaviors.imagegallery = { Drupal.behaviors.imagegallery = {
attach: function () { attach: function () {
// Ensure code runs after the DOM is fully loaded. // Ensure code runs after the DOM is fully loaded.
$(document).ready(function () { $(document).ready(function () {
...@@ -30,6 +29,7 @@ ...@@ -30,6 +29,7 @@
contain: true, contain: true,
wrapAround: true, wrapAround: true,
draggable: false, draggable: false,
imagesLoaded: true,
groupCells: function () { groupCells: function () {
// Adjust the number of visible images based on screen width. // Adjust the number of visible images based on screen width.
var width = $(window).width(); var width = $(window).width();
...@@ -51,8 +51,13 @@ ...@@ -51,8 +51,13 @@
var flkty = $carousel.data('flickity'); var flkty = $carousel.data('flickity');
// Handle keyboard navigation for Flickity pagination dots. // Handle keyboard navigation for Flickity pagination dots.
var dots = document.querySelectorAll('.uw-ig .flickity-page-dots .dot'); var dots = $carousel.find('.flickity-page-dots .dot').toArray();
// Hide the button wrapper if the number of dots equals imagesNum
if (dots.length === imagesNum) {
$(this).find('.uw-button--wrap').addClass('hide');
$(this).find('.flickity-page-dots').addClass('hide');
}
if (!dots.length) { if (!dots.length) {
return; return;
} }
...@@ -82,11 +87,13 @@ ...@@ -82,11 +87,13 @@
// Previous button event listener. // Previous button event listener.
$('.uw-ig-button--previous').on('click', function () { $('.uw-ig-button--previous').on('click', function () {
var $carousel = $(this).closest('.uw-ig').find('.carousel');
$carousel.flickity('previous'); $carousel.flickity('previous');
}); });
// Next button event listener. // Next button event listener.
$('.uw-ig-button--next').on('click', function () { $('.uw-ig-button--next').on('click', function () {
var $carousel = $(this).closest('.uw-ig').find('.carousel');
$carousel.flickity('next'); $carousel.flickity('next');
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment