最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用 electron 實現(xiàn)類似新版 QQ 的登錄界面效果(陰影、背景動畫、窗體3D翻轉(zhuǎn))

 更新時間:2018年10月23日 11:26:15   作者:Why not!  
這篇文章主要介紹了使用 electron 實現(xiàn)類似新版 QQ 的登錄界面效果(陰影、背景動畫、窗體3D翻轉(zhuǎn)),其實主要用到的就是 CSS3 的效果:邊框圓角、陰影,3D變換,實現(xiàn)代碼超級簡單,需要的朋友可以參考下

現(xiàn)在什么都講究追趕潮流,覺得 QQ 登錄窗口做的效果不錯,既然剛學(xué)習(xí) electron ,那么就用 electron 模仿一下。其實主要用到的就是 CSS3 的效果:邊框圓角、陰影,3D變換。對,就這么簡單。先上效果:

下面是關(guān)鍵代碼:

app.js

'use strict';
const { app, BrowserWindow } = require('electron')
const path = require('path')
const url = require('url')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
function createWindow() {
  // Create the browser window.
  win = new BrowserWindow({
    width: 495, height: 470, /*skipTaskbar: true,*/ frame: false,
    resizable: false, transparent: true, show: false, alwaysOnTop: true
  })
  win.once('ready-to-show', () => {
    win.show()
  })
  // and load the index.html of the app.
  win.loadURL(url.format({
    pathname: path.join(__dirname, '/app/index.html'),
    protocol: 'file:',
    slashes: true
  }))
  // Open the DevTools.
  //win.webContents.openDevTools()
  // Emitted when the window is closed.
  win.on('closed', () => {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    win = null
  })
}
//app.disableHardwareAcceleration();
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', () => {
  // On macOS it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform !== 'darwin') {
    app.quit()
  }
})
app.on('activate', () => {
  // On macOS it's common to re-create a window in the app when the
  // dock icon is clicked and there are no other windows open.
  if (win === null) {
    createWindow()
  }
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

index.html

<!DOCTYPE html>
<html style="margin:0; padding:0;height:100%;">
<head>
  <meta charset="UTF-8">
  <title>QQ Login</title>
  <style>
    html, body {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
    }

    body {
      perspective: 800px;
      -webkit-app-region: drag;
      -webkit-user-select: none;
    }

    input[type="submit"],
    input[type="reset"],
    input[type="button"],
    input[type="text"],
    button,
    textarea {
      -webkit-app-region: no-drag;
    }

    .shadow {
      box-shadow: 0 0 10px rgba(0, 0, 0, 1);
      position: absolute;
      width: 100%;
      height: 100%;
      border-radius: 4px;
    }

    #login-back {
      position: relative;
      border-radius: 3px 3px 0 0;
      left: 0;
      right: 0;
      height: 180px;
    }

    #card {
      left: 33px;
      top: 70px;
      right: 33px;
      bottom: 70px;
      background-color: #ebf2f9;
      position: absolute;
      -webkit-transition: -webkit-transform .6s ease-in-out;
      transition: transform .6s ease-in-out;
      -webkit-transform-style: preserve-3d;
      transform-style: preserve-3d;
      border-radius: 4px;
    }

      #card.flipped {
        -webkit-transform: rotateY( 180deg );
        transform: rotateY( 180deg );
      }

      #card .front {
        background: url(imgs/login-back.gif) no-repeat;
        background-size: 100% 180px;
        position: absolute;
        transform: rotateY(0deg);
      }

      #card .back {
        position: absolute;
        background: url(imgs/login-back.gif) no-repeat;
        background-size: 100% 180px;
        -webkit-transform: rotateY( -180deg );
        transform: rotateY( -180deg );
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        z-index:2;
      }

    .sys-control-box {
      float:right;
      width:84px;
      border-radius: 0 3px 0 0;
    }

    .sys-btn {
      width: 28px;
      height: 28px;
      border: none;
      outline: none;
      margin: 0;
    }

    .sys-btn-mini {
      background: url(imgs/btn_mini_normal.png) no-repeat;
    }

      .sys-btn-mini:hover {
        background: url(imgs/btn_mini_highlight.png) no-repeat;
      }

      .sys-btn-mini:active {
        background: url(imgs/btn_mini_down.png) no-repeat;
      }

    .sys-btn-close {
      border-radius: 0 3px 0 0;
      background: url(imgs/btn_close_normal.png) no-repeat;
    }

      .sys-btn-close:hover {
        background: url(imgs/btn_close_highlight.png) no-repeat;
      }

      .sys-btn-close:active {
        background: url(imgs/btn_close_down.png) no-repeat;
      }

    .sys-btn-set {
      background: url(imgs/btn_set_normal.png) 1px 0 no-repeat;
    }

      .sys-btn-set:hover {
        background: url(imgs/btn_set_hover.png) 1px 0 no-repeat;
      }

      .sys-btn-set:active {
        background: url(imgs/btn_set_press.png) 1px 0 no-repeat;
      }

    .btn {
      width: 78px;
      height: 28px;
      background: url(imgs/setting_btn_normal.png) no-repeat;
      background-size: 100% 100%;
      border: none;
      outline: none;
      margin: 0;
    }

      .btn:hover, .btn:active {
        background: url(imgs/setting_btn_hover.png) no-repeat;
        background-size: 100% 100%;
      }

      .btn:focus {
        background: url(imgs/setting_btn_hover.png) no-repeat;
        background-size: 100% 100%;
      }
  </style>
</head>
<body>
  <div id="card">
    <div id="front" class="front shadow">
      <div class="sys-control-box">
        <button id="btn-set" class="sys-btn sys-btn-set" title="設(shè)置"></button><button class="sys-btn sys-btn-mini" title="最小化"></button><button class="sys-btn sys-btn-close" title="關(guān)閉"></button>
      </div>
    </div>
    <div id="back" class="back shadow">
      <div style="width:100%;height:100%; border-radius: 4px;background:-webkit-linear-gradient(top, rgba(0, 0, 0, 0.00) 0%, rgba(0, 0, 0, 0.00) 6%, #ebf2f9 12%, #ebf2f9 90%, #cde2f2 90%, #cde2f2 100%);">
        <div class="sys-control-box" style="width:56px;">
          <button class="sys-btn sys-btn-mini" title="最小化"></button><button class="sys-btn sys-btn-close" title="關(guān)閉"></button>
        </div>
        <button id="btn-ok" style="position:absolute; right:91px; bottom:2px;" class="btn">確定</button>
        <button id="btn-cancel" style="position:absolute; right:10px; bottom:2px;" class="btn">取消</button>
      </div>
    </div>
  </div>
  <script>
    Element.prototype.hasClassName = function (a) {
      return new RegExp("(?:^|\\s+)" + a + "(?:\\s+|$)").test(this.className);
    };

    Element.prototype.addClassName = function (a) {
      if (!this.hasClassName(a)) {
        this.className = [this.className, a].join(" ");
      }
    };

    Element.prototype.removeClassName = function (b) {
      if (this.hasClassName(b)) {
        var a = this.className;
        this.className = a.replace(new RegExp("(?:^|\\s+)" + b + "(?:\\s+|$)", "g"), " ");
      }
    };

    Element.prototype.toggleClassName = function (a) {
      this[this.hasClassName(a) ? "removeClassName" : "addClassName"](a);
    };

    //var init = function () {
    //  var card = document.getElementById('card');

    //  document.getElementById('front').addEventListener('click', function () {
    //    card.toggleClassName('flipped');
    //  }, false);

    //  document.getElementById('back').addEventListener('click', function () {
    //    card.toggleClassName('flipped');
    //  }, false);
    //};

    //window.addEventListener('DOMContentLoaded', init, false);
    (function () {

      const remote = require('electron').remote;

      function init() {

        function flip() {
          if (frontShow == 2) {
            document.getElementById('front').style.display = 'block';
          }
          else {
            document.getElementById('back').style.display = 'block';
          }
          card.toggleClassName('flipped');
        };

        var btn_minis = document.getElementsByClassName("sys-btn-mini");
        for (var i = 0; i < btn_minis.length; i++) {
          btn_minis[i].addEventListener("click", function (e) {
            const window = remote.getCurrentWindow();
            window.minimize();
          });
        }

        //document.getElementById("sys-btn-maxi").addEventListener("click", function (e) {
        //  const window = remote.getCurrentWindow();
        //  if (!window.isMaximized()) {
        //    window.maximize();
        //  } else {
        //    window.unmaximize();
        //  }
        //});

        var btn_closes = document.getElementsByClassName("sys-btn-close");
        for (var i = 0; i < btn_closes.length; i++) {
          btn_closes[i].addEventListener("click", function (e) {
            const window = remote.getCurrentWindow();
            window.close();
          });
        }   

        var card = document.getElementById('card');
        var frontShow = 1;

        var btn_sets = document.getElementsByClassName("sys-btn-set");
        for (var i = 0; i < btn_sets.length; i++) {
          btn_sets[i].addEventListener('click', function () { flip(); }, false);
        } 

        card.addEventListener('transitionend', function () {
          if (frontShow == 1) {
            frontShow = 2;
            document.getElementById('front').style.display = 'none';
          }
          else {
            document.getElementById('back').style.display = 'none';
            frontShow = 1;
          }
        }, false);

        document.getElementById('btn-ok').addEventListener('click', function () { flip(); }, false);
        document.getElementById('btn-cancel').addEventListener('click', function () { flip(); }, false);
      };

      document.onreadystatechange = function () {
        if (document.readyState == "complete") {
          init();
        }
      };
    })();
  </script>
