MCPcopy
hub / github.com/fengyuanchen/cropperjs / connectedCallback

Method connectedCallback

packages/element-image/src/index.ts:152–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

150 }
151
152 protected connectedCallback(): void {
153 super.connectedCallback();
154
155 const { $image } = this;
156 const $canvas: CropperCanvas | null = this.closest(this.$getTagNameOf(CROPPER_CANVAS));
157
158 if ($canvas) {
159 this.$canvas = $canvas;
160 this.$setStyles({
161 // Make it a block element to avoid side effects (#1074).
162 display: 'block',
163 position: 'absolute',
164 });
165
166 this.$onCanvasActionStart = (event: Event | CustomEvent) => {
167 this.$actionStartTarget = (event as CustomEvent).detail?.relatedEvent?.target;
168 };
169 this.$onCanvasActionEnd = () => {
170 this.$actionStartTarget = null;
171 };
172 this.$onCanvasAction = this.$handleAction.bind(this);
173 on($canvas, EVENT_ACTION_START, this.$onCanvasActionStart);
174 on($canvas, EVENT_ACTION_END, this.$onCanvasActionEnd);
175 on($canvas, EVENT_ACTION, this.$onCanvasAction);
176 }
177
178 this.$onLoad = this.$handleLoad.bind(this);
179 on($image, EVENT_LOAD, this.$onLoad);
180 this.$getShadowRoot().appendChild($image);
181 }
182
183 protected disconnectedCallback(): void {
184 const { $image, $canvas } = this;

Callers

nothing calls this directly

Calls 4

onFunction · 0.90
$getTagNameOfMethod · 0.80
$setStylesMethod · 0.80
$getShadowRootMethod · 0.80

Tested by

no test coverage detected