Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Commit

Permalink
Scroll position now saved
Browse files Browse the repository at this point in the history
  • Loading branch information
Dotnaught committed Jul 11, 2019
1 parent 7557ce8 commit 66119db
Show file tree
Hide file tree
Showing 5 changed files with 499 additions and 550 deletions.
13 changes: 13 additions & 0 deletions js/mainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function toggleProgressBar(bstate) {

//do this when the window has loaded
window.onload = () => {
console.log("OnLoad");
toggleProgressBar("indeterminate");
let hours = remote.getGlobal("timeWindow").minutes / 60;
setter(hours);
Expand Down Expand Up @@ -185,6 +186,18 @@ ipcRenderer.on("stop", function() {
toggleProgressBar("determinate");
});

ipcRenderer.on("blur", function() {
console.log("blur handler");
let scrollPosition = window.scrollY;
config.set("scrollPosition", scrollPosition);
});

ipcRenderer.on("focus", function() {
let y = config.get("scrollPosition", 0);
window.scrollTo(0, y);
console.log("focus handler", y);
});

ipcRenderer.on("update", function(e, text) {
console.log(text);
document.getElementById("query").placeholder = text;
Expand Down
9 changes: 9 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ app.on("ready", function() {
nodeIntegration: true
}
});

mainWindow.on("focus", () => {
console.log("Restore tab position");
mainWindow.webContents.send("focus");
});
mainWindow.on("blur", () => {
console.log("Save tab position");
mainWindow.webContents.send("blur");
});
//load html
mainWindow.loadURL(
url.format({
Expand Down
Loading

0 comments on commit 66119db

Please sign in to comment.