Skip to content

Commit

Permalink
Fix the slide behaviour when the controls are closing (wulkano#149)
Browse files Browse the repository at this point in the history
* Fix the slide behaviour when the controls are closing

* Remove console.log

* Remove setTimeout approach

and replace with ipcRenderer.sendSync to take the finish of the transition syncronously, combined with a callback to add "hidden" class to "controls-content" div
  • Loading branch information
Kon Hondros authored and matheuss committed Feb 23, 2017
1 parent a51dd53 commit f73948a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ipcMain.on('set-main-window-size', (event, args) => {
if (args.width && args.height && mainWindow) {
[args.width, args.height] = [parseInt(args.width, 10), parseInt(args.height, 10)];
mainWindow.setSize(args.width, args.height, true); // true == animate
event.returnValue = true; // Give true to sendSync caller
}
});

Expand Down
21 changes: 18 additions & 3 deletions app/src/renderer/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ function setMainWindowSize() {
ipcRenderer.send('set-main-window-size', {width, height});
}

function setStrictWindowSize(width, height, callback) {
if (ipcRenderer.sendSync('set-main-window-size', {width, height})) {
callback();
}
}

document.addEventListener('DOMContentLoaded', () => {
// Element definitions
const aspectRatioSelector = document.querySelector('.aspect-ratio-selector');
Expand Down Expand Up @@ -305,14 +311,23 @@ document.addEventListener('DOMContentLoaded', () => {

triangle.classList.toggle('up');

controls.classList.toggle('hidden');
if (controls.classList.contains('hidden')) {
controls.classList.remove('hidden');
setMainWindowSize();
} else {
const w = document.documentElement.scrollWidth;
const h = document.documentElement.scrollHeight - controls.scrollHeight - 1;

setStrictWindowSize(w, h, () => {
controls.classList.add('hidden');
});
}

if (!initializedActiveShim && !controls.classList.contains('hidden')) {
handleActiveButtonGroup({buttonGroup: exportAs[0].parentNode});
initializedActiveShim = true;
setMainWindowSize();
}

setMainWindowSize();
};

options.onclick = event => {
Expand Down

0 comments on commit f73948a

Please sign in to comment.