Getting IE8 compatibility with EaselJS and ExplorerCanvas

后端 未结 2 1220
小鲜肉
小鲜肉 2021-01-07 10:24

I am using EaselJS and want to allow for backwards compatibility with ExplorerCanvas.

This should be possible using the following code (see here):

c         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-07 10:57

    You should instantiate the quasi canvas element by making reference to the original canvas source as provided on the project page example:

    
    
    
    
    var el = document.createElement('canvas');
    G_vmlCanvasManager.initElement(el);
    var ctx = el.getContext('2d'); 
    

    EDIT:

    After further investigation i came to the following conclusions! There are multiple reasons for not being able to include the image into the canvas:

    1. 1st probably there is a bug in the excanvas code for not being able to mimic the native canvas features. I used with more success the modified sancha code, which you can obtain here: http://dev.sencha.com/playpen/tm/excanvas-patch/excanvas-modified.js. See live example here: http://jsfiddle.net/aDHKm/ (try it on IE).
    2. 2nd before Easeljs initialize the core objects and classes first is searching for the canvas element existence. Because IE < 9 doesn't have implemented the canvas it's obvious that easeljs core graphics API's can not be instantiated. I think these are the two main reasons that your code is not working.

    My suggestion is to try to remake the code without the easeljs. I made a fiddle with the necessary modification to show you how can be done without easeljs: http://jsfiddle.net/xdXrw/. I don't know if it's absolute imperative for you to use easeljs, but certainly it has some limitations in terms of IE8 hacked canvas.

提交回复
热议问题