Showing
1 changed file
with
0 additions
and
42 deletions
@@ -160,48 +160,6 @@ $header.on('touchstart', 'a', function() { | @@ -160,48 +160,6 @@ $header.on('touchstart', 'a', function() { | ||
160 | $(this).removeClass('highlight'); | 160 | $(this).removeClass('highlight'); |
161 | }); | 161 | }); |
162 | 162 | ||
163 | -(function() { | ||
164 | - var lastTime = 0; | ||
165 | - var prefixes = 'webkit moz ms o'.split(' '); | ||
166 | - | ||
167 | - var requestAnimationFrame = window.requestAnimationFrame; | ||
168 | - var cancelAnimationFrame = window.cancelAnimationFrame; | ||
169 | - | ||
170 | - var prefix; | ||
171 | - | ||
172 | - //通过遍历各浏览器前缀,来得到requestAnimationFrame和cancelAnimationFrame在当前浏览器的实现形式 | ||
173 | - for( var i = 0; i < prefixes.length; i++ ) { | ||
174 | - if ( requestAnimationFrame && cancelAnimationFrame ) { | ||
175 | - break; | ||
176 | - } | ||
177 | - prefix = prefixes[i]; | ||
178 | - requestAnimationFrame = requestAnimationFrame || window[ prefix + 'RequestAnimationFrame' ]; | ||
179 | - cancelAnimationFrame = cancelAnimationFrame || window[ prefix + 'CancelAnimationFrame' ] || window[ prefix + 'CancelRequestAnimationFrame' ]; | ||
180 | - } | ||
181 | - | ||
182 | - //如果当前浏览器不支持requestAnimationFrame和cancelAnimationFrame,则会退到setTimeout | ||
183 | - if ( !requestAnimationFrame || !cancelAnimationFrame ) { | ||
184 | - requestAnimationFrame = function( callback, element ) { | ||
185 | - var currTime = new Date().getTime(); | ||
186 | - | ||
187 | - //为了使setTimteout的尽可能的接近每秒60帧的效果 | ||
188 | - var timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) ); | ||
189 | - var id = window.setTimeout( function() { | ||
190 | - callback( currTime + timeToCall ); | ||
191 | - }, timeToCall ); | ||
192 | - lastTime = currTime + timeToCall; | ||
193 | - return id; | ||
194 | - }; | ||
195 | - | ||
196 | - cancelAnimationFrame = function( id ) { | ||
197 | - window.clearTimeout( id ); | ||
198 | - }; | ||
199 | - } | ||
200 | - | ||
201 | - window.requestAnimationFrame = requestAnimationFrame; | ||
202 | - window.cancelAnimationFrame = cancelAnimationFrame; | ||
203 | -}()); | ||
204 | - | ||
205 | //暴露公共接口 | 163 | //暴露公共接口 |
206 | window.cookie = cookie; | 164 | window.cookie = cookie; |
207 | 165 |
-
Please register or login to post a comment