From 36529a46fd52d8924923027c79afe44cd810861e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?=
Date: Sat, 10 Sep 2022 18:09:46 +0200 Subject: [PATCH] xP: also scroll to bottom on window resize --- xP/public/xP.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xP/public/xP.js b/xP/public/xP.js index 7f64473..864323a 100644 --- a/xP/public/xP.js +++ b/xP/public/xP.js @@ -438,20 +438,28 @@ let Content = { } let Buffer = { - oncreate: vnode => { - if (vnode.dom !== undefined && bufferAutoscroll) - vnode.dom.scrollTop = vnode.dom.scrollHeight + controller: new AbortController(), + + onbeforeremove: vnode => { + Buffer.controller.abort() }, onupdate: vnode => { - Buffer.oncreate(vnode) + if (bufferAutoscroll) + vnode.dom.scrollTop = vnode.dom.scrollHeight + }, + + oncreate: vnode => { + Buffer.onupdate(vnode) + window.addEventListener('resize', event => Buffer.onupdate(vnode), + {signal: Buffer.controller.signal}) }, view: vnode => { let lines = [] let b = buffers.get(bufferCurrent) if (b === undefined) - return + return m('.buffer') let lastDateMark = undefined let markBefore = b.lines.length