You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi There, we're big fans of your work. Also, let me say we can't use cycle2 at all for responsiveness - we have too many deployments of cycle in production.
We're able to tweak cycle and make it responsive fairly easily. but for that, we're resorting to a hack we don't like: accessing cycle internal DOM data cycleH and cycleW:
We know by reading the code that we could also set them to 0, but in that case, the end result might not be responsive.
It would be great if you could add a function to reset the cycleH and cycleW to values we pass, or default to recomputing dimensions.
Looking at the code base, this would be a small new function.
Here's our full example:
html looks like this:
<divclass="slideshow"><divclass="slide"><imgsrc=".." width="100%" height="auto"/></div><divclass="slide"><p>Copy copy copy no photo on slide </p></div><divclass="slide"><imgsrc=".." width="100%" height="auto"/></div><divclass="slide"><p>Copy copy copy no photo on slide </p></div>
...
</div>
on window resize function: (snippet):
$(window).resize(function(){// first time around, save original width & height for ratios and complicated preloading$(".slideshow").each(function(i,elt){varoriginalWidth=$(elt).attr("originalWidth");// check existence of our ratio cacheif(typeoforiginalWidth=="undefined"){varcontainerWidth=$(elt).parent().first().width();// auto scale to container width.varcontainerHeight=$(elt).parent().first().height();$(elt).attr("originalWidth",containerWidth);$(elt).attr("originalHeight",containerHeight);}});// fix slideshows to their container width$(".slideshow").each(function(i,elt){varcontainerWidth=$(elt).parent().first().width();varoriginalWidth=$(elt).attr("originalWidth")*1;varoriginalHeight=$(elt).attr("originalHeight")*1;varheight=Math.floor(originalHeight*containerWidth/originalWidth);// maintain original ratio$(elt).css("width",containerWidth+"px").css("height",height+"px");// container actual dimensions$(elt).children("div").css("width",containerWidth+"px");// reset each slide width // (fails once slides move, because the cycle plugin will auto compute based on the panel in it.$(elt).children("div").children().css("width",containerWidth+"px");// fix direct children (images or divs - images should have height auto).// recompute max height based on inside slide, not just photos.// some slideshows have variable height slides.varmaxHeight=0;varpanelArray=$(elt).children("div");for(vari=0;i<panelArray.length;i++){varheight=$(panelArray[i]).height();if(height>maxHeight)maxHeight=height;}if(maxHeight>0){$(elt).height(maxHeight);}// fix internal cycle dimension cache (cycleW and cycleH on each slide)$(elt).children("div").each(function(){this.cycleW=containerWidth;this.cycleH=maxHeight;});});});
Thank you so much for considering this small new function
The text was updated successfully, but these errors were encountered:
Hi There, we're big fans of your work. Also, let me say we can't use cycle2 at all for responsiveness - we have too many deployments of cycle in production.
We're able to tweak cycle and make it responsive fairly easily. but for that, we're resorting to a hack we don't like: accessing cycle internal DOM data cycleH and cycleW:
We know by reading the code that we could also set them to 0, but in that case, the end result might not be responsive.
It would be great if you could add a function to reset the cycleH and cycleW to values we pass, or default to recomputing dimensions.
Looking at the code base, this would be a small new function.
Here's our full example:
html looks like this:
on window resize function: (snippet):
Thank you so much for considering this small new function
The text was updated successfully, but these errors were encountered: