简体   繁体   English

jQuery动画在IE8中不起作用

[英]JQuery animation doesn't work in IE8

I have used HighChart JS for creating a chart. 我使用HighChart JS创建图表。 My only change to it was to create the animation for each series in the chart. 我唯一的更改是为图表中的每个系列创建动画。

All went well, but only problem is that it doesn't work in IE8. 一切顺利,但是唯一的问题是它在IE8中不起作用。 It works in IE9, IE10 and in all other sane browsers. 它可以在IE9,IE10和所有其他合理的浏览器中使用。

I created a fiddle here and will be thankful if you can take a look. 我在这里创建了一个小提琴,如果您可以看一下,将不胜感激。

http://jsfiddle.net/DUvQW/ http://jsfiddle.net/DUvQW/

This is what I wrote and where I created the timed animation:- 这是我写的,也是我创建定时动画的地方:-

 chart: {
            type: 'bubble',
            width: 650,
            height: 450,
            zoomType: 'xy',
            events: {
                load: function (event) {

                    this.series.forEach(function (d, i) {
                        if (d.options.id == 1) {
                            setTimeout(function () {
                                d.show();
                            }, 100);

                        }
                        if (d.options.id == 2) {
                            setTimeout(function () {
                                d.show();
                            }, 1000);
                        }
                        if (d.options.id == 3) {
                            setTimeout(function () {
                                d.show();
                            }, 2000);
                        }
                        if (d.options.id == 4) {
                            setTimeout(function () {
                                d.show();
                            }, 3000);
                        }
                        if (d.options.id == 5) {
                            setTimeout(function () {
                                d.show();
                            }, 4000);
                        }
                        if (d.options.id == 6) {
                            setTimeout(function () {
                                d.show();
                            }, 5000);
                        }
                    })

                }
            }
        },
        . . . 

IE 8 does not support the .forEach() iterator for arrays. IE 8不支持数组的.forEach()迭代器。 You can either switch to the for (var i = 0; i < array.length; i++) method of iterating arrays or you can install a polyfill for .forEach() . 您可以切换到迭代数组的for (var i = 0; i < array.length; i++)方法,也可以为.forEach()安装.forEach() See this MDN page for the polyfill. 请参见此MDN页面以获取polyfill。

If you switch to a regular for loop, then you will also have to use an IIFE (immediately executing function expression) to capture a unique value for d for each iteration of the loop like here: http://jsfiddle.net/jfriend00/yMRP8/ 如果切换到常规的for循环,则还必须使用IIFE(立即执行函数表达式)为循环的每次迭代捕获d的唯一值,例如: http : //jsfiddle.net/jfriend00/ yMRP8 /

Or, you can add the polyfill for .forEach() as shown here to add support for it in IE8: http://jsfiddle.net/jfriend00/6kybR/ . 或者,您可以如下所示添加.forEach() ,以在IE8中添加对此的支持: http : //jsfiddle.net/jfriend00/6kybR/ The jsFiddle will not work in IE8 because jsFiddle itself does not support IE8. jsFiddle无法在IE8中使用,因为jsFiddle本身不支持IE8。 You will have to test the polyfill in IE8 in your own actual code. 您将必须使用自己的实际代码测试IE8中的polyfill。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM