Can't succeed in making transparent window in Electron (javascript)

后端 未结 4 2052
失恋的感觉
失恋的感觉 2020-12-18 22:06

I am trying to make a transparent window with ElectronJs but I obtain a black background.

I am on Linux (Debian Jessie)

I have tried different versions : lat

4条回答
  •  误落风尘
    2020-12-18 22:58

    It's a very old regression bug in Electron project.

    See https://github.com/electron/electron/issues/15947

    To bypass that problem, just downgrade to 1.4.16 2.0.16, the last working version.


    EDIT 1 : if you wait at least 300ms after ready event to open windows it will work correctly

    app.on('ready', () => setTimeout(onAppReady, 300));
    

    And you do not need --disable-gpu option in your package.json

    "start": "electron --enable-transparent-visuals ."
    

    EDIT 2 : To make it works out of the box, use this repo : https://gitlab.com/doom-fr/electron-transparency-demo

    git clone https://gitlab.com/doom-fr/electron-transparency-demo
    cd electron-transparency-demo
    npm install
    npm start
    # or npm run startWithTransparentOption
    # or npm run startWithAllOptions
    

    for me works with npm start and npm run startWithTransparentOption


    EDIT 3 : Please have a look also to @Thalinda Bandara answer below : It might be interresting (not tested but already seen it elsewhere).

提交回复
热议问题