How to simply use YUI to create JavaScript animation_YUI.Ext related
原文地址:http://www.jackslocum.com/blog/2006/08/24/javascript-animations-with-yahoo-ui-made-easy/
YUI的动画类简直就是一门艺术工作。不像其它的传统的JS库,提供了已经“预设好”的直接可运行的效果,相反,它由开发者做自己喜欢的。在这点,我比较喜欢适当地运行一些动画和变换效果,越多越好。
按照这么地说,也会有个问题。动画API是非常“底层”的工作,而且需要您花时间去弄的,子类的构建函数会又长又啰嗦的。因此,在上一发布的版本中, 我把 YAHOO.ext.Element的动画效果尽量简单地调用。其实,在这个网站的大多数效果都是它完成的。但如果我想做些较复杂的效果,该怎么办?当某个效果完成后,YUI能够以函数的方式提供一个回调(callback).利用Callback你能够将多个效果排队来做出复杂的效果。唯一的问题是,在其函数内,每一步效果的封装好的,这样,代码起来就很复杂可怕了。另外一个问题是,当你同一时内多个元素发生动画效果的话,代码会持续地随着每个元素它拥有的回调函数的增长而增长。不得不说,YahooUI!在这方面,有点难以适用于开发,--尤其日渐常用这类效果。
新版的yui.ext包含了原本yui做动画所需的复杂代码,甚至比你想的要简单。这里是功能列表:
*自动调整动画顺序 --回调函数不再有啦!
*动画列表(一组的动画效果)可按需预定义和执行
var exdiv = new YAHOO.ext.Actor('example', null, true);
exdiv.moveIn('top');
exdiv.play();
var anim = new YAHOO.ext.Animator(this.minbar, this.dockbar); <br>anim.startCapture();
this.dockbar.setX(-this.dockedWidth); <br>this.dockbar.setWidth(this.dockedWidth); <br>this.dockbar.setVisible(true);
anim.beginSync(); <br>this.minbar.move('left', this.minbar.getWidth()+this.margin, true, .35); <br>this.dockbar.move('right', this.dockedWidth+this.margin, true, .4, null, YAHOO.util.Easing.easeOut); <br>anim.endSync();
anim.play(this.fireDocked);
<font face="Arial">var animator = new YAHOO.ext.Animator();<br>var cursor = new YAHOO.ext.Actor('cursor-img', animator); <br></font><font face="Arial">var resize = new YAHOO.ext.Actor('resize-img', animator); <br>var click = new YAHOO.ext.Actor('click-img', animator); <br>var splitter = new YAHOO.ext.Actor('splitter', animator); <br>animator.startCapture(); <br>animator.addAsyncCall(Blog.navbar.undockDelegate, 1); <br>cursor.show(); <br>cursor.moveTo(500,400); <br>cursor.moveTo(20, getEl('navbar').getY()+10, true, .75); <br>click.clearOpacity(); <br>click.show(); <br>click.alignTo(cursor, 'tl', [-4, -4]); <br>animator.pause(.5); <br>click.hide(true, .7); <br>animator.addAsyncCall(Blog.navbar.dockDelegate, 1); <br>cursor.alignTo('splitter', 'tr', [0, +100], true, 1); <br>resize.alignTo('splitter', 'tr', [-12, +100]);<br>animator.beginSync(); <br>cursor.hide(); <br>resize.show(); <br>animator.endSync(); <br>splitter.highlight('#EEEEFF', '#C3DAF9', .3); <br>splitter.highlight('#EEEEFF', '#C3DAF9', .3); <br>animator.pause(2);<br>resize.hide(); <br>cursor.show(); <br>cursor.moveTo(-100, -100, true); <br>animator.stopCapture(); <br>animator.play();</font>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

Learning JavaScript is not difficult, but it is challenging. 1) Understand basic concepts such as variables, data types, functions, etc. 2) Master asynchronous programming and implement it through event loops. 3) Use DOM operations and Promise to handle asynchronous requests. 4) Avoid common mistakes and use debugging techniques. 5) Optimize performance and follow best practices.

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...
