From de7d43f46a2430c7b2d8de70d4907e0afed34779 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 5 Nov 2015 19:02:38 -0500 Subject: using flickity gallery --- StoneIsland/www/css/products.css | 18 +++++++++--------- StoneIsland/www/index.html | 14 +++++--------- StoneIsland/www/js/lib/products/GalleryView.js | 26 ++++++++++++++++++-------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/StoneIsland/www/css/products.css b/StoneIsland/www/css/products.css index 0a615c34..9ded00d1 100644 --- a/StoneIsland/www/css/products.css +++ b/StoneIsland/www/css/products.css @@ -21,15 +21,15 @@ display: none; } -#gallery, -#gallery .slider, -#gallery .slider .item { +#gallery { + width: 100vw; + height: 63vw; } -#gallery .slider .item { - float: left; - width: 10vw; -} -#gallery .slider .item img { - max-width: 10vw; +#gallery .item { + width: 100vw; + height: 63vw; + background-size: contain; + background-position: center center; + background-repeat: no-repeat; } diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html index 4706fe18..06f4335f 100644 --- a/StoneIsland/www/index.html +++ b/StoneIsland/www/index.html @@ -18,6 +18,7 @@ + @@ -145,15 +146,9 @@

@@ -347,6 +342,7 @@ + diff --git a/StoneIsland/www/js/lib/products/GalleryView.js b/StoneIsland/www/js/lib/products/GalleryView.js index 44eed9f0..a139c454 100644 --- a/StoneIsland/www/js/lib/products/GalleryView.js +++ b/StoneIsland/www/js/lib/products/GalleryView.js @@ -6,15 +6,13 @@ var GalleryView = View.extend({ events: { "click .left": "prev", "click .right": "next", - "touchstart .gallery": "touchstart", - "touchmove .gallery": "touchmove", - "touchend .gallery": "touchend", +// "touchstart .gallery": "touchstart", +// "touchmove .gallery": "touchmove", +// "touchend .gallery": "touchend", }, initialize: function(){ - this.$prev = this.$(".prev") - this.$next = this.$(".next") - this.$slider = this.$(".slider") + this.$(".template").remove() }, populate: function(code, image_ids){ @@ -31,9 +29,21 @@ var GalleryView = View.extend({ Object.keys(valid_styles).forEach(function(style){ var id = valid_styles[style] + "_" + style var t = this.template.replace(/{{image}}/, sdk.image(code, id)) - .replace(/{{id}}/, sdk.image(code, id)) - this.$slider.append(t) + this.$el.append(t) }.bind(this)) + + this.gallery = new Flickity( "#gallery", { + selector: '.item', + cellAlign: 'center', + autoPlay: false, + freeScroll: false, + wrapAround: true, + imagesLoaded: true, + prevNextButtons: false, + pageDots: false, + contain: true, + draggable: true, + }) }, prev: function(){ -- cgit v1.2.3-70-g09d2