davidenke / context-filter-polyfill

Polyfills `CanvasRenderingContext2d.filter` capability of adopting CSS3 filters to canvas contexts at least partially.
MIT License
89 stars 22 forks source link

Conflicts with fabric.js #4

Open poojakapuriya619 opened 4 years ago

poojakapuriya619 commented 4 years ago

It changes the default CanvasRenderingContext2d and therefore while adding text to canvas the method does not work properly.

Can you please help fix this? Thanks in advance.

davidenke commented 4 years ago

I've no experiences with Fabric.js, but I think you can maybe trigger it's behavior after the polyfill has run.

Edit: Okay, I see the issue now after having a look at Fabric.js. I think you need to delay this polyfill after Fabric is run. So you need to load and apply the polyfill after Fabric did its magic (and maybe re-apply it after changes have been made). You can see here how the polyfill is applied. Lazy loading the script is some Stackoverflow research. It'll may be easier to have a global short hand method to call the polyfill dynamically...

poojakapuriya619 commented 4 years ago

Thanks. I'll check this and let you know if it works.

poojakapuriya619 commented 4 years ago

I checked the lazy loading script. Unfortunately its not working in my case because once the script is loaded it again overrides the default behaviour of all methods. I want to add filters and text from frabic.js simultaneously.

The global method sounds like a solution but I am really new to polyfill. I downloaded js from demo and struggling to create a global class for the same. Could you please create a Js and add to your repo?