]> Repos - mime-chat/commitdiff
add allCardHeight function
authorriqo <hernandeze2@xavier.edu>
Tue, 27 Oct 2020 17:21:06 +0000 (12:21 -0500)
committerriqo <hernandeze2@xavier.edu>
Tue, 27 Oct 2020 17:21:06 +0000 (12:21 -0500)
src/components/UI/index.vue
src/composables/anims/useUIindexAnims.ts

index 808d4892b7777792900fbec1781818dafbeab4ee..546197475e1412f2234f64b95078725fb39abcb7 100644 (file)
@@ -40,6 +40,7 @@
       <g
         v-for="(item, index) in renderArr"
         :key="index"
+        class="message"
         id="cards"
         transform="translate(0, 0)"
       >
index 1cd3b927c610b45c806f61194945aee3a4b7509b..df91efb8ff670640843e5a15b85e3f6d074338e1 100644 (file)
@@ -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,