# electron-aspect-ratio-browser-window

> Drop-in replacement for Electron's BrowserWindow with working aspect ratio on Windows

Latest version **1.0.2** (published 2020-07-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install electron-aspect-ratio-browser-window
pnpm add electron-aspect-ratio-browser-window
yarn add electron-aspect-ratio-browser-window
bun add electron-aspect-ratio-browser-window
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-07-18 |
| First published | 2020-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Anton Fisher |
| Maintainers | afschr |
| Keywords | electron, BrowserWindow, windows, win32, aspect ratio |

## Links

- npm: https://www.npmjs.com/package/electron-aspect-ratio-browser-window
- Repository: https://github.com/antonfisher/electron-aspect-ratio-browser-window
- Homepage: https://github.com/antonfisher/electron-aspect-ratio-browser-window#readme
- Issues: https://github.com/antonfisher/electron-aspect-ratio-browser-window/issues
- npm.io page: https://npm.io/package/electron-aspect-ratio-browser-window

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-07-18
- 1.0.1 — 2020-07-09
- 1.0.0 — 2020-07-09
- 0.0.1 — 2020-07-09

## README

# electron-aspect-ratio-browser-window

[![npm version](https://img.shields.io/npm/v/electron-aspect-ratio-browser-window.svg?colorB=brightgreen)](https://www.npmjs.com/package/electron-aspect-ratio-browser-window)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)

Drop-in replacement for Electron's BrowserWindow with working aspect ratio on
Windows.

The module addresses this Electron issue:
https://github.com/electron/electron/issues/8036.

> **Warning**: this package extends BrowserWindow, that approach doesn't work
  properly with some Electron API,
  [more here](https://github.com/electron/electron/issues/23#issuecomment-1961324).
  Underline code can still be used to implement custom Window class that
  doesn't extend BrowserWindow but keeps reference to it (idea for next version
  of this library!)

## Installation:

```bash
npm install --save electron-aspect-ratio-browser-window
```

## Usage:

```js
const AspectRatioBrowserWindow = require('electron-aspect-ratio-browser-window');

// AspectRatioBrowserWindow instead of BrowserWindow:
const mainWindow = new AspectRatioBrowserWindow({
  width: 800,
  height: 450
});

// Aspect ratio works on Windows, Linux, and Mac:
mainWindow.setAspectRatio(16 / 9);
```

## Try example:

```bash
git clone https://github.com/antonfisher/electron-aspect-ratio-browser-window.git
cd electron-aspect-ratio-browser-window/example
npm install
npm start
```

## Features:

- utilizes Winuser.h resize hook: https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-sizing
- supports different screen scales: 100-125-150% setting on Windows.

## Thanks:

This module was inspired by two responses on the original issue:
- https://github.com/electron/electron/issues/8036#issuecomment-648642719 by [@asc0910](https://github.com/asc0910)
- https://github.com/electron/electron/issues/8036#issuecomment-649161348 by [@swimauger](https://github.com/swimauger)

---
_Source: https://npm.io/package/electron-aspect-ratio-browser-window · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
