jQuery Orbit-如何制作随机幻灯片
jQuery Orbit - How to make a Random Slideshow?
我为我的网站找到了一个很酷的幻灯片。
加载页面时,第一张图片将显示在幻灯片中。
我希望幻灯片在页面加载时随机显示一些图片。
Javascript代码:
(function($) {
$.fn.orbit = function(options) {
var defaults = {
animation: 'fade',
animationSpeed: 800,
timer: false,
advanceSpeed: 4000,
pauseOnHover: false,
startClockOnMouseOut: false,
startClockOnMouseOutAfter: 1000,
directionalNav: true,
captions: true,
captionAnimation: 'fade',
captionAnimationSpeed: 800,
bullets: false,
bulletThumbs: false,
bulletThumbLocation: '',
afterSlideChange: function(){}
};
有什么想法吗?
so;开放源代码ORBIT对象设置添加随机默认值false:
defaults: {
animation: 'horizontal-push',
animationSpeed: 600, // how fast animtions are
timer: true, // true or false to have the timer
advanceSpeed: 4000, // if timer is enabled, time between transitions
pauseOnHover: false, // if you hover pauses the slider
startClockOnMouseOut: false, // if clock should start on MouseOut
startClockOnMouseOutAfter: 1000,
directionalNav: true, // manual advancing directional navs
captions: true, // do you want captions?
captionAnimation: 'fade', // fade, slideOpen, none
captionAnimationSpeed: 600, // if so how quickly should they animate in
bullets: false,
bulletThumbs: false, // thumbnails for the bullets
bulletThumbLocation: '', // location from this file where thumbs will be
afterSlideChange: $.noop, // empty function
fluid: false,
centerBullets: true,
/////////////////////////// add Line
random: false, // or true
////////////////////////////
},
在ORBIT对象{loaded}方法添加到if(options.rrandom)之后,random:
loaded: function () {
this.$element
.addClass('orbit')
.css({width: '1px', height: '1px'});
this.setDimentionsFromLargestSlide();
this.updateOptionsIfOnlyOneSlide();
this.setupFirstSlide();
if (this.options.timer) {
this.setupTimer();
this.startClock();
}
if (this.options.captions) {
this.setupCaptions();
}
if (this.options.directionalNav) {
this.setupDirectionalNav();
}
if (this.options.bullets) {
this.setupBulletNav();
this.setActiveBullet();
}
//////////////////////////////// add Line
if (this.options.random)
this.shift(this.Random.__init__());
/////////////////////////////////////
},
之后;添加ORBIT对象新方法{Random}
Random: {
__init__: function() {
return this.math();
},
math: function() {
var bullets_count = (jQuery(".orbit-bullets li").length -1);
return (Math.floor(Math.random() * (bullets_count - 0 + 1)));
}
},
别紧张。。
相关文章:
- jQuery Orbit-如何制作随机幻灯片
- jQuery幻灯片 - 想要随机,但需要从相同的图像开始
- 引导程序3转盘-随机选择下一张幻灯片
- 带有两个带过渡的图像的随机幻灯片
- 使用javascript的随机幻灯片放映
- 具有随机起点的jQuery幻灯片
- JQuery 幻灯片错误.图片在页面上列出,而不是随机播放.找不到错误
- 如何让我的 javascript 函数随机选择一个函数(幻灯片),执行它,然后重复
- 如何根据随机幻灯片编号显示幻灯片
- 如何为jssor滑块随机选择几张幻灯片并隐藏其余幻灯片
- Javascript幻灯片与随机的第一张图片
- 随机图像顺序幻灯片
- 在reveal.js中随机化幻灯片
- 是否可以使此代码随机化幻灯片的图像?
- Javascript幻灯片以随机顺序显示
- 只是一个简单的问题??关于随机化这个幻灯片
- 随机幻灯片在Wordpress主题,JS
- JavaScript幻灯片显示,改变幻灯片每3秒,并开始在一个随机的图像
- 随机化幻灯片上的第一张图片
- 带有随机图片的幻灯片