Skip to content

Commit bfae579

Browse files
oicqcxrdkmaster
authored andcommitted
优化:optimize change for combo-select (#540)
* fix #372 * - remove event lisntener as soon as possible; - change close debounce timeout to 400ms; - change popup debounce timeout to 100ms; * - remove event lisntener as soon as possible; - change close timeout to 400ms; - change open timeout to 100ms; * merge change from master
1 parent 6b8f7fe commit bfae579

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/jigsaw/component/combo-select/combo-select.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,9 @@ export class JigsawComboSelect extends AbstractJigsawComponent implements Contro
294294
if (this._removeWindowClickHandler) {
295295
this._removeWindowClickHandler();
296296
}
297-
298297
this._removeWindowClickHandler = this._renderer.listen('window', 'click', () => {
299-
if (this._removeWindowClickHandler) {
300-
this._removeWindowClickHandler();
301-
}
298+
this._removeWindowClickHandler();
299+
this._removeWindowClickHandler = null;
302300
this.open = false
303301
});
304302

@@ -309,13 +307,23 @@ export class JigsawComboSelect extends AbstractJigsawComponent implements Contro
309307
this._disposePopup = popupInfo.dispose;
310308

311309
if (this._openTrigger === DropDownTrigger.mouseenter && this._popupElement) {
310+
if (this._removeMouseOverHandler) {
311+
this._removeMouseOverHandler();
312+
}
312313
this._removeMouseOverHandler = this._renderer.listen(this._popupElement, 'mouseenter', () => {
314+
this._removeMouseOverHandler();
315+
this._removeMouseOverHandler = null;
313316
clearTimeout(this._rollOutDenouncesTimer);
314317
});
315318
}
316319
if (this._closeTrigger === DropDownTrigger.mouseleave && this._popupElement) {
320+
if (this._removeMouseOutHandler) {
321+
this._removeMouseOutHandler();
322+
}
317323
this._removeMouseOutHandler = this._renderer.listen(this._popupElement, 'mouseleave', () => {
318-
this._rollOutDenouncesTimer = this.callLater(() => this.open = false, 200);
324+
this._removeMouseOutHandler();
325+
this._removeMouseOutHandler = null;
326+
this._rollOutDenouncesTimer = this.callLater(() => this.open = false, 400);
319327
});
320328
}
321329

@@ -336,6 +344,10 @@ export class JigsawComboSelect extends AbstractJigsawComponent implements Contro
336344
this._disposePopup();
337345
this._disposePopup = null;
338346
}
347+
this._clearAllListeners();
348+
}
349+
350+
private _clearAllListeners() {
339351
if (this._removeWindowClickHandler) {
340352
this._removeWindowClickHandler();
341353
this._removeWindowClickHandler = null;
@@ -391,7 +403,7 @@ export class JigsawComboSelect extends AbstractJigsawComponent implements Contro
391403
this._rollInDenouncesTimer = setTimeout(() => {
392404
this.open = true;
393405
if (this._editor) this._editor.select();
394-
}, 200)
406+
}, 100);
395407
}
396408

397409
/**
@@ -403,7 +415,7 @@ export class JigsawComboSelect extends AbstractJigsawComponent implements Contro
403415
event.stopPropagation();
404416

405417
clearTimeout(this._rollInDenouncesTimer);
406-
this._rollOutDenouncesTimer = this.callLater(() => this.open = false, 200);
418+
this._rollOutDenouncesTimer = this.callLater(() => this.open = false, 400);
407419
}
408420

409421
/**
@@ -427,8 +439,8 @@ export class JigsawComboSelect extends AbstractJigsawComponent implements Contro
427439
public ngAfterViewInit() {
428440
this._tags.changes.subscribe(() => {
429441
this._autoEditorWidth();
430-
// 等待combo高度变化,调整下拉位置
431442
this.callLater(() => {
443+
// 等待combo高度变化,调整下拉位置
432444
if (this._popupElement) {
433445
this._popupService.setPosition(this._getPopupOption(), this._popupElement);
434446
}
@@ -440,10 +452,15 @@ export class JigsawComboSelect extends AbstractJigsawComponent implements Contro
440452
super.ngOnDestroy();
441453

442454
this.open = false;
455+
this._clearAllListeners();
443456

444457
if (this._removeRefreshCallback) {
445-
this._removeRefreshCallback()
458+
this._removeRefreshCallback();
459+
this._removeRefreshCallback = null;
446460
}
461+
462+
this._popupElement = null;
463+
this._disposePopup = null;
447464
}
448465

449466
private _propagateChange: any = () => {

0 commit comments

Comments
 (0)