Fabric Canvas changing position when Openseadragon

2019-08-15 01:47发布

问题:


I am using Fabric.js Canvas on top of OpenSeadragon(osd). I am trying to create a compass/rotater widget on top of the osd image, which will rotate the osd image. It should zoom and pan with the osd image, but should not rotate with the osd image.

Things are getting tidy when i use

viewer.viewport.setRotation(angle);    

Osd Image rotates, but the location of the Fabric canvas objects also change with it, even though i have set the objects to be in the center of the image. Here is the codePen link

回答1:

The issue was that I was tring to use viewer.setRotation(), which rotates the viewer object.

Line number - 75 - I changed the code to

 viewer.world.getItemAt(0).setRotation(angle, true);


and the issue was fixed. Above codePen is updated.