From ae55628076b82c2ea78b4ab96409823d66c4f092 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 5 Jun 2019 20:56:42 -0700 Subject: [PATCH 1/2] Remove now-native setWindowBounds functionality --- index.js | 10 ---------- readme.md | 5 ----- 2 files changed, 15 deletions(-) diff --git a/index.js b/index.js index 1735b06..327c2a7 100644 --- a/index.js +++ b/index.js @@ -102,16 +102,6 @@ exports.getWindowBoundsCentered = options => { }; }; -exports.setWindowBounds = (bounds, options) => { - options = { - window: activeWindow(), - animated: false, - ...options - }; - - options.window.setBounds(bounds, options.animated); -}; - exports.centerWindow = options => { options = { window: activeWindow(), diff --git a/readme.md b/readme.md index 81022b4..c77a9b6 100644 --- a/readme.md +++ b/readme.md @@ -39,7 +39,6 @@ console.log(is.macos && is.main); - [`enforceMacOSAppLocation()`](#enforcemacosapplocation-macos) - [`menuBarHeight()`](#menubarheight-macos) - [`getWindowBoundsCentered()`](#getwindowboundscenteredoptions) -- [`setWindowBounds()`](#setwindowboundsbounds-options) - [`centerWindow()`](#centerwindowoptions) - [`disableZoom()`](#disablezoomwindow) - [`appLaunchTimestamp`](#applaunchtimestamp) @@ -186,10 +185,6 @@ Default: Size of `window` Set a new window size. Example: `{width: 600, height: 400}` -### setWindowBounds(bounds, [options]) - -Set the bounds of a window. This is similar to the [`BrowserWindow#setBounds()`](https://electronjs.org/docs/api/browser-window#winsetboundsbounds-animate) method, but it allows setting any of the `x`, `y`, `width`, `height` properties, instead of forcing you to set them all at once. The properties that are not set will just fall back to the current ones. - #### options Type: `object` From 98d227d28971308cffe6a9743546815c6ca97830 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 6 Jun 2019 07:57:43 -0700 Subject: [PATCH 2/2] Update TS defs and centerWindow --- index.d.ts | 24 ------------------------ index.js | 2 +- index.test-d.ts | 2 -- 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/index.d.ts b/index.d.ts index f3a6034..f73fc07 100644 --- a/index.d.ts +++ b/index.d.ts @@ -212,30 +212,6 @@ export interface OptionalRectangle { readonly y?: number; } -export interface SetWindowBoundsOptions { - /** - The window to set the bounds of. - - Default: Current window - */ - readonly window?: BrowserWindow; - - /** - Animate the change. - - @default false - */ - readonly animated?: boolean; -} - -/** -Set the bounds of a window. This is similar to the [`BrowserWindow#setBounds()`](https://electronjs.org/docs/api/browser-window#winsetboundsbounds-animate) method, but it allows setting any of the `x`, `y`, `width`, `height` properties, instead of forcing you to set them all at once. -The properties that are not set will just fall back to the current ones. - -@param bounds - New window bounds. -*/ -export function setWindowBounds(bounds: OptionalRectangle, options?: SetWindowBoundsOptions): void; - export interface CenterWindowOptions { /** The window to center. diff --git a/index.js b/index.js index 327c2a7..e9b7534 100644 --- a/index.js +++ b/index.js @@ -110,7 +110,7 @@ exports.centerWindow = options => { }; const bounds = exports.getWindowBoundsCentered(options); - exports.setWindowBounds(bounds, options); + options.window.setBounds(bounds, options.animated); }; exports.disableZoom = (win = activeWindow()) => { diff --git a/index.test-d.ts b/index.test-d.ts index ac1566c..5ebb484 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -12,7 +12,6 @@ import { enforceMacOSAppLocation, menuBarHeight, getWindowBoundsCentered, - setWindowBounds, centerWindow, disableZoom, appLaunchTimestamp, @@ -47,7 +46,6 @@ expectType(fixPathForAsarUnpack('/path')); expectType(enforceMacOSAppLocation()); expectType(menuBarHeight()); expectType(getWindowBoundsCentered()); -expectType(setWindowBounds({width: 1920, height: 1080})); expectType(centerWindow({})); expectType(disableZoom()); expectType(appLaunchTimestamp);