File tree 3 files changed +46
-10
lines changed
src/components/rangeslider
3 files changed +46
-10
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright 2012-2016, Plotly, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ // This code adapted from:
10
+ //
11
+ // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
12
+ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
13
+
14
+ // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
15
+
16
+ // MIT license
17
+
18
+
19
+ 'use strict' ;
20
+
21
+ if ( ! Date . now ) {
22
+ Date . now = function ( ) { return new Date ( ) . getTime ( ) ; } ;
23
+ }
24
+
25
+ var vendors = [ 'webkit' , 'moz' ] ;
26
+ for ( var i = 0 ; i < vendors . length && ! window . requestAnimationFrame ; ++ i ) {
27
+ var vp = vendors [ i ] ;
28
+ window . requestAnimationFrame = window [ vp + 'RequestAnimationFrame' ] ;
29
+ window . cancelAnimationFrame = ( window [ vp + 'CancelAnimationFrame' ] ||
30
+ window [ vp + 'CancelRequestAnimationFrame' ] ) ;
31
+ }
32
+ if ( / i P ( a d | h o n e | o d ) .* O S 6 / . test ( window . navigator . userAgent ) || // iOS6 is buggy
33
+ ! window . requestAnimationFrame || ! window . cancelAnimationFrame ) {
34
+ var lastTime = 0 ;
35
+ window . requestAnimationFrame = function ( callback ) {
36
+ var now = Date . now ( ) ;
37
+ var nextTime = Math . max ( lastTime + 16 , now ) ;
38
+ return setTimeout ( function ( ) { callback ( lastTime = nextTime ) ; } ,
39
+ nextTime - now ) ;
40
+ } ;
41
+ window . cancelAnimationFrame = clearTimeout ;
42
+ }
Original file line number Diff line number Diff line change @@ -221,16 +221,9 @@ module.exports = function createSlider(gd) {
221
221
}
222
222
223
223
function setDataRange ( dataMin , dataMax ) {
224
-
225
- if ( window . requestAnimationFrame ) {
226
- window . requestAnimationFrame ( function ( ) {
227
- Plotly . relayout ( gd , 'xaxis.range' , [ dataMin , dataMax ] ) ;
228
- } ) ;
229
- } else {
230
- setTimeout ( function ( ) {
231
- Plotly . relayout ( gd , 'xaxis.range' , [ dataMin , dataMax ] ) ;
232
- } , 16 ) ;
233
- }
224
+ window . requestAnimationFrame ( function ( ) {
225
+ Plotly . relayout ( gd , 'xaxis.range' , [ dataMin , dataMax ] ) ;
226
+ } ) ;
234
227
}
235
228
236
229
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ function getInfoContent() {
52
52
'' ,
53
53
'```html' ,
54
54
'<script>if(typeof window.Int16Array !== \'function\')document.write("<scri"+"pt src=\'extras/typedarray.min.js\'></scr"+"ipt>");</script>' ,
55
+ '<script>document.write("<scri"+"pt src=\'extras/request_animation_frame.js\'></scr"+"ipt>");</script>' ,
55
56
'```' ,
56
57
'' ,
57
58
'before the plotly.js script tag.' ,
You can’t perform that action at this time.
0 commit comments