Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove now-native setWindowBounds functionality #15

Merged
merged 2 commits into from Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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