const visible = (element) => {
let bounds = element.getBoundingClientRect();
- return bounds.top >= 0 && bounds.bottom <= window.innerHeight;
+ return Math.abs(bounds.bottom - bounds.top) > window.innerHeight || (bounds.top >= 0 && bounds.bottom <= window.innerHeight);
}
const changeWithVisibleCallback = (comment, callback) => {
// Curry callback for moving downpage
const changeDownpage = () => {
- elementsIndex = Math.min(elementsIndex + 1, elements.length);
+ elementsIndex = Math.min(elementsIndex + 1, elements.length - 1);
changeWithVisibleCallback(elements[elementsIndex], () => {window.scrollTo(0, window.scrollY + selectedElement.offsetHeight)});
}
change(e.target.closest("tr.athing"));
})
document.addEventListener("keydown", (e) => {
- if (e.isComposing) {
+ if (e.target.type === 'textarea' || e.isComposing) {
return;
}
switch (e.key) {