define(["require", "exports", "@syncfusion/ej2-base", "../utils/helper"], function (require, exports, ej2_base_1, helper_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var AnnotationBase = (function () {
function AnnotationBase(control) {
this.control = control;
}
AnnotationBase.prototype.render = function (annotation, index) {
this.annotation = annotation;
var childElement = ej2_base_1.createElement('div', {
id: this.control.element.id + 'Annotation' + index,
styles: 'position:absolute;z-index:1', innerHTML: annotation.content
});
return childElement;
};
AnnotationBase.prototype.processAnnotation = function (annotation, index, parentElement) {
var location = new helper_1.ProgressLocation(0, 0);
var annotationElement = this.render(annotation, index);
Eif (annotationElement) {
this.setElementStyle(location, annotationElement, parentElement);
}
else if (this.control.redraw) {
helper_1.removeElement(annotationElement.id);
if (this.control.isReact) {
this.control.clearTemplate();
}
}
};
AnnotationBase.prototype.setElementStyle = function (location, element, parentElement) {
var argsData = {
cancel: false, name: helper_1.annotationRender, content: element,
location: location
};
this.control.trigger(helper_1.annotationRender, argsData);
Eif (!argsData.cancel) {
var result = this.Location(this.annotation.annotationRadius, this.annotation.annotationAngle);
argsData.content.style.left = result.left + 'px';
argsData.content.style.top = result.top + 'px';
argsData.content.style.transform = 'translate(-50%, -50%)';
argsData.content.setAttribute('aria-label', 'Annotation');
parentElement.appendChild(argsData.content);
if (this.control.isReact) {
this.control.renderReactTemplates();
}
}
};
AnnotationBase.prototype.Location = function (radius, angle) {
var top;
var left;
var radius1 = parseFloat(radius);
if (radius1 === 0 && angle === 0) {
var rect = this.control.progressRect;
left = rect.x + (rect.width / 2);
top = rect.y + (rect.height / 2);
}
else {
var degToRadFactor = Math.PI / 180;
angle = angle - 90;
angle = angle * degToRadFactor;
var x = Math.round(this.control.progressSize.width / 2.25);
var y = Math.round(this.control.progressSize.height / 2.25);
left = (radius1 * Math.cos(angle)) + x;
top = (radius1 * Math.sin(angle)) + y;
}
return {
top: top, left: left
};
};
return AnnotationBase;
}());
exports.AnnotationBase = AnnotationBase;
});
|