Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c98739

Browse files
committed
Update HTML animation as slider is dragged
1 parent d5a4eda commit 1c98739

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/matplotlib/_animation_data.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/
55
css/font-awesome.min.css">
66
<script language="javascript">
7+
function isInternetExplorer() {
8+
ua = navigator.userAgent;
9+
/* MSIE used to detect old browsers and Trident used to newer ones*/
10+
return ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1;
11+
}
12+
713
/* Define the Animation class */
814
function Animation(frames, img_id, slider_id, interval, loop_select_id){
915
this.img_id = img_id;
@@ -20,7 +26,15 @@
2026
this.frames[i] = new Image();
2127
this.frames[i].src = frames[i];
2228
}
23-
document.getElementById(this.slider_id).max = this.frames.length - 1;
29+
var slider = document.getElementById(this.slider_id);
30+
slider.max = this.frames.length - 1;
31+
if (isInternetExplorer()) {
32+
// switch from oninput to onchange because IE <= 11 does not conform
33+
// with W3C specification. It ignores oninput and onchange behaves
34+
// like oninput. In contrast, Mircosoft Edge behaves correctly.
35+
slider.setAttribute('onchange', slider.getAttribute('oninput'));
36+
slider.setAttribute('oninput', null);
37+
}
2438
this.set_frame(this.current_frame);
2539
}
2640
@@ -183,7 +197,7 @@
183197
<div class="anim-controls">
184198
<input id="_anim_slider{id}" type="range" class="anim-slider"
185199
name="points" min="0" max="1" step="1" value="0"
186-
onchange="anim{id}.set_frame(parseInt(this.value));"></input>
200+
oninput="anim{id}.set_frame(parseInt(this.value));"></input>
187201
<div class="anim-buttons">
188202
<button onclick="anim{id}.slower()"><i class="fa fa-minus"></i></button>
189203
<button onclick="anim{id}.first_frame()"><i class="fa fa-fast-backward">

0 commit comments

Comments
 (0)