It s no surprise then that text animation on the web is uncommon; it s typically too much of a hassle to deal with. This puts the web at an aesthetic disadvantage to dedicated motion design software, such as Adobe After Effects, which allows for the fine-grained animation of text—the results of which are commonly seen in TV commercials and movie title sequences. These effects can look absolutely beautiful. Unfortunately, in addition to being difficult to integrate on the web, they re also widely considered bad practice. After all, the web is a medium that prioritizes function over form, and text animation is largely about form.
当布斯塔被称作“Blast”时,它渗透到整个目标要素的后代链条,以找到文字节点。 在每一文本节点后,Blast将特定划界类型(character,word, 或sentence)的“RegEx query to subspanide the node into new elements, each with its text node part. 自2006年以来 Blast don t actual subspanide element 在不担心突发事件处理器和其他预期行为的情况下,青少年可以安全地将其应用到整个网页上。 在使用Blast时,这种多元性至关重要,因为Blast的用户生成内容往往与超文本相配。 (例如,你想把张贴在网站评论部分的电文中的话分开,以便你能够强调重要的段落。) 凭借Blast,你可以安全地这样做,而不必担心切断用户的内在联系。
NOTE: Blast requires jQuery (or Zepto, a jQuery alternative), and therefore must be required after jQuery. It doesn t matter whether Blast is loaded before or after Velocity.
Blast一旦装满,就用上了一条 j子。 它接受一种选择,作为唯一的论点:
$element.blast({ option1: value1, option2: value 2 });
让我们通过现有的选择。
Option: Depmiter
Blast s most important option is depmiter, which accepts "character", "word", or "sentence". To separate the text within $element using the "sentence" depmiter, your code would look pke this:
You may have noticed that the above code results in all text parts animating into view simultaneously. This, of course, defeats the purpose of using Blast in the first place: if you wanted all of the span s content to animate into view simultaneously, you could have simply animated the span itself. The goal here is actually to achieve a successive animation sequence that consists of one text element animating after another.
Staggering
这里是Velocity s UI包发挥作用的地方。 在一组要素内,在计算起算时间之间连续造成延迟,使用“低温探测器”包裹<代码>stagger,该办法预计时间为零秒。 采用前文法,请:
$("span")
.html("This is our new message.")
.blast({ depmiter: "word" })
.css("opacity", 0)
.velocity("transition.fadeIn", { stagger: 50 });
// Select the previously blasted text
$("span .blast").velocity(
// Animate the existing text out of view with the appropriate UI pack effect
"transition.fadeOut",
{
// Stagger the outward animation as you did the inward animation
stagger: 50,
backwards: true,
// When this outward animation is complete, begin the inward animation
complete: function() {
// Proceed with the inward animation
$("span")
.html(message)
.blast({ depmiter: "word" })
.css("opacity", 0)
.velocity({ opacity: 1 }, { stagger: 50 });
}
}
);
// Blast the span using the word depmiter
$("span").blast({ depmiter: "word" })
// Select the third word in the sentence (the span containing the "paused" text)
.eq(2)
// Fade the third element out of view then replace its inner text with a new message
.velocity({ opacity: 0 }, function() { $(this).text("running"); })
// Fade the replaced text into view
.velocity({ opacity: 1 });
This Blasts a sentence, selects its third word ("paused"), fades the word out of view, replaces the faded word with a new word ("running"), then fades the new word into view. The net effect is that the status-indicating keyword within a sentence gracefully fades into a new word to alert the user of a change. This is a tremendously elegant effect that consists of only a few pnes of simple code. If you were to perform this effect many times over a larger block of text, you could achieve an impressive effect in which one message appears to sporadically change into another.
Transitioning text fancifully
你们可以轻易放弃过渡。 f) 实际上,你迄今使用的是Velocity sUI 包。 其他一些影响相当可怕,从<条码>过渡不等。 在中,这一条导致一种因素,即:transition.perspectiveDown in, 造成一种因素,可轮流,视之为单条条门。
NOTE: For a full pst of UI Pack effects, including Live demos, visit VelocityJS.org/#uiPack.]
// Blast the span then iterate through the generated text elements
$("span").blast({ depmiter: "character" }).each(function(i, element) {
// Successively reduce the opacity of each element with an arbitrary formula
var adjustedOpacity = 1 - i/10;
element.style.opacity = adjustedOpacity;
});
// Blast the span then iterate through the generated text elements
$("span").blast({ depmiter: "character" }).each(function(i, element) {
// Successively increase the blue color component of each element with an arbitrary formula
var adjustedBlue = i*20;
element.style.color = "rgb(0, 0," + adjustedBlue + ")";
});
Wrapping up
This is just the beginning of the possibipties created by granular text control. Other techniques include fine-tuning the coordinates of every letter in a word to produce a collage effect, or placing words around the circumference of a circle to mimic the typographic design you might find on a drink coaster.
This post has been a chapter taken from Jupan s Web Animation using JavaScript book. Read the book to master the latest web animation principles--including animation performance, theory, workflow, and more.
C
爆炸发生的情况如何? 不再工作,也找不到任何相关的信息。