/electron-window-rotator

Rotate native Electron window on macOS

Primary LanguageObjective-C++MIT LicenseMIT

electron-window-rotator

Rotate native Electron window on macOS

npm npm GitHub license

Demo gif

Note: this is a silly proof-of-concept npm module that demonstrates using Nodejs N-API.

Read a blog post about it: https://antonfisher.com/posts/2020/12/27/how-to-animate-native-electron-window/

Usage

Install the module:

npm install electron-window-rotator

Rotate BrowserWindow every 3 seconds:

const Rotator = require('electron-window-rotator');
const mainWindow = new BrowserWindow({ ... });

setInterval(() => {
  Rotator.rotate(
    mainWindow,             // Electron's BrowserWindow instance
    1000,                   // animation duration [ms]
    Rotator.DIRECTION_LEFT  // rotation direction
  );
}, 3000);

Build and run demo locally

git clone https://github.com/antonfisher/electron-window-rotator.git
cd electron-window-rotator && npm install
cd demo && npm install && cd -
xcode-select --install
npm start

License

MIT License