【发布时间】:2014-06-17 12:19:35
【问题描述】:
试图循环一个函数。
这是一个简单的文字动画 - 文字会
1.逐个字母淡入左侧
2.逐个字母淡出。
3.这将重复,但文本将再次出现在另一个随机位置 页面。
当我将间隔延迟设置为 1000 时,文本总共出现 4 次,每次间隔 1 秒。第一次,文字向左淡入,第二次和第三次文字整体闪烁,最后,逐个字母淡出。
所以,我将延迟设置为 4700。动画按预期工作,但没有循环播放。
textillate 中的回调函数也不起作用,所以我选择了 setInterval。
HTML:
<span class="brand">
<h1>
<ul class="texts">
<li>E L Y S I U M</li>
<li></li>
</ul>
</h1>
</span>
JS:
$(window).bind("load", function () {
function ShowBrand() {
var docHeight = $(document).height();
var docWidth = $(document).width();
$newSpan = $(".brand");
spanHeight = $newSpan.height();
spanWidth = $newSpan.width();
maxHeight = docHeight - spanHeight;
maxWidth = docWidth - spanWidth;
$newSpan.show().css({
top: Math.floor(Math.random() * maxHeight),
left: Math.floor(Math.random() * maxWidth)
}).textillate({
in: {effect:'fadeInLeft'},
out: {effect:'fadeOutUp'}
});
}
setInterval(ShowBrand,4700);
});
【问题讨论】:
标签: javascript jquery jquery-plugins