KonvaJS rotate on touch devices

558 Views Asked by At

can you assist me?

https://konvajs.github.io/docs/sandbox/Multi-touch_Scale_Stage.html

this tutorial works perfectly, can you help me please make the rotation in same manner? i want to rotate my stage clockwise and counterclockwise.

1

There are 1 best solutions below

1
lavrton On

This simplest way is to add gesture recognition library and then use rotate event.

For example, I added https://zingchart.github.io/zingtouch/ library.

var containerElement = document.getElementById('container');
var activeRegion = ZingTouch.Region(containerElement);

var childElement = document.getElementById('container');
activeRegion.bind(childElement, 'rotate', function(event){
    stage.rotation(-event.detail.angle);
    stage.draw();
});

Demo: https://jsfiddle.net/lavrton/7nLte356/9/