diff --git a/spec/window-event-handler-spec.js b/spec/window-event-handler-spec.js index a03e168fa..2891aa2db 100644 --- a/spec/window-event-handler-spec.js +++ b/spec/window-event-handler-spec.js @@ -44,7 +44,15 @@ describe('WindowEventHandler', () => { }) ) }) - + + describe('resize event', () => + it('calls storeWindowDimensions', () => { + spyOn(atom, 'storeWindowDimensions') + window.dispatchEvent(new CustomEvent('resize')) + expect(atom.storeWindowDimensions).toHaveBeenCalled() + }) + ) + describe('window:close event', () => it('closes the window', () => { spyOn(atom, 'close') diff --git a/src/window-event-handler.js b/src/window-event-handler.js index 6d380819b..da735294e 100644 --- a/src/window-event-handler.js +++ b/src/window-event-handler.js @@ -9,6 +9,7 @@ class WindowEventHandler { this.handleFocusNext = this.handleFocusNext.bind(this) this.handleFocusPrevious = this.handleFocusPrevious.bind(this) this.handleWindowBlur = this.handleWindowBlur.bind(this) + this.handleWindowResize = this.handleWindowResize.bind(this) this.handleEnterFullScreen = this.handleEnterFullScreen.bind(this) this.handleLeaveFullScreen = this.handleLeaveFullScreen.bind(this) this.handleWindowBeforeunload = this.handleWindowBeforeunload.bind(this) @@ -51,6 +52,7 @@ class WindowEventHandler { this.addEventListener(this.window, 'beforeunload', this.handleWindowBeforeunload) this.addEventListener(this.window, 'focus', this.handleWindowFocus) this.addEventListener(this.window, 'blur', this.handleWindowBlur) + this.addEventListener(this.window, 'resize', this.handleWindowResize) this.addEventListener(this.document, 'keyup', this.handleDocumentKeyEvent) this.addEventListener(this.document, 'keydown', this.handleDocumentKeyEvent) @@ -189,6 +191,10 @@ class WindowEventHandler { this.atomEnvironment.storeWindowDimensions() } + handleWindowResize () { + this.atomEnvironment.storeWindowDimensions() + } + handleEnterFullScreen () { this.document.body.classList.add('fullscreen') }