From 6b8cc43213b3a35b865ecace56ee57729238d8e6 Mon Sep 17 00:00:00 2001 From: Rodrigo Ferreira de Souza Date: Mon, 25 Jul 2016 09:08:35 -0300 Subject: [PATCH] Fix to work with --- CHANGES.rst | 3 ++- src/collective/js/cycle2/resources/utils.js | 10 +++++----- src/collective/js/cycle2/resources/utils.min.js | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 05f0dac..610563d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,7 +6,8 @@ There's a frood who really knows where his towel is. 1.0rc1 (unreleased) ------------------- -- Nothing changed yet. +- Use attributes to get image height (fix use with collective.lazysizes). + [rodfersou] 1.0b2 (2016-07-20) diff --git a/src/collective/js/cycle2/resources/utils.js b/src/collective/js/cycle2/resources/utils.js index 0435e93..6aa78d8 100644 --- a/src/collective/js/cycle2/resources/utils.js +++ b/src/collective/js/cycle2/resources/utils.js @@ -43,12 +43,12 @@ }; Cycle2SlideShow.prototype.centerImage = function(img) { if (typeof(img) === 'undefined') { - var img = this.$imgs[0].parentElement; - if ($(img).hasClass('cycle-sentinel')) { - img = this.$imgs[1].parentElement; + var img = this.$imgs[0]; + if ($(img).parent().hasClass('cycle-sentinel')) { + img = this.$imgs[1]; } } - var img_height = $(img).height() + var img_height = parseInt($(img).attr('height')); if (img_height < this.maxHeight) { var margin = parseInt((this.maxHeight - img_height) / 2); $(img).css('margin-top', margin); @@ -60,7 +60,7 @@ }; Cycle2SlideShow.prototype.cycleBefore = function(e, opts, outSlide, inSlide) { e.preventDefault(); - this.centerImage(inSlide); + this.centerImage(inSlide.children[0]); }; Cycle2SlideShow.prototype.thumbsClick = function(e) { e.preventDefault(); diff --git a/src/collective/js/cycle2/resources/utils.min.js b/src/collective/js/cycle2/resources/utils.min.js index 8410f5d..c5a6db4 100644 --- a/src/collective/js/cycle2/resources/utils.min.js +++ b/src/collective/js/cycle2/resources/utils.min.js @@ -1 +1 @@ -(function(window,factory){var cycle2SlideShow=factory(window,window.document);window.cycle2SlideShow=cycle2SlideShow;if(typeof module=="object"&&module.exports){module.exports=cycle2SlideShow}})(window,function l(window,document){"use strict";var Cycle2SlideShow=function(){function Cycle2SlideShow(el){$(el).data("cycle2slideshow",this);this.$player=$(".cycle-player",el);this.$thumbsContainer=$(".cycle-carrossel",el);this.$thumbs=$(".cycle-carrossel .thumb-itens",el);this.$imgs=$(".cycle-player img",el);this.$slideshows=$(".cycle-slideshow",el);this.aspectRatio=parseFloat($(el).attr("data-aspect-ratio"));if(isNaN(this.aspectRatio)){this.aspectRatio=3/2}this.maxWidth=this.$player.width();this.maxHeight=this.maxWidth/this.aspectRatio;this.bindEvents();this.fixImageSize();this.centerImage();$(el).fadeTo("slow",1)}Cycle2SlideShow.prototype.bindEvents=function(){this.$player.on("cycle-next cycle-prev",$.proxy(this.syncSlideshows,this));this.$player.on("cycle-before",$.proxy(this.cycleBefore,this));this.$thumbs.on("click",$.proxy(this.thumbsClick,this))};Cycle2SlideShow.prototype.fixImageSize=function(){this.$player.css({width:this.maxWidth,height:this.maxHeight});this.$imgs.css({"max-width":this.maxWidth,"max-height":this.maxHeight})};Cycle2SlideShow.prototype.centerImage=function(img){if(typeof img==="undefined"){var img=this.$imgs[0].parentElement;if($(img).hasClass("cycle-sentinel")){img=this.$imgs[1].parentElement}}var img_height=$(img).height();if(img_height