| 6 | type AnnotationState = 'unattached' | 'not-showing' | 'showing'; |
| 7 | |
| 8 | class RoughAnnotationImpl implements RoughAnnotation { |
| 9 | private _state: AnnotationState = 'unattached'; |
| 10 | private _config: RoughAnnotationConfig; |
| 11 | private _resizing = false; |
| 12 | private _ro?: any; // ResizeObserver is not supported in typescript std lib yet |
| 13 | private _seed = randomSeed(); |
| 14 | |
| 15 | private _e: HTMLElement; |
| 16 | private _svg?: SVGSVGElement; |
| 17 | private _lastSizes: Rect[] = []; |
| 18 | |
| 19 | _animationDelay = 0; |
| 20 | |
| 21 | constructor(e: HTMLElement, config: RoughAnnotationConfig) { |
| 22 | this._e = e; |
| 23 | this._config = JSON.parse(JSON.stringify(config)); |
| 24 | this.attach(); |
| 25 | } |
| 26 | |
| 27 | get animate() { return this._config.animate; } |
| 28 | set animate(value) { this._config.animate = value; } |
| 29 | |
| 30 | get animationDuration() { return this._config.animationDuration; } |
| 31 | set animationDuration(value) { this._config.animationDuration = value; } |
| 32 | |
| 33 | get iterations() { return this._config.iterations; } |
| 34 | set iterations(value) { this._config.iterations = value; } |
| 35 | |
| 36 | get color() { return this._config.color; } |
| 37 | set color(value) { |
| 38 | if (this._config.color !== value) { |
| 39 | this._config.color = value; |
| 40 | this.refresh(); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | get strokeWidth() { return this._config.strokeWidth; } |
| 45 | set strokeWidth(value) { |
| 46 | if (this._config.strokeWidth !== value) { |
| 47 | this._config.strokeWidth = value; |
| 48 | this.refresh(); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | get padding() { return this._config.padding; } |
| 53 | set padding(value) { |
| 54 | if (this._config.padding !== value) { |
| 55 | this._config.padding = value; |
| 56 | this.refresh(); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | private _resizeListener = () => { |
| 61 | if (!this._resizing) { |
| 62 | this._resizing = true; |
| 63 | setTimeout(() => { |
| 64 | this._resizing = false; |
| 65 | if (this._state === 'showing') { |
nothing calls this directly
no test coverage detected
searching dependent graphs…