1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-02-01 19:15:01 +02:00

Fix scrolling issue in Electron app

This commit is contained in:
Laurent Cozic 2018-02-04 18:45:52 +00:00
parent 29e9ccf216
commit 8b7f5b1151
2 changed files with 17 additions and 3 deletions

View File

@ -14,6 +14,8 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.3\n" "X-Generator: Poedit 2.0.3\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
msgid "Give focus to next pane" msgid "Give focus to next pane"
msgstr "Activer le volet suivant" msgstr "Activer le volet suivant"
@ -1243,7 +1245,7 @@ msgid "Configuration"
msgstr "Configuration" msgstr "Configuration"
msgid "Move to notebook..." msgid "Move to notebook..."
msgstr "Déplacer la note vers carnet..." msgstr "Déplacer vers..."
#, javascript-format #, javascript-format
msgid "Move %d notes to notebook \"%s\"?" msgid "Move %d notes to notebook \"%s\"?"

View File

@ -17,7 +17,7 @@
</style> </style>
</head> </head>
<body> <body id="body">
<div id="hlScriptContainer"></div> <div id="hlScriptContainer"></div>
<div id="content" ondragstart="return false;" ondrop="return false;"></div> <div id="content" ondragstart="return false;" ondrop="return false;"></div>
@ -25,7 +25,6 @@
const { ipcRenderer } = require('electron'); const { ipcRenderer } = require('electron');
const contentElement = document.getElementById('content'); const contentElement = document.getElementById('content');
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Handle dynamically loading HLJS when a code element is present // Handle dynamically loading HLJS when a code element is present
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -110,6 +109,8 @@
} }
ipcRenderer.on('setHtml', (event, html) => { ipcRenderer.on('setHtml', (event, html) => {
updateBodyHeight();
contentElement.innerHTML = html; contentElement.innerHTML = html;
loadAndApplyHljs(); loadAndApplyHljs();
@ -163,6 +164,11 @@
return Math.max(0, contentElement.scrollHeight - contentElement.clientHeight); 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) { contentElement.addEventListener('scroll', function(e) {
if (ignoreNextScrollEvent) { if (ignoreNextScrollEvent) {
ignoreNextScrollEvent = false; ignoreNextScrollEvent = false;
@ -187,6 +193,12 @@
document.addEventListener('dragover', function(e) { document.addEventListener('dragover', function(e) {
e.preventDefault(); e.preventDefault();
}); });
window.addEventListener('resize', function() {
updateBodyHeight();
});
updateBodyHeight();
</script> </script>
</body> </body>