javascript - smoothstate 阻止其他 javascript 运行(电子)
问题描述
基本上我有一个电子应用程序,我在加载按钮工作时添加了最小化/关闭按钮,但是在使用平滑状态切换页面后它们停止工作我找到了各种解决方案(github 常见问题解答,stackoverlow 等),但到目前为止没有一个工作
按钮 html
<div id="title-bar-btns">
<button class="btn btn-outline" id="min-btn">—</button>
<button class="btn btn-outline" id="close-btn">X</button>
</div>
main.js
$(function() {
'use strict';
var $page = $('#main'),
options = {
debug: !0,
prefetch: !0,
cacheLength: 4,
onStart: {
duration: 350,
render: function($container) {
$container.addClass('is-exiting');
smoothState.restartCSSAnimations()
}
},
onReady: {
duration: 0,
render: function($container, $newContent) {
$container.removeClass('is-exiting');
$container.html($newContent)
initfunction();
}
},
onAfter: function($container, $newContent) {
initfunction();
}
},
smoothState = $page.smoothState(options).data('smoothState')
});
$(document).ready(function() {
initfunction();
});
function initfunction() {
(function() {
const {
BrowserWindow
} = require('electron').remote
function init() {
document.getElementById("min-btn").addEventListener("click", (e) => {
var window = BrowserWindow.getFocusedWindow();
window.minimize()
});
document.getElementById("close-btn").addEventListener("click", (e) => {
var window = BrowserWindow.getFocusedWindow();
window.close()
})
};
document.onreadystatechange = () => {
if (document.readyState == "complete") {
init()
}
}
})()
}
解决方案
推荐阅读
- android - Drupal 7.59 图像无法在 Android 应用程序中下载
- postgresql - postgreSQL 复制不同步
- php - php:@fopen 在 localhost 中有效,但在实时服务器中无效
- domain-driven-design - 聚合根设计一对多有序项
- sublimetext3 - 在 Sublime Text3 中,访问界面右上角的快捷方式是什么?
- tilde - 为什么在数字前使用〜符号?
- python - 使用 Scikit-Learn 的管道来组合转换器和估计器
- c++ - 如何使用 C/C++ 和 system() 系统调用以外的其他方法在 Linux 中获取文件功能?
- r - 错误:`x` 必须是字符串或 R 连接
- scala - 如何在scala play2.6 slick中将Select Statemnt数据存储到var