Skip to content

Commit 3f6a722

Browse files
committed
Before unload handler
1 parent 97bfd1c commit 3f6a722

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/app/containers/angular-tetris/angular-tetris.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ export class AngularTetrisComponent implements OnInit {
7171
this[`keyUp${key}`]();
7272
}
7373

74+
@HostListener('window:beforeunload', ['$event'])
75+
unloadHandler(event: Event) {
76+
if (!!this._tetrisQuery.current) {
77+
event.preventDefault();
78+
event.returnValue = true;
79+
}
80+
}
81+
7482
@HostListener(`${KeyDown}.${TetrisKeyboard.Left}`)
7583
keyDownLeft() {
7684
this._soundManager.move();

0 commit comments

Comments
 (0)