</body>
</html>

最后整個項目的源代碼:https://github.com/starts2000/ElectronQQLogin

總結(jié)

以上所述是小編給大家介紹的使用 electron 實現(xiàn)類似新版 QQ 的登錄界面效果(陰影、背景動畫、窗體3D翻轉(zhuǎn)),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

  • javascript遍歷json對象的key和任意js對象屬性實例

    javascript遍歷json對象的key和任意js對象屬性實例

    下面小編就為大家?guī)硪黄猨avascript遍歷json對象的key和任意js對象屬性實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-03-03
  • JavaScript中rxjs與?Observable?兩大類操作符解析

    JavaScript中rxjs與?Observable?兩大類操作符解析

    這篇文章主要介紹了JavaScript中rxjs與?Observable?兩大類操作符解析,運算符是對?Observable?進(jìn)行操作并返回?Observable?的函數(shù),文章圍繞主題展開詳細(xì)內(nèi)容,需要的小伙伴可以參考一下
    2022-07-07
  • 移動端手指放大縮小插件與js源碼

    移動端手指放大縮小插件與js源碼

    這篇文章主要介紹了移動端手指放大縮小插件與js源碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • 用js一次改變多個input的readonly屬性值的方法

    用js一次改變多個input的readonly屬性值的方法

    這篇文章主要介紹了用js一次改變多個input的readonly屬性值的方法,需要的朋友可以參考下
    2014-06-06
  • js轉(zhuǎn)換對象為xml

    js轉(zhuǎn)換對象為xml

    本文主要介紹了js轉(zhuǎn)換對象為xml的方法。具有很好的參考價值,下面跟著小編一起來看下吧
    2017-02-02
  • JavaScript隱式類型轉(zhuǎn)換

    JavaScript隱式類型轉(zhuǎn)換

    JavaScript的數(shù)據(jù)類型是非常弱的(不然不會叫它做弱類型語言了)!在使用算術(shù)運算符時,運算符兩邊的數(shù)據(jù)類型可以是任意的,比如,一個字符串可以和數(shù)字相加
    2016-03-03
  • javascript+xml技術(shù)實現(xiàn)分頁瀏覽

    javascript+xml技術(shù)實現(xiàn)分頁瀏覽

    基于web的技術(shù)中,分頁是一個老的不能再老的,但大家津津樂道的問題,隨著xml技術(shù)的日漸應(yīng)用,把xml應(yīng)用到分頁當(dāng)中,也是一種可能,當(dāng)然網(wǎng)上的教程很多,當(dāng)我都是看得稀里糊涂,索性自己寫一個,與大家分享、指正。
    2008-07-07
  • JavaScript執(zhí)行效率與性能提升方案

    JavaScript執(zhí)行效率與性能提升方案

    如何提升JavaScript執(zhí)行效率與性能在前端開發(fā)中位于一個很重要的地方,這節(jié)來研究下如何在平時做項目過程中,提升JavaScript性能與運行效率,需要的朋友可以參考下
    2012-12-12
  • js獲取和設(shè)置屬性的方法

    js獲取和設(shè)置屬性的方法

    本篇文章主要是對js獲取和設(shè)置屬性的方法進(jìn)行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助
    2014-02-02
  • JavaScript實現(xiàn)拼音排序的方法

    JavaScript實現(xiàn)拼音排序的方法

    本文將介紹JavaScript如何實現(xiàn)拼音排序 支持所有主流瀏覽器+中英文系統(tǒng)
    2012-11-11

最新評論

襄汾县| 永安市| 巢湖市| 邢台县| 开封市| 光泽县| 玛纳斯县| 永川市| 安图县| 江华| 邳州市| 防城港市| 台中县| 桃园市| 乌什县| 崇仁县| 呈贡县| 潢川县| 天柱县| 永州市| 宣化县| 仁寿县| 原阳县| 衡水市| 山阳县| 扎囊县| 宁海县| 会宁县| 苍梧县| 平罗县| 蒙阴县| 黄大仙区| 东山县| 仁寿县| 五峰| 锡林郭勒盟| 遵义市| 海淀区| 黑山县| 旌德县| 沅江市|