2
A
回答
4
检查此:http://wordcrowd.org/index.php?title=Rotating_marquee_with_jQuery_Cycle
jquery的周期插件http://malsup.com/jquery/cycle/
实施例:
<script type="text/javascript">
$(function() {
$('#marquee').cycle({
fx: 'fade',
pause: 1
});
});
</script>
+0
带出插件我们不能做吗? – 2010-07-31 09:48:23
+0
我认为你必须去纯JavaScript – 2010-07-31 09:58:07
3
在这里检查了这一点:http://jsfiddle.net/jithil89/BNBB6/
我有这样的例子,其中所述文本被连续滚动并只在悬停在文字上时才会暂停。
代码:
$(document).ready(function() {
//this is the useful function to scroll a text inside an element...
function startScrolling(scroller_obj, velocity, start_from) {
//bind animation inside the scroller element
scroller_obj.bind('marquee', function (event, c) {
//text to scroll
var ob = $(this);
//scroller width
var sw = parseInt(ob.parent().width());
//text width
var tw = parseInt(ob.width());
//text left position relative to the offset parent
var tl = parseInt(ob.position().left);
//velocity converted to calculate duration
var v = velocity > 0 && velocity < 100 ? (100 - velocity) * 1000 : 5000;
//same velocity for different text's length in relation with duration
var dr = (v * tw/sw) + v;
//is it scrolling from right or left?
switch (start_from) {
case 'right':
//is it the first time?
if (typeof c == 'undefined') {
//if yes, start from the absolute right
ob.css({
left: sw
});
sw = -tw;
} else {
//else calculate destination position
sw = tl - (tw + sw);
};
break;
default:
if (typeof c == 'undefined') {
//start from the absolute left
ob.css({
left: -tw
});
} else {
//else calculate destination position
sw += tl + tw;
};
}
//attach animation to scroller element and start it by a trigger
ob.animate({
left: sw
}, {
duration: dr,
easing: 'linear',
complete: function() {
ob.trigger('marquee');
},
step: function() {
//check if scroller limits are reached
if (start_from == 'right') {
if (parseInt(ob.position().left) < -parseInt(ob.width())) {
//we need to stop and restart animation
ob.stop();
ob.trigger('marquee');
};
} else {
if (parseInt(ob.position().left) > parseInt(ob.parent().width())) {
ob.stop();
ob.trigger('marquee');
};
};
}
});
}).trigger('marquee');
//pause scrolling animation on mouse over
scroller_obj.mouseover(function() {
$(this).stop();
});
//resume scrolling animation on mouse out
scroller_obj.mouseout(function() {
$(this).trigger('marquee', ['resume']);
});
};
//the main app starts here...
//change the cursor type for each scroller
$('.scroller').css("cursor", "pointer");
//settings to pass to function
var scroller = $('.scrollingtext'); // element(s) to scroll
var scrolling_velocity = 80; // 1-99
var scrolling_from = 'right'; // 'right' or 'left'
//call the function and start to scroll..
startScrolling(scroller, scrolling_velocity, scrolling_from);
});
相关问题
- 1. 使用JQuery选择只读文本框
- 2. 使用jQuery连续显示文字
- 3. 使用jQuery连续请求
- 4. 使用jQuery连续点击
- 5. jQuery的连续选择DIV
- 6. 使用jquery获取文本框外的选定文本
- 7. 如何使用jQuery选择所有文本区和文本框?
- 8. jQuery的选择框使选项 - 连接
- 9. jquery禁用使用复选框的文本框(复选框为多个文本框)
- 10. 使用jQuery选择文本
- 11. 复选框值文本框使用jQuery和Greasemonkey的
- 12. 如果选中单选按钮,使用jQuery隐藏文本框
- 13. 当使用jquery取消选中复选框时隐藏文本
- 14. jquery列表框/文本框筛选器
- 15. Jquery - 复选框和多个文本框
- 16. 如何使用本机android连续更改布局背景,如选取框
- 17. 使用jQuery启用禁用文本框
- 18. 选择连续
- 19. 使用jQuery连续移动元素
- 20. 使用jQuery连续检查焦点
- 21. 制作连续幻灯片 - 使用jQuery?
- 22. 使用jquery插入文本框旁边的文本框
- 23. 使用jQuery包含用于文本框
- 24. 无法使用jquery禁用文本框
- 25. 如何使用复选框更改文本框文本模式
- 26. jQuery选择和取消选择文本框文本
- 27. 用户在文本框中选择延续的事件
- 28. jQuery连接选择器和文本
- 29. 如何连续使用SQL Server读取文本文件?
- 30. 使用Jquery在弹出框中选择文本
带回帐篷。真棒。重击一些jquery blink功能;) – 2010-05-26 12:22:15
这是超过90年代。你确定可以说服'他们'吗? – karim79 2010-05-26 12:23:03