1
1
( function ( ) {
2
- var $createKeyframeStyleTag , animationPlayState , playStateRunning ,
3
- animationSupport = false ,
2
+ var animationSupport = false ,
4
3
animationString = 'animation' ,
5
4
vendorPrefix = prefix = '' ,
6
5
domPrefixes = [ 'Webkit' , 'Moz' , 'O' , 'ms' , 'Khtml' ] ;
23
22
} ) ;
24
23
25
24
26
- $createKeyframeStyleTag = function ( params ) {
25
+ var $createKeyframeStyleTag = function ( id ) {
27
26
return $ ( "<style>" ) . attr ( {
28
27
class : "keyframe-style" ,
29
- id : params . id ,
28
+ id : id ,
30
29
type : "text/css"
31
30
} ) . appendTo ( "head" ) ;
32
31
} ;
39
38
return animationSupport ;
40
39
} ,
41
40
generate : function ( frameData ) {
42
- var $elems , $frameStyle , css , frameName , property , key ;
43
- frameName = frameData . name || "" ;
44
- css = "@" + vendorPrefix + "keyframes " + frameName + " {" ;
41
+ var frameName = frameData . name || "" ;
42
+ var css = "@" + vendorPrefix + "keyframes " + frameName + " {" ;
45
43
46
- for ( key in frameData ) {
44
+ for ( var key in frameData ) {
47
45
if ( key !== "name" ) {
48
46
css += key + " {" ;
49
47
50
- for ( property in frameData [ key ] ) {
48
+ for ( var property in frameData [ key ] ) {
51
49
css += property + ":" + frameData [ key ] [ property ] + ";" ;
52
50
}
53
51
57
55
58
56
css = PrefixFree . prefixCSS ( css + "}" ) ;
59
57
60
- $frameStyle = $ ( "style#" + frameData . name ) ;
58
+ var $frameStyle = $ ( "style#" + frameData . name ) ;
61
59
62
60
if ( $frameStyle . length > 0 ) {
63
61
$frameStyle . html ( css ) ;
64
62
65
- $elems = $ ( "*" ) . filter ( function ( ) {
66
- this . style [ "" + animationString + "Name" ] === frameName ;
63
+ var $elems = $ ( "*" ) . filter ( function ( ) {
64
+ this . style [ animationString + "Name" ] === frameName ;
67
65
} ) ;
68
66
69
67
$elems . each ( function ( ) {
75
73
} ) ;
76
74
} ) ;
77
75
} else {
78
- $createKeyframeStyleTag ( {
79
- id : frameName
80
- } ) . append ( css ) ;
76
+ $createKeyframeStyleTag ( frameName ) . append ( css ) ;
81
77
}
82
78
} ,
83
79
define : function ( frameData ) {
87
83
this . generate ( frame ) ;
88
84
}
89
85
} else {
90
- return this . generate ( frameData ) ;
86
+ this . generate ( frameData ) ;
91
87
}
92
88
}
93
89
} ;
94
90
95
- animationPlayState = "animation-play-state" ;
96
- playStateRunning = "running" ;
91
+ var animationPlayState = "animation-play-state" ;
92
+ var playStateRunning = "running" ;
97
93
98
94
$ . fn . resetKeyframe = function ( callback ) {
99
95
var $el = $ ( this ) . css ( vendorPrefix + animationPlayState , playStateRunning ) . css ( vendorPrefix + "animation" , "none" ) ;
104
100
} ;
105
101
106
102
$ . fn . pauseKeyframe = function ( ) {
107
- var $el = $ ( this ) . css ( vendorPrefix + animationPlayState , "paused" ) ;
103
+ $ ( this ) . css ( vendorPrefix + animationPlayState , "paused" ) ;
108
104
} ;
109
105
110
106
$ . fn . resumeKeyframe = function ( ) {
111
- return $ ( this ) . css ( vendorPrefix + animationPlayState , playStateRunning ) ;
107
+ $ ( this ) . css ( vendorPrefix + animationPlayState , playStateRunning ) ;
112
108
} ;
113
109
114
110
$ . fn . playKeyframe = function ( frameOptions , callback ) {
115
- var animationcss , animationkey , delay , duration , pfx , repeat ;
116
111
117
112
if ( typeof frameOptions === 'string' ) {
118
113
var frameOptSplit = frameOptions . trim ( ) . split ( ' ' ) ;
138
133
complete : callback
139
134
} , frameOptions ) ;
140
135
141
- duration = frameOptions . duration ;
142
- delay = frameOptions . delay ;
143
- repeat = frameOptions . repeat ;
144
- animationcss = "" + frameOptions . name + " " + duration + "ms " + frameOptions . timingFunction + " " + delay + "ms " + repeat + " " + frameOptions . direction + " " + frameOptions . fillMode ;
145
- callback = frameOptions . complete ;
146
- animationkey = vendorPrefix + "animation" ;
147
- pfx = [ "webkit" , "moz" , "MS" , "o" , "" ] ;
136
+ var duration = frameOptions . duration ;
137
+ var delay = frameOptions . delay ;
138
+ var repeat = frameOptions . repeat ;
139
+ var animationcss = "" + frameOptions . name + " " + duration + "ms " + frameOptions . timingFunction + " " + delay + "ms " + repeat + " " + frameOptions . direction + " " + frameOptions . fillMode ;
140
+ var animationkey = vendorPrefix + "animation" ;
141
+ var pfx = [ "webkit" , "moz" , "MS" , "o" , "" ] ;
148
142
149
143
var _prefixEvent = function ( element , type , callback ) {
150
- var evt , p , _results ;
151
- p = 0 ;
152
- _results = [ ] ;
153
- while ( p < pfx . length ) {
154
- if ( ! pfx [ p ] ) {
144
+ for ( var i = 0 ; i < pfx . length ; i ++ ) {
145
+ if ( ! pfx [ i ] ) {
155
146
type = type . toLowerCase ( ) ;
156
147
}
157
- evt = pfx [ p ] + type ;
148
+ var evt = pfx [ i ] + type ;
158
149
element . off ( evt ) . on ( evt , callback ) ;
159
- _results . push ( p ++ ) ;
160
150
}
161
- _results ;
162
151
} ;
163
152
164
153
this . each ( function ( ) {
172
161
return this ;
173
162
} ;
174
163
175
- $createKeyframeStyleTag ( {
176
- id : "boost-keyframe"
177
- } ) . append ( " .boostKeyframe{" + vendorPrefix + "transform:scale3d(1,1,1);}" ) ;
164
+ $createKeyframeStyleTag ( "boost-keyframe" ) . append ( " .boostKeyframe{" + vendorPrefix + "transform:scale3d(1,1,1);}" ) ;
178
165
179
166
} ) . call ( this ) ;
0 commit comments