()
| 64 | } |
| 65 | |
| 66 | protected connectedCallback(): void { |
| 67 | super.connectedCallback(); |
| 68 | |
| 69 | const $canvas: CropperCanvas | null = this.closest(this.$getTagNameOf(CROPPER_CANVAS)); |
| 70 | |
| 71 | if ($canvas) { |
| 72 | this.$canvas = $canvas; |
| 73 | this.style.position = 'absolute'; |
| 74 | |
| 75 | const $selection: CropperSelection | null = $canvas.querySelector( |
| 76 | this.$getTagNameOf(CROPPER_SELECTION), |
| 77 | ); |
| 78 | |
| 79 | if ($selection) { |
| 80 | this.$onWindowResize = this.$render.bind(this); |
| 81 | this.$onCanvasActionStart = (event) => { |
| 82 | if ($selection.hidden && (event as CustomEvent).detail.action === ACTION_SELECT) { |
| 83 | this.hidden = false; |
| 84 | } |
| 85 | }; |
| 86 | this.$onCanvasActionEnd = (event) => { |
| 87 | if ($selection.hidden && (event as CustomEvent).detail.action === ACTION_SELECT) { |
| 88 | this.hidden = true; |
| 89 | } |
| 90 | }; |
| 91 | this.$onSelectionChange = (event) => { |
| 92 | const { |
| 93 | x, |
| 94 | y, |
| 95 | width, |
| 96 | height, |
| 97 | } = event.defaultPrevented ? $selection : (event as CustomEvent).detail; |
| 98 | |
| 99 | this.$change(x, y, width, height); |
| 100 | |
| 101 | if ($selection.hidden || (x === 0 && y === 0 && width === 0 && height === 0)) { |
| 102 | this.hidden = true; |
| 103 | } |
| 104 | }; |
| 105 | on(window, EVENT_RESIZE, this.$onWindowResize); |
| 106 | on($canvas, EVENT_ACTION_START, this.$onCanvasActionStart); |
| 107 | on($canvas, EVENT_ACTION_END, this.$onCanvasActionEnd); |
| 108 | on($canvas, EVENT_CHANGE, this.$onSelectionChange); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | this.$render(); |
| 113 | } |
| 114 | |
| 115 | protected disconnectedCallback(): void { |
| 116 | const { $canvas } = this; |
nothing calls this directly
no test coverage detected