Skip to content

Commit

Permalink
Remove now-native setWindowBounds functionality (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere authored and sindresorhus committed Jun 6, 2019
1 parent e7b9fe0 commit 88ac9fe
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 42 deletions.
24 changes: 0 additions & 24 deletions index.d.ts
Expand Up @@ -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.
Expand Down
12 changes: 1 addition & 11 deletions index.js
Expand Up @@ -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(),
Expand All @@ -120,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()) => {
Expand Down
2 changes: 0 additions & 2 deletions index.test-d.ts
Expand Up @@ -12,7 +12,6 @@ import {
enforceMacOSAppLocation,
menuBarHeight,
getWindowBoundsCentered,
setWindowBounds,
centerWindow,
disableZoom,
appLaunchTimestamp,
Expand Down Expand Up @@ -47,7 +46,6 @@ expectType<string>(fixPathForAsarUnpack('/path'));
expectType<void>(enforceMacOSAppLocation());
expectType<number>(menuBarHeight());
expectType<Rectangle>(getWindowBoundsCentered());
expectType<void>(setWindowBounds({width: 1920, height: 1080}));
expectType<void>(centerWindow({}));
expectType<void>(disableZoom());
expectType<number>(appLaunchTimestamp);
Expand Down
5 changes: 0 additions & 5 deletions readme.md
Expand Up @@ -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)
Expand Down Expand Up @@ -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`
Expand Down

0 comments on commit 88ac9fe

Please sign in to comment.