繁体   English   中英

drupal的滑块响应代码

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM