Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.addHitRegion() doesn't work in Chrome

I have the latest Chrome version and I see in specs that it should support .addHitRegion() method, as mentioned on MDN. For some reason I get Uncaught TypeError: context.addHitRegion is not a function error.

My code is as simple as this:

var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.beginPath();
context.rect(10,10,100,100);
context.fill();
context.addHitRegion({'id': 'The First Button', 'cursor': 'pointer'});

How do I fix it?

like image 911
Sergei Basharov Avatar asked Mar 31 '16 15:03

Sergei Basharov


1 Answers

Go here with your browser: chrome://flags

and then

Set the flag Experimental Web Platform features to true to enable it.

like image 185
Bolza Avatar answered Oct 03 '22 22:10

Bolza