medsurf-draw
Version:
Draw annotations on jpg/zoomify images, based on PIXI.js
57 lines • 2.31 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import * as PIXI from "pixi.js-legacy";
import { BaseElementInteraction } from "../bases/interactions/BaseElementInteraction";
var ZoomInteraction = (function (_super) {
__extends(ZoomInteraction, _super);
function ZoomInteraction(element, active) {
if (active === void 0) { active = true; }
var _this = _super.call(this, element) || this;
_this._zoomStep = 0.05;
_this._active = active;
return _this;
}
ZoomInteraction.prototype.reset = function () {
this._spriteX = 0;
this._spriteY = 0;
};
ZoomInteraction.prototype.getGraphCoordinates = function (x, y) {
this._spriteX = x;
this._spriteY = y;
return PIXI.InteractionData.prototype.getLocalPosition.call({ global: { x: this._spriteX, y: this._spriteY } }, this.element);
};
ZoomInteraction.prototype.onZoom = function (event) {
if (!this._active) {
return;
}
var direction = (event.deltaY < 0) ? 1 : -1;
var factor = (1 + direction * this._zoomStep);
this.emit("onZoom", event, event.clientX, event.clientY, factor);
};
Object.defineProperty(ZoomInteraction.prototype, "active", {
get: function () {
return this._active;
},
set: function (value) {
this._active = value;
},
enumerable: false,
configurable: true
});
return ZoomInteraction;
}(BaseElementInteraction));
export { ZoomInteraction };
//# sourceMappingURL=ZoomInteraction.js.map