Issues when we go from fullscreen to windowed mode by pressing the escape key on the keyboard, rather than fullscreen button present on the image-viewer.
Because in your toggleFullscreen() method it just reverses the value of 'fullscreen' value. So when we press escape key in fullscreen mode, it takes us to windowed mode but the value of fullscreen value stays the same(since toggleFullscreen() wasn't invoked), and hence it takes 2 clicks on the fullscreen button to take to fullscreen again.
Escape key event is not fired in fullscreen mode. So gotta find some other way around.
I personally used @HostListener('fullscreenchange', ['$event']) to fix the issue in my code.
Issues when we go from fullscreen to windowed mode by pressing the escape key on the keyboard, rather than fullscreen button present on the image-viewer. Because in your toggleFullscreen() method it just reverses the value of 'fullscreen' value. So when we press escape key in fullscreen mode, it takes us to windowed mode but the value of fullscreen value stays the same(since toggleFullscreen() wasn't invoked), and hence it takes 2 clicks on the fullscreen button to take to fullscreen again.