弹性滑块-我想计数旋转木马最小值&调整浏览器大小时的最大项目数

Flex slider - I want to count Carousel Min & Max Items when resize browser

本文关键字:浏览器 调整 amp 小时 项目数 最小值 旋转木马      更新时间:2023-11-18

调整浏览器大小时;然后在刷新页面之后。所以计数旋转木马Min&最大项目数。但是当不计数旋转木马Min&不刷新页面的最大项目数。

我要数旋转木马Min&调整浏览器大小时的最大项目数。

查看我们的网站(我在特色商品中使用了旋转木马柔性滑块):http://demo.harnishdesign.net/opencart/polishop/

如何修复?

(function() {
// store the slider in a local variable
var $window = $(window),
flexslider;
// tiny helper function to add breakpoints
function getGridSize() {
return (window.innerWidth < 320) ? 1 :
(window.innerWidth < 600) ? 2 :
(window.innerWidth < 800) ? 3 :
(window.innerWidth < 900) ? 4 : 5;
}
$window.load(function() {
$('#content .featured_carousel').flexslider({
animation: "slide",
animationLoop: false,
slideshow: false,
itemWidth: 210,
minItems: getGridSize(), // use function to pull in initial value
maxItems: getGridSize() // use function to pull in initial value
});
});
}());

我也遇到了同样的问题。尝试代码修复它。

(function() {
  // store the slider in a local variable
  var $window = $(window);
  var flexslider;
  // tiny helper function to add breakpoints
  function getGridSize() {
    return (window.innerWidth < 320) ? 1 :
      (window.innerWidth < 600) ? 2 :
      (window.innerWidth < 800) ? 3 :
      (window.innerWidth < 900) ? 4 : 5;
  }
  $window.load(function() {
    $('#content .featured_carousel').flexslider({
      animation: "slide",
      animationLoop: false,
      slideshow: false,
      itemWidth: 210,
      minItems: getGridSize(), // use function to pull in initial value
      maxItems: getGridSize(), // use function to pull in initial value
      start: function(slider) {
        flexslider = slider;
      }
    });
  });
  $window.resize(function() {
    var gridSize = getGridSize();
    flexslider.vars.minItems = gridSize;
    flexslider.vars.maxItems = gridSize;
  });
}());

尝试类似的东西

(function() {
  // store the slider in a local variable
  var $window = $(window),
      flexslider;
  // tiny helper function to add breakpoints
  function getGridSize() {
    return (window.innerWidth < 600) ? 2 :
           (window.innerWidth < 900) ? 3 : 4;
  }
  $(function() {
    SyntaxHighlighter.all();
  });
  $window.load(function() {
    $('.flexslider').flexslider({
      animation: "slide",
      animationLoop: false,
      itemWidth: 210,
      itemMargin: 5,
      minItems: getGridSize(), // use function to pull in initial value
      maxItems: getGridSize() // use function to pull in initial value
    });
  });
  // check grid size on resize event
  $window.resize(function() {
    var gridSize = getGridSize();
    flexslider.vars.minItems = gridSize;
    flexslider.vars.maxItems = gridSize;
  });
}());