From 8b7f5b1151d431a6cfabe91165b10ce392a10a0a Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 4 Feb 2018 18:45:52 +0000 Subject: [PATCH] Fix scrolling issue in Electron app --- CliClient/locales/fr_FR.po | 4 +++- ElectronClient/app/gui/note-viewer/index.html | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CliClient/locales/fr_FR.po b/CliClient/locales/fr_FR.po index 01463b890..fb04867ed 100644 --- a/CliClient/locales/fr_FR.po +++ b/CliClient/locales/fr_FR.po @@ -14,6 +14,8 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 2.0.3\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" msgid "Give focus to next pane" msgstr "Activer le volet suivant" @@ -1243,7 +1245,7 @@ msgid "Configuration" msgstr "Configuration" msgid "Move to notebook..." -msgstr "Déplacer la note vers carnet..." +msgstr "Déplacer vers..." #, javascript-format msgid "Move %d notes to notebook \"%s\"?" diff --git a/ElectronClient/app/gui/note-viewer/index.html b/ElectronClient/app/gui/note-viewer/index.html index f9f34cb12..5d5213e3e 100644 --- a/ElectronClient/app/gui/note-viewer/index.html +++ b/ElectronClient/app/gui/note-viewer/index.html @@ -17,7 +17,7 @@ - +
@@ -25,7 +25,6 @@ const { ipcRenderer } = require('electron'); const contentElement = document.getElementById('content'); - // ---------------------------------------------------------------------- // Handle dynamically loading HLJS when a code element is present // ---------------------------------------------------------------------- @@ -110,6 +109,8 @@ } ipcRenderer.on('setHtml', (event, html) => { + updateBodyHeight(); + contentElement.innerHTML = html; loadAndApplyHljs(); @@ -163,6 +164,11 @@ return Math.max(0, contentElement.scrollHeight - contentElement.clientHeight); } + // The body element needs to have a fixed height for the content to be scrollable + function updateBodyHeight() { + document.getElementById('body').style.height = window.innerHeight + 'px'; + } + contentElement.addEventListener('scroll', function(e) { if (ignoreNextScrollEvent) { ignoreNextScrollEvent = false; @@ -187,6 +193,12 @@ document.addEventListener('dragover', function(e) { e.preventDefault(); }); + + window.addEventListener('resize', function() { + updateBodyHeight(); + }); + + updateBodyHeight();