Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private emit(type: DeckdeckgoEventType, e: any) {
this.communicationService.emit({
type: type,
emitter: DeckdeckgoEventEmitter.APP,
action: this.action,
clientX: unifyEvent(e).clientX - this.widthOffset,
clientY: unifyEvent(e).clientY - this.heightOffset,
windowWidth: this.width,
windowHeight: this.height,
color: this.color
});
}
private startEvent = (e: MouseEvent) => {
this.emit(DeckdeckgoEventType.START_DRAWING, e);
this.startX = unifyEvent(e).clientX - this.deckLeftOffset - this.widthOffset;
this.startY = unifyEvent(e).clientY - this.heightOffset;
if (this.action === DeckdeckgoDrawAction.CIRCLE) {
this.drawables.push(new Circle({x: this.startX, y: this.startY}, {
x: this.startX,
y: this.startY
}, this.color))
}
this.drawEvents = true;
};
private emit(type: DeckdeckgoEventType, e: any) {
this.communicationService.emit({
type: type,
emitter: DeckdeckgoEventEmitter.APP,
action: this.action,
clientX: unifyEvent(e).clientX - this.widthOffset,
clientY: unifyEvent(e).clientY - this.heightOffset,
windowWidth: this.width,
windowHeight: this.height,
color: this.color
});
}
return new Promise((resolve) => {
if (!this.startX) {
resolve(null);
return;
}
const slider: HTMLElement = this.el.shadowRoot.querySelector('div.deckgo-deck');
if (!slider) {
resolve(null);
return;
}
const currentX: number = unifyEvent(e).clientX;
if (this.startX === currentX) {
resolve(null);
return;
}
const swipeLeft: boolean = this.startX > currentX;
resolve({
slider: slider,
swipeLeft: swipeLeft,
deltaX: swipeLeft ? (this.startX - currentX) : (currentX - this.startX)
})
});
}
private endEvent = ($event: MouseEvent) => {
if (!this.startY || this.startY === undefined) {
return;
}
$event.preventDefault();
const toY: number = unifyEvent($event).clientY;
if (this.startY > toY) {
this.bottomSheetTop = this.bottomSheetTop <= this.bottomSheetMinHeight ? this.heightOffset : (this.bottomSheetTop + this.heightOffset >= this.content.offsetHeight ? this.content.offsetHeight : (this.bottomSheetTop + this.heightOffset));
} else {
this.bottomSheetTop = this.bottomSheetMinHeight;
}
this.startY = undefined;
};
private start(e: Event) {
this.startX = unifyEvent(e).clientX;
}
private startEvent = ($event: MouseEvent | TouchEvent) => {
$event.preventDefault();
this.startY = unifyEvent($event).clientY;
};