|
109 | 109 |
|
110 | 110 | $.fn.playKeyframe = function(frameOptions, callback) {
|
111 | 111 |
|
112 |
| - if (typeof frameOptions === 'string') { |
113 |
| - var frameOptSplit = frameOptions.trim().split(' '); |
114 |
| - frameOptions = { |
115 |
| - name: frameOptSplit[0], |
116 |
| - duration: parseInt(frameOptSplit[1]), |
117 |
| - timingFunction: frameOptSplit[2], |
118 |
| - delay: parseInt(frameOptSplit[3]), |
119 |
| - repeat: frameOptSplit[4], |
120 |
| - direction: frameOptSplit[5], |
121 |
| - fillMode: frameOptSplit[6], |
122 |
| - complete: callback |
| 112 | + var animObjToStr = function(obj){ |
| 113 | + obj = $.extend({ |
| 114 | + duration: 0, |
| 115 | + timingFunction: "ease", |
| 116 | + delay: 0, |
| 117 | + iterationCount: 1, |
| 118 | + direction: "normal", |
| 119 | + fillMode: "forwards" |
| 120 | + }, obj); |
| 121 | + return [obj.name, obj.duration, obj.timingFunction, obj.delay, obj.iterationCount, obj.direction, obj.fillMode].join(" "); |
| 122 | + }; |
| 123 | + |
| 124 | + var animationcss = ""; |
| 125 | + |
| 126 | + if($.isArray(frameOptions)){ |
| 127 | + var frameOptionsStrings = []; |
| 128 | + console.log(frameOptions.length); |
| 129 | + for(var i = 0; i < frameOptions.length; i++){ |
| 130 | + if (typeof frameOptions[i] === 'string') { |
| 131 | + frameOptionsStrings.push(frameOptions[i]); |
| 132 | + }else{ |
| 133 | + frameOptionsStrings.push(animObjToStr(frameOptions[i])); |
| 134 | + } |
123 | 135 | }
|
| 136 | + animationcss = frameOptionsStrings.join(", "); |
| 137 | + }else if (typeof frameOptions === 'string') { |
| 138 | + animationcss = frameOptions; |
| 139 | + }else{ |
| 140 | + animationcss = animObjToStr(frameOptions); |
124 | 141 | }
|
125 | 142 |
|
126 |
| - frameOptions = $.extend({ |
127 |
| - duration: 0, |
128 |
| - timingFunction: "ease", |
129 |
| - delay: 0, |
130 |
| - repeat: 1, |
131 |
| - direction: "normal", |
132 |
| - fillMode: "forwards", |
133 |
| - complete: callback |
134 |
| - }, frameOptions); |
135 |
| - |
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 | 143 | var animationkey = vendorPrefix + "animation";
|
141 | 144 | var pfx = ["webkit", "moz", "MS", "o", ""];
|
142 | 145 |
|
|
0 commit comments