[英]slider responsive code for drupal
我正在嘗試使用此代碼使drupal滑塊響應,但是控制台顯示此錯誤“ undefined is not function”。
$(window).resize(function () {
$('.views-slideshow-cycle-main-frame').each(function () {
var heightImgNow = '';
$(this).find('.views-slideshow-cycle-main-frame-row').each(function () {
var thisDisplay = $(this).prop("style").display;
var thisImgHeight = $(this).find('img').height();
if (thisDisplay == 'block') {
heightImgNow = thisImgHeight;
}
});
if (heightImgNow != '') {
// set div height = now image height.
$(this).height(heightImgNow);
}
});
});
我已將代碼放入views_slideshow.js文件中。 現在有人出什么事了嗎?
我在最近的站點上使用了下面的代碼。
$(window).resize(function(){
$('.views_slideshow_cycle_main').each(function(){
var cycleMain = $(this);
var img_width = 0,
img_height = 0;
var clearCSS = {width: "auto", height: "auto"};
var cycle = cycleMain.children('.views-slideshow-cycle-main-frame');
cycleElements = cycle.data("cycle.opts");
cycle.css(clearCSS);
cycleMain.find('.views-slideshow-cycle-main-frame-row').each(function(i){
$(this).css(clearCSS);
var tmp_img_width = $(this).width();
var tmp_img_height = $(this).height();
if(tmp_img_width > img_width)
img_width = tmp_img_width;
if(tmp_img_height > img_height)
img_height = tmp_img_height;
cycleElements.elements[i].cycleW = tmp_img_width;
cycleElements.elements[i].cycleH = tmp_img_height;
$(this).css({width: tmp_img_width, height: tmp_img_height});
});
cycleMain.height(img_height);
cycle.css({width: img_width, height: img_height});
cycle.data("cycle.opts.elements", cycleElements);
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.