Jquery and CSS3 Rotation
Jquery and CSS3 Rotation
我真的需要一些帮助!我正在尝试使用jquery和CSS3创建旋转滚动条效果。我想按顺序运行以下程序,每个程序之间都有延迟:
Javascript:
$('#scroll-script')
.removeClass().addClass('slide-one')
DELAY
.removeClass().addClass('slide-two')
DELAY
.removeClass().addClass('slide-three')
DELAY
.removeClass().addClass('slide-four')
DELAY
HTML:
<div id="scroll-script" class="slide-one"></div>
刚开始使用Jquery,任何帮助都将不胜感激!
一次:
var i = 0;
delay = 1000;
var el = $('#scroll-script');
var classes = ['slide-one', 'slide-two', 'slide-three', 'slide-four'];
var interval = setInterval(function () {
el.removeClass().addClass(classes[i]);
i += 1;
if (i >= classes.length) clearInterval(interval);
}, delay);
圆圈内:
var i = 0;
delay = 1000;
var el = $('#scroll-script');
var classes = ['slide-one', 'slide-two', 'slide-three', 'slide-four'];
var interval = setInterval(function () {
el.removeClass().addClass(classes[i]);
i = (i + 1) % 4;
}, delay);
您可以使用.animate
。。这些链接将帮助你!
http://tympanus.net/codrops/2011/04/28/rotating-image-slider/
//wrap in a function to provide closure on following vars
//this will prevent them from being in the global scope and
//potentially colliding with other vars
(function () {
var sub = 0,
delay = 500, //500 ms = 1/2 a second
scrollScript = $('#scroll-script'),
slides = ['one', 'two', 'three', 'four'],
handle;
//calls the provided anonymous function at the interval delay
handle = setInterval(function () {
scrollScript.removeClass().addClass('slide-' + slides[sub]);
sub += 1;
// test to see if there is another class in the sequence of classes
if (!slides[sub]) {
//if not halt timed callback
clearInterval(handle);
}
}, delay);
}());
使其循环:
//wrap in a function to provide closure on following vars
//this will prevent them from being in the global scope and
//potentially colliding with other vars
(function () {
var sub = 0,
delay = 500, //500 ms = 1/2 a second
scrollScript = $('#scroll-script'),
slides = ['one', 'two', 'three', 'four'],
handle;
//calls the provided anonymous function at the interval delay
handle = setInterval(function () {
scrollScript.removeClass().addClass('slide-' + slides[sub % slides.length]);
sub += 1;
}, delay);
}());
相关文章:
- Three.js Points Rotation
- 关键帧之间的css3动画延迟
- 尝试创建一个具有z-index的堆叠菜单'使用HTML5/CSS3/JS
- 计算CSS3缩放框在另一个框中的最高位置
- 打开相对于鼠标位置的CSS3/HTML5模式对话框
- 下降区内的CSS3过渡
- 访问css3动画的关键帧
- CSS3:当页面向下滚动到第一个视口时,是否可以在元素上触发转换
- css3转换和javascript出错
- CSS3动画图像质量按比例
- CSS3卡翻转动画,检测是否不支持
- HTML5、CSS3和/或JS中旋转CD上的音频播放器
- jQuery鼠标输出调用CSS3动画
- 使用带有onclick事件的Javascript启动CSS3动画
- Jquery and CSS3 Rotation
- 仅限滑动图像css3或需要javascript
- 如何在不使用css转换的情况下将jQuery animate与css3属性相结合
- DIV不会与实验性CSS3菜单一起定位
- JavaScript应用CSS3渐变
- 如何在 css3 中创建活动按钮