26 lines
793 B
TypeScript
26 lines
793 B
TypeScript
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'iqser-hidden-action',
|
|
templateUrl: './hidden-action.component.html',
|
|
styleUrls: ['./hidden-action.component.scss']
|
|
})
|
|
export class HiddenActionComponent {
|
|
@Input() requiredClicks = 4;
|
|
@Output() readonly action = new EventEmitter();
|
|
private _clickCount = 0;
|
|
private _clickCountTimeout?: ReturnType<typeof setTimeout>;
|
|
|
|
countActions(): void {
|
|
this._clickCount += 1;
|
|
if (this._clickCount === this.requiredClicks) {
|
|
this._clickCount = 0;
|
|
this.action.emit();
|
|
}
|
|
clearTimeout(this._clickCountTimeout);
|
|
this._clickCountTimeout = setTimeout(() => {
|
|
this._clickCount = 0;
|
|
}, 1000);
|
|
}
|
|
}
|