[英]slider responsive code for drupal
I'm trying to us this code to make drupal slider responsive, but console showes this error "undefined is not a function " . 我正在尝试使用此代码使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);
}
});
});
I have put the code in the views_slideshow.js file. 我已将代码放入views_slideshow.js文件中。 Does anybody now what's wrong? 现在有人出什么事了吗?
I used the code bellow on a recent site. 我在最近的站点上使用了下面的代码。
$(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.