Have ideas to improve npm?Join in the discussion! »

    electron-aspect-ratio-browser-window
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.2 • Public • Published

    electron-aspect-ratio-browser-window

    npm version Conventional Commits

    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. 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:

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

    Usage:

    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:

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

    Features:

    Thanks:

    This module was inspired by two responses on the original issue:

    Install

    npm i electron-aspect-ratio-browser-window

    DownloadsWeekly Downloads

    61

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    7.96 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar