Skip to content

Commit f73948a

Browse files
Kon Hondrosmatheuss
authored andcommitted
Fix the slide behaviour when the controls are closing (#149)
* 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
1 parent a51dd53 commit f73948a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

app/src/main/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ ipcMain.on('set-main-window-size', (event, args) => {
4343
if (args.width && args.height && mainWindow) {
4444
[args.width, args.height] = [parseInt(args.width, 10), parseInt(args.height, 10)];
4545
mainWindow.setSize(args.width, args.height, true); // true == animate
46+
event.returnValue = true; // Give true to sendSync caller
4647
}
4748
});
4849

app/src/renderer/js/main.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ function setMainWindowSize() {
2727
ipcRenderer.send('set-main-window-size', {width, height});
2828
}
2929

30+
function setStrictWindowSize(width, height, callback) {
31+
if (ipcRenderer.sendSync('set-main-window-size', {width, height})) {
32+
callback();
33+
}
34+
}
35+
3036
document.addEventListener('DOMContentLoaded', () => {
3137
// Element definitions
3238
const aspectRatioSelector = document.querySelector('.aspect-ratio-selector');
@@ -305,14 +311,23 @@ document.addEventListener('DOMContentLoaded', () => {
305311

306312
triangle.classList.toggle('up');
307313

308-
controls.classList.toggle('hidden');
314+
if (controls.classList.contains('hidden')) {
315+
controls.classList.remove('hidden');
316+
setMainWindowSize();
317+
} else {
318+
const w = document.documentElement.scrollWidth;
319+
const h = document.documentElement.scrollHeight - controls.scrollHeight - 1;
320+
321+
setStrictWindowSize(w, h, () => {
322+
controls.classList.add('hidden');
323+
});
324+
}
309325

310326
if (!initializedActiveShim && !controls.classList.contains('hidden')) {
311327
handleActiveButtonGroup({buttonGroup: exportAs[0].parentNode});
312328
initializedActiveShim = true;
329+
setMainWindowSize();
313330
}
314-
315-
setMainWindowSize();
316331
};
317332

318333
options.onclick = event => {

0 commit comments

Comments
 (0)