From 36529a46fd52d8924923027c79afe44cd810861e Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Sat, 10 Sep 2022 18:09:46 +0200 Subject: xP: also scroll to bottom on window resize --- xP/public/xP.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'xP/public') 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 -- cgit v1.2.3-70-g09d2