资源描述:一个轻量级支持多类型内容的幻灯片插件,支持内容类型:图片、文本、视频或其它HTML内容,可设置自动循环切换。
jquery支持图片文本文字视频的幻灯片特效代码(共9个文件)
使用方法
/**
* home JS - separated because homepages usually use a lot of stuff the rest of the site doesn't need
*/
/* define $ as jQuery just in case */
(function ($) {
/* slideshow - my custom plugin */
$.fn.slideshow = function () {
/* set vars */
var slideshow = this;
var slides = slideshow.find('.slide');
var controls = slideshow.find('.control');
var active_slides = slideshow.find('.slide.active');
var active_slide = active_slides.first().length > 0 ? active_slides.first() : slideshow.find('.slide:eq(0)');
var target_index = active_slide.index();
var target_el = slideshow.find('.slide:eq(' + target_index + ')');
var target_control = slideshow.find('.control:eq(' + target_index + ')');
var slide_speed = 10000;
var timer;
/* hide the slides before showing the active slide */
slideshow.hide();
$(window).load(function () {
/* hide all slides, then show the active one */
slides.removeClass('active').hide();
target_el.addClass('active').show();
/* remove active class from all controls and then add it to the target (active) control */
controls.removeClass('active');
target_control.addClass('active');
/* show the slideshow when everything is set */
slideshow.show();
/* animate the slideshow every XX seconds */
var timer = setInterval(show_next_slide, slide_speed);
});
/* navigator */
slideshow.on('click', '.control', function (e) {
/* reset the timer */
window.clearInterval(timer);
/* set the vars */
var target_index = $(this).index();
var target_slide = slideshow.find('.slide:eq(' + target_index + ')');
/* show the targeted slide */
slides.removeClass('active').hide();
target_slide.show().addClass('active');
/* change the control nav to active */
controls.removeClass('active');
$(this).addClass('active');
e.preventDefault();
});
/* animate slides */
function show_next_slide() {
/* set the vars */
var slides = slideshow.find('.slide');
var curr_slide = slideshow.find('.slide.active');
var curr_index = curr_slide.index();
var next_index = parseInt(curr_index + 1);
if (next_index > slides.length - 1) {
var next_index = 0;
}
var target_el = slideshow.find('.slide:eq(' + next_index + ')');
var target_control = slideshow.find('.control:eq(' + next_index + ')');
/* show the next slide */
slides.hide().removeClass('active');
target_el.show().addClass('active');
/* change the control nav to active */
controls.removeClass('active');
target_control.addClass('active');
}
}
})(jQuery);
站长提示:
1. 苦力吧素材官方QQ群:
950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励
2K币。
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服