From aab6a479b46c7ead6ebc899e958976ad4902f45d Mon Sep 17 00:00:00 2001 From: riqo Date: Tue, 27 Oct 2020 12:21:06 -0500 Subject: [PATCH] add allCardHeight function --- src/components/UI/index.vue | 1 + src/composables/anims/useUIindexAnims.ts | 25 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/components/UI/index.vue b/src/components/UI/index.vue index 808d489..5461974 100644 --- a/src/components/UI/index.vue +++ b/src/components/UI/index.vue @@ -40,6 +40,7 @@ diff --git a/src/composables/anims/useUIindexAnims.ts b/src/composables/anims/useUIindexAnims.ts index 1cd3b92..df91efb 100644 --- a/src/composables/anims/useUIindexAnims.ts +++ b/src/composables/anims/useUIindexAnims.ts @@ -1,5 +1,6 @@ import { inject, onMounted } from "vue"; export default function useUIindexAnims() { + interface Done {} const anime: any = inject("animejs"); const timeline = anime.timeline({ loop: true }); const msgOffset = { @@ -18,12 +19,31 @@ export default function useUIindexAnims() { winW = messenger.clientWidth; }); - async function beforeEnter(el: any) { + function getCardHeight(el: SVGSVGElement) { + 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"); + } + } + } + + async function beforeEnter(el: SVGGElement) { modifier = el.className.baseVal.substring(0, 2); } async function enter(el: SVGGElement, done: any) { - console.log(done); + getAllCardsHeight(); const paddingLeft = 40; msg = await document.getElementById(el.id); const rect = msg.getBoundingClientRect(); @@ -69,6 +89,7 @@ export default function useUIindexAnims() { duration: 500, offset: 1000 }); + done; } return { beforeEnter, -- 2.43.0