Flexisel

jQuery响应式轮播插件...(A responsive carousel jQuery plugin...)

Github星跟踪图

jQuery响应式轮播插件。所有你需要做的是调用flexisel在您的无序列表中包含的图像。 在 $(window).load 事件(而不是 $(document).ready 事件)上调用它,以便Flexisel可以计算图像的宽度,并找出如何正确地将它们播放出来。 例如...

$(window).load(function() {  $("#myCarousel").flexisel();});


下面是如何调用它传递所有的选项....

$(window).load(function() {
$("#myCarousel").flexisel({ visibleItems: 4, itemsToScroll: 3, animationSpeed: 400, infinite: true, navigationTargetSelector: null, autoPlay: { enable: false, interval: 5000, pauseOnHover: true }, responsiveBreakpoints: { portrait: { changePoint:480, visibleItems: 1, itemsToScroll: 1 }, landscape: { changePoint:640, visibleItems: 2, itemsToScroll: 2 }, tablet: { changePoint:768, visibleItems: 3, itemsToScroll: 3 } } });});

概览

名称与所有者9bitStudios/flexisel
主编程语言JavaScript
编程语言CSS (语言数: 3)
平台
许可证
发布数5
最新版本名称v2.2.2 (发布于 )
第一版名称v2.0.0 (发布于 )
创建于2013-03-04 15:15:49
推送于2023-07-08 14:44:47
最后一次提交2023-07-08 07:44:47
星数379
关注者数33
派生数168
提交数59
已启用问题?
问题数73
打开的问题数4
拉请求数6
打开的拉请求数0
关闭的拉请求数5
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?

Flexisel

A responsive carousel jQuery plugin...

View Demo, Buy Author a Coffee

All you have to do is call flexisel on your unordered list containing images. Call it on the $(window).load event (as opposed to the $(document).ready event) so that Flexisel can calculate the width of the images and figure out how to space them out properly. For example...

$(window).load(function() {
  $("#myCarousel").flexisel();
});

Below is how you'd call it passing in all the options....

$(window).load(function() {
  $("#myCarousel").flexisel({
    visibleItems: 4,
    itemsToScroll: 3,
    animationSpeed: 400,
    infinite: true,
    navigationTargetSelector: null,
    autoPlay: {
      enable: false,
      interval: 5000,
      pauseOnHover: true
    },
    responsiveBreakpoints: { 
      portrait: { 
        changePoint:480,
        visibleItems: 1,
        itemsToScroll: 1
      }, 
        landscape: { 
        changePoint:640,
        visibleItems: 2,
        itemsToScroll: 2
      },
        tablet: { 
        changePoint:768,
        visibleItems: 3,
        itemsToScroll: 3
      }
    }
  });
});

Options

Below is a listing of some basic options you can set..., Option, Value, Default Value, Description, Example, ---, ---, ---, ---, ---, visibleItems, Integer, 4, Sets the initial number of visible items in the carousel, visibleItems: 5
itemsToScroll, Integer, 3, Sets the initial number of items that you want to scroll. Note: This value will be overridden by responsive breakpoint settings at smaller or larger screen widths, itemsToScroll: 2
animationSpeed, Integer (in Milliseconds), 400, Sets the "speed" of the animation when the carousel navigates right or left., animationSpeed: 1000
infinite, Boolean, true, Sets whether or not the carousel wraps infinitely, infinite: false
navigationTargetSelector, String (selector), null, The left/right arrows will be added to the element with this selector instead of the default, navigationTargetSelector: '#navigation'
autoPlay, Object, autoPlay: { enable: false, interval: 5000, pauseOnHover: true }, Values for setting autoplay. The "enable" property must be true for this to apply, autoPlay: { enable: true, interval: 7000, pauseOnHover: false }
loaded, function, function(object) { }, Callback function that runs after the slider is loaded and initialized. A jQuery reference to the instance of the carousel is passed in as the first argument., loaded: function(object) { console.log('Slider loaded...'); }
before, function, function(object) { }, Callback function that runs before a slide transition. A jQuery reference to the instance of the carousel is passed in as the first argument., before: function(object) { console.log('Before transition...'); }
after, function, function(object) { }, Callback function that runs after a slide transition. A jQuery reference to the instance of the carousel is passed in as the first argument., after: function(object) { console.log('After transition...'); }
resize, function, function(object) { }, Callback function that runs after a throttled resize event finishes. A jQuery reference to the instance of the carousel is passed in as the first argument., resize: function(object) { console.log('After resize...'); }

Responsive Breakpoints

This is an object that specifies responsive breakpoints. You can name your objects whatever you want (the default names provided are "portrait," "landscape," and "tablet") and you can have as many or as few as you want (so you could add to or delete any of the defaults), but each one needs to have a "changePoint" a "visibleItems", and an "itemsToScroll" property. Those properties are required. The responsiveBreakpoints object sets the threshold of where the screen width falls below a certain width. So for example, the example default portrait responsive breakpoint will be applied to the carousel when the screen width is less than the changePoint value set for portrait. The number of items shown in this state will be whatever value is set for visibleItems and the number of items that scroll per click (or swipe) is set by the itemsToScroll property.

For example...

responsiveBreakpoints: { 
  portrait: { 
    changePoint:480,
    visibleItems: 1,
    itemsToScroll: 1
  }, 
  landscape: { 
    changePoint:640,
    visibleItems: 2,
    itemsToScroll: 2
  },
  tablet: { 
    changePoint:768,
    visibleItems: 3,
    itemsToScroll: 3
  }
}

The landscape responsive breakpoint will be applied when the screen width is greater than the width of the portrait changePoint value, but less that the width of the tablet changePoint value. Likewise, when the screen width falls below the tablet changePoint, the number of visibleItems set for the tablet event will be shown. The same is true for the portrait breakpoint. Usually, because the portrait responsive event is used to show portrait views on mobile phones, 1 is a good value to set for both visibleItems and itemsToScroll here. And remember you can pass as many or as few of these as you like in and you can name them whatever you want. So, for example, if you wanted to just have things only show 1 item on all views below a certain width you could pass in something like the following...

 responsiveBreakpoints: {
    mobile: {
      changePoint:768,
      visibleItems: 1,
      itemsToScroll: 1
    }
}

And then this will be the only point at which Flexisel changes.

View Demo, Buy Author a Coffee

去到顶部