MCPcopy
hub / github.com/chen-zeong/DTV / afterCreate

Method afterCreate

web/src/components/player/danmuPlugins.ts:125–176  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

123 private opacitySlider: HTMLInputElement | null = null;
124
125 override afterCreate() {
126 if (this.config.disable) {
127 return;
128 }
129 this.currentSettings = typeof this.config.getSettings === 'function'
130 ? this.config.getSettings()
131 : this.currentSettings;
132 this.currentSettings.area = sanitizeDanmuArea(this.currentSettings.area);
133 this.currentSettings.opacity = sanitizeDanmuOpacity(this.currentSettings.opacity);
134 if (typeof this.currentSettings.strokeColor !== 'string') {
135 this.currentSettings.strokeColor = '#444444';
136 }
137
138 this.createPanel();
139 this.updateInputs();
140
141 this.handleToggle = (event: Event) => {
142 event.preventDefault();
143 event.stopPropagation();
144 this.togglePanel();
145 };
146
147 this.bind(['click', 'touchend'], this.handleToggle);
148
149 if (typeof document !== 'undefined') {
150 this.handleDocumentClick = (event: MouseEvent) => {
151 if (!this.root.contains(event.target as Node)) {
152 this.closePanel();
153 }
154 };
155 document.addEventListener('click', this.handleDocumentClick);
156 }
157
158 this.handleHoverEnter = () => {
159 if (this.hoverCloseTimer) {
160 clearTimeout(this.hoverCloseTimer);
161 this.hoverCloseTimer = null;
162 }
163 this.openPanel();
164 };
165 this.handleHoverLeave = () => {
166 if (this.hoverCloseTimer) {
167 clearTimeout(this.hoverCloseTimer);
168 }
169 this.hoverCloseTimer = setTimeout(() => {
170 this.hoverCloseTimer = null;
171 this.closePanel();
172 }, 220);
173 };
174 this.bind('mouseenter', this.handleHoverEnter);
175 this.bind('mouseleave', this.handleHoverLeave);
176 }
177
178 override destroy() {
179 if (this.handleToggle) {

Callers

nothing calls this directly

Calls 7

createPanelMethod · 0.95
updateInputsMethod · 0.95
togglePanelMethod · 0.95
closePanelMethod · 0.95
openPanelMethod · 0.95
sanitizeDanmuAreaFunction · 0.90
sanitizeDanmuOpacityFunction · 0.90

Tested by

no test coverage detected