说它短,是因为总共核心代码+注释不到100行。(需要声明一下的是此代码非原创,但略有修改,加了自已的部分注解)
function getEl(id) {
? document.getElementById(id) : id;
3: }
/**
* @fileoverview Tween
*/
function Tween(C, B, A) {
if (C) {
this.time = parseInt(C * 1000)
10: }
if (B) {
this.transform = B
13: }
if (A) {
this.interval = A
16: }
17: }
18: Tween.prototype = {
19: interval: 40,
function(A) {
return 1 - Math.pow(1 - A, 3)
22: },
23: time: 1000,
function(A, E, D) {
this.transform;
function H() {
27: I += C;
//<==>(runTime / totalTime)
//Tween over
30: A(1);
31: E();
32: clearInterval(B)
else {
34: A(D(J) / G)
35: }
36: }
this.interval;
this.time;
var G = D(1);
var I = 0;
var B = setInterval(H, C);
return B
43: },
/**
* C {id|dom}
* F width
* E height
*/
function(C, F, E, G) {
50: C = getEl(C);
var I = C.offsetLeft;
var H = C.offsetTop;
var B = C.style;
function A(J) {
;
57: }
function D() {
null;
60: G && G()
61: }
this.start(A, D)
63: },
/**
* D {id|dom}
* C start--opacity
* A end--opacity
* E complete--callback
*/
function(D, C, A, E) {
71: D = getEl(D);
var G = A - C;
var M = document.defaultView && document.defaultView.getComputedStyle;
function B(I) {
75: I = C + G * I;
if (!M) {
if (I >= 1) {
;
true;
80: }
81:
')';
else {
84: D.style.opacity = I;
85: }
86: }
function F() {
null;
89: E && E()
90: }
this.start(B, F)
92: }
93: };