Tools.EllipseCreateTool.prototype.mouseMove = function(e) {
Tools.GenericAnnotationCreateTool.prototype.mouseMove.call(this, e);
const annotation = this['annotation'];
if (annotation) {
const width = annotation['Width'];
const height = annotation['Height'];
const maxDimension = Math.abs(width < height ? width : height);
annotation['Width'] = maxDimension;
annotation['Height'] = maxDimension;
// The following code ensures the annotation X and Y
// remains fixed to point where we started drawing,
// even as the annotation moves upwards or leftwards
const pt0 = this['pageCoordinates'][0];
const pt1 = this['pageCoordinates'][1];
const deltaX = pt1.x - pt0.x;
const deltaY = pt1.y - pt0.y;
const absDeltaX = Math.abs(deltaX);
const absDeltaY = Math.abs(deltaY);
const offset = absDeltaX < absDeltaY ? absDeltaX : absDeltaY;
if (deltaX < 0) {
annotation['X'] = pt0.x - offset;
}
if (deltaY < 0) {
annotation['Y'] = pt0.y - offset;
}
this.docViewer.annotationManager.redrawAnnotation(this['annotation']);
// By toggling this on/off we can ensure the ellipsis remains
// a perfect circle when it is being resized when selected
annotation['MaintainAspectRatio'] = true;
}
};