From: riqo Date: Fri, 30 Oct 2020 00:43:56 +0000 (-0500) Subject: gotta implement scroll offset X-Git-Tag: v0.9~143^2~1^2~3 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=67573031372300791bf1bed54b1844ce7d150d5e;p=mime-chat gotta implement scroll offset --- diff --git a/src/components/UI/index.vue b/src/components/UI/index.vue index 5461974..233af79 100644 --- a/src/components/UI/index.vue +++ b/src/components/UI/index.vue @@ -40,8 +40,7 @@ { messenger = document.getElementById("messenger"); winW = messenger.clientWidth; }); - function getCardHeight(el: SVGSVGElement) { + function getCardHeight(el: any) { const cardHeight = el.getBBox().height; return cardHeight; } - async function getAllCardsHeight() { - let cards: []; - cardsDiv = await document.getElementById("cardsDiv"); - cards = cardsDiv.querySelectorAll(".message"); - let totalHeight = 0; - for (const card of cards) { - let height = getCardHeight(card); - totalHeight += height; - if (totalHeight >= 500) { - console.log("update scroll view"); + function calculateAllCardsHeight() { + const cards = document.querySelectorAll(".test"); + if (cards.length) { + renderList = cards; + currentCard = cards.item(cards.length - 1); + for (const card of cards) { + const height = getCardHeight(card); + totalHeight += height; } } } async function beforeEnter(el: SVGGElement) { modifier = el.className.baseVal.substring(0, 2); + calculateAllCardsHeight(); } - async function enter(el: SVGGElement, done: any) { - getAllCardsHeight(); + async function stackAnimate(el: any, done: any) { const paddingLeft = 40; msg = await document.getElementById(el.id); const rect = msg.getBoundingClientRect(); const msgW = rect.width; const msgH = rect.height; - cardsDiv = await document.getElementById("cardsDiv"); + cardsDiv = document.getElementById("cardsDiv"); const cdBox = cardsDiv.getBBox(); if (prevCardH === 0) { @@ -90,6 +90,29 @@ export default function useUIindexAnims() { offset: 1000 }); done; + + } + + function OffsetMessage() { + // TODO implement individual offset function + + } + + function scrollOffset(l: NodeList) { + } + + async function scrollAnimate(el: any, done: any) { + // get incoming card height + const height = getCardHeight(el); + scrollOffset(renderList) + } + + async function enter(el: SVGGElement, done: any) { + if (totalHeight < 500) { + stackAnimate(el, done) + } else { + scrollAnimate(el, done); + } } return { beforeEnter,