Skip to content

Commit

Permalink
feat: add rotation support
Browse files Browse the repository at this point in the history
OpenSeadragon overlay supports rotation since
openseadragon/openseadragon#896
Apply rotation to SVG overlay
  • Loading branch information
leesei committed May 4, 2016
1 parent a0b4b7b commit 0c7c8a0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion openseadragon-svg-overlay.js
Expand Up @@ -46,6 +46,10 @@
self.resize();
});

this._viewer.addHandler('rotate', function(evt) {
self.resize();
});

this.resize();
};

Expand All @@ -70,10 +74,11 @@

var p = this._viewer.viewport.pixelFromPoint(new OpenSeadragon.Point(0, 0), true);
var zoom = this._viewer.viewport.getZoom(true);
var rotation = this._viewer.viewport.getRotation();
// TODO: Expose an accessor for _containerInnerSize in the OSD API so we don't have to use the private variable.
var scale = this._viewer.viewport._containerInnerSize.x * zoom;
this._node.setAttribute('transform',
'translate(' + p.x + ',' + p.y + ') scale(' + scale + ')');
'translate(' + p.x + ',' + p.y + ') scale(' + scale + ') rotate(' + rotation + ')');
},

// ----------
Expand Down

0 comments on commit 0c7c8a0

Please sign in to comment.