पुरानी पोस्ट, मुझे पता है।
हम इसे चक्र के साथ उत्पादन में काम कर रहे हैं। Cycle2 नहीं था और अभी भी हमारे लिए एक विकल्प नहीं है। दुर्भाग्यवश, इसमें चक्र के आंतरिक डेटा को संशोधित करना शामिल है। सौभाग्य से, फिक्स सीधा है।
जब चक्र प्लगइन initializes, यह दो propeties cycleW और cycleH क्रमशः प्रारंभिक चौड़ाई और प्रत्येक स्लाइड की ऊंचाई के साथ अपनी स्लाइड्स 'डोम वस्तु से प्रत्येक के लिए कहते हैं। खिड़की के आयाम के बावजूद चक्र प्रत्येक स्लाइड को एनिमेट करने के लिए इन गुणों का उपयोग करता है।
जब विंडो का आकार बदलता है, तो आपको मैन्युअल रूप से cycleW और cycleH को साफ़ करने या उन्हें पूर्व निर्धारित मान पर सेट करने की आवश्यकता होती है।
उदाहरण (अपने स्लाइड शो कंटेनर संभालने है .slideshow):
$(".slideshow").children("div").each(function(){
this.cycleW = $(this).width();
this.cycleH = $(this).height();
});
हम यह उत्पादन में बहुत अच्छी तरह से काम कर रहा है।
एचटीएमएल इस तरह दिखता है:
<div class="slideshow">
<div class="slide"><img src=".." width="100%" height="auto"/></div>
<div class="slide"><p>Copy copy copy no photo on slide </p></div>
<div class="slide"><img src=".." width="100%" height="auto"/></div>
<div class="slide"><p>Copy copy copy no photo on slide </p></div>
...
</div>
अब विंडो आकार परिवर्तन कार्य करते हैं। यह हमारा संस्करण है। आपको अपनी आवश्यकताओं के अनुरूप इसे अनुकूलित करने की आवश्यकता हो सकती है। असल में, हम स्लाइड शो में छवियों को निर्धारित करने वाले मामलों के लिए प्रारंभिक अनुपात संग्रहीत करते हैं। कई बार हमारे पास परिवर्तनीय ऊंचाई स्लाइडशो होती है। यह कोड दोनों परिस्थितियों को संबोधित करता है। फिर, यह प्रत्येक स्लाइड DOM तत्व का आंतरिक cycleW और cycleH मूल्यों को रीसेट करता है अपने माता पिता के कंटेनर
$(window).resize(function(){
// first time around, save original width & height for ratios and complicated preloading
$(".slideshow").each(function(i,elt){
var originalWidth = $(elt).data("originalWidth"); // check existence of our ratio cache
if (typeof originalWidth == "undefined") {
var containerWidth = $(elt).parent().first().width(); // auto scale to container width.
var containerHeight = $(elt).parent().first().height();
$(elt).data("originalWidth",containerWidth);
$(elt).data("originalHeight",containerHeight);
}
});
// fix slideshows to their container width
$(".slideshow").each(function(i,elt){
var containerWidth = $(elt).parent().first().width();
var originalWidth = $(elt).data("originalWidth")*1;
var originalHeight = $(elt).data("originalHeight")*1;
var height = Math.floor(originalHeight*containerWidth/originalWidth); // maintain original ratio
$(elt).css("width", containerWidth+"px").css("height",height+"px"); // container actual dimensions. height might get reset again below
$(elt).children("div").css("width", containerWidth+"px"); // reset each slide width
// (fails once slide moves out, because the cycle plugin will use a cached value)
$(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.
var maxHeight = 0;
var panelArray = $(elt).children("div");
for (var i = 0; i < panelArray.length; i++) {
var height = $(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;
});
});
});
मैं सच करने के लिए containerResize संपत्ति बदल गया है और फिर इसे काम फिट करने के लिए है, लेकिन फिर यह उत्तरदायी anymore..maybe यह मदद करता है नहीं है। – Boyye
नहीं, यह उत्तरदायी होने की जरूरत है! धन्यवाद – Blowsie
सुनिश्चित नहीं है कि आप तकनीक के दूसरे टुकड़े के लिए खुले हैं, लेकिन मुझे प्यार है और [विल्टो के डायनामिक कैरोसेल] का उपयोग करें (https://github.com/Wilto/Dynamic-Carousel)। –