diff --git a/src/patterns/04-components/image-gallery/_image-gallery.scss b/src/patterns/04-components/image-gallery/_image-gallery.scss index 490d42d45136dd22e49645c5884f814caa1d374d..a50e4edaf277141e6e395cb1745a724368f6bdfc 100644 --- a/src/patterns/04-components/image-gallery/_image-gallery.scss +++ b/src/patterns/04-components/image-gallery/_image-gallery.scss @@ -8,6 +8,16 @@ $size-medium: 4; $size-large: 4; $size-xlarge: 7; .uw-ig { + .uw-button--wrap { + display:none; + margin-top: var(--size-6); + &.active { + display: flex; + } + } + .flickity-page-dots { + bottom: -2rem; + } &--slider { // } @@ -196,6 +206,36 @@ $size-xlarge: 7; } } } + &[data-images-num="1"], + &[data-images-num="2"], + &[data-images-num="3"], + &[data-images-num="4"] { + .uw-ig__item { + margin-left: var(--size-1); + width: 100%; + &:first-child { + margin-left: inherit; + } + } + } + @media(min-width: $screen-md) { + + &[data-images-num="2"] { + .uw-ig__item { + max-width: 45%; + } + } + &[data-images-num="3"] { + .uw-ig__item { + max-width: 32%; + } + } + &[data-images-num="4"] { + .uw-ig__item { + max-width: 24.5%; + } + } + } } // // lightbox diff --git a/src/patterns/04-components/image-gallery/_image-gallery.twig b/src/patterns/04-components/image-gallery/_image-gallery.twig index ffad9cdd01260de76879c2b51c02fde53b00e3f3..c36acebd1a9d1073f88ccec4fda80f417d0558cb 100644 --- a/src/patterns/04-components/image-gallery/_image-gallery.twig +++ b/src/patterns/04-components/image-gallery/_image-gallery.twig @@ -144,4 +144,10 @@ {% endfor %} {% endif %} </div> + {% if type == NULL or type == 'slider' %} + <div class="uw-button--wrap"> + <button class="uw-ig-button--previous"> < Prev</button> + <button class="uw-ig-button--next">Next ></button> + </div> + {% endif %} </div> diff --git a/src/patterns/04-components/image-gallery/image-gallery.js b/src/patterns/04-components/image-gallery/image-gallery.js index 86d2eedb4935968aa06f1d26bfe37f44b8012d61..6b4cbb0c1b7f0f516816dc836f5d981181a135d5 100644 --- a/src/patterns/04-components/image-gallery/image-gallery.js +++ b/src/patterns/04-components/image-gallery/image-gallery.js @@ -19,40 +19,38 @@ var imagesNum = $(this).data('images-num') || 1; var navStyle = $(this).data('nav') || 'both'; - // Create owl carouse config first. - var carousel = { - loop: true, - dots: true, - nav: true, - navContainerClass: 'uw-owl-nav', - navText:[ - 'prev', - 'next' - ], - margin: 10, - responsiveClass: true, - responsive: { - 0: { - items: 1 - }, - 600: { - items: imagesNum - }, - 1000: { - items: imagesNum - } - } + // Create carousel config first. + var flickityOptions = { + cellAlign: 'left', + contain: true, + wrapAround: true, + draggable: false, + groupCells: function () { + var width = $(window).width(); + return width <= 600 ? 1 : imagesNum; + }, + prevNextButtons: false, + pageDots: navStyle === 'pagination' || navStyle === 'both' }; - if (navStyle === 'pagination') { - carousel.nav = false; - } - else if (navStyle === 'navigation') { - carousel.dots = false; + var $carousel = $(id + ' .carousel'); + + if ($carousel.length) { + $carousel.flickity(flickityOptions); } + // previous button + $('.uw-ig-button--previous').on( 'click', function() { + $carousel.flickity('previous'); + }); + // next + $('.uw-ig-button--next').on( 'click', function() { + $carousel.flickity('next'); + }); + - // Add the carousel to the FF using the id. - $(id + ' .owl-carousel').owlCarousel(carousel); + if (navStyle === 'navigation' || navStyle === 'both') { + $('.uw-button--wrap').addClass('active'); + } // Lightbox enchancements $('.uw-lightbox__open').on('click', function () {