gotta implement scroll offset
This commit is contained in:
parent
aab6a479b4
commit
6757303137
2 changed files with 40 additions and 18 deletions
|
|
@ -40,8 +40,7 @@
|
||||||
<g
|
<g
|
||||||
v-for="(item, index) in renderArr"
|
v-for="(item, index) in renderArr"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="message"
|
class="test"
|
||||||
id="cards"
|
|
||||||
transform="translate(0, 0)"
|
transform="translate(0, 0)"
|
||||||
>
|
>
|
||||||
<transition
|
<transition
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { inject, onMounted } from "vue";
|
import { inject, onMounted } from "vue";
|
||||||
export default function useUIindexAnims() {
|
export default function useUIindexAnims() {
|
||||||
interface Done {}
|
|
||||||
const anime: any = inject("animejs");
|
const anime: any = inject("animejs");
|
||||||
const timeline = anime.timeline({ loop: true });
|
const timeline = anime.timeline({ loop: true });
|
||||||
const msgOffset = {
|
const msgOffset = {
|
||||||
|
|
@ -12,44 +11,45 @@ export default function useUIindexAnims() {
|
||||||
let msg: any;
|
let msg: any;
|
||||||
let cardsDiv: any;
|
let cardsDiv: any;
|
||||||
let prevCardH = 0;
|
let prevCardH = 0;
|
||||||
|
let totalHeight = 0;
|
||||||
let messenger: any;
|
let messenger: any;
|
||||||
|
let currentCard: Element;
|
||||||
|
let renderList: NodeList;
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
messenger = document.getElementById("messenger");
|
messenger = document.getElementById("messenger");
|
||||||
winW = messenger.clientWidth;
|
winW = messenger.clientWidth;
|
||||||
});
|
});
|
||||||
|
|
||||||
function getCardHeight(el: SVGSVGElement) {
|
function getCardHeight(el: any) {
|
||||||
const cardHeight = el.getBBox().height;
|
const cardHeight = el.getBBox().height;
|
||||||
return cardHeight;
|
return cardHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAllCardsHeight() {
|
function calculateAllCardsHeight() {
|
||||||
let cards: [];
|
const cards = document.querySelectorAll(".test");
|
||||||
cardsDiv = await document.getElementById("cardsDiv");
|
if (cards.length) {
|
||||||
cards = cardsDiv.querySelectorAll(".message");
|
renderList = cards;
|
||||||
let totalHeight = 0;
|
currentCard = cards.item(cards.length - 1);
|
||||||
for (const card of cards) {
|
for (const card of cards) {
|
||||||
let height = getCardHeight(card);
|
const height = getCardHeight(card);
|
||||||
totalHeight += height;
|
totalHeight += height;
|
||||||
if (totalHeight >= 500) {
|
|
||||||
console.log("update scroll view");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function beforeEnter(el: SVGGElement) {
|
async function beforeEnter(el: SVGGElement) {
|
||||||
modifier = el.className.baseVal.substring(0, 2);
|
modifier = el.className.baseVal.substring(0, 2);
|
||||||
|
calculateAllCardsHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function enter(el: SVGGElement, done: any) {
|
async function stackAnimate(el: any, done: any) {
|
||||||
getAllCardsHeight();
|
|
||||||
const paddingLeft = 40;
|
const paddingLeft = 40;
|
||||||
msg = await document.getElementById(el.id);
|
msg = await document.getElementById(el.id);
|
||||||
const rect = msg.getBoundingClientRect();
|
const rect = msg.getBoundingClientRect();
|
||||||
const msgW = rect.width;
|
const msgW = rect.width;
|
||||||
const msgH = rect.height;
|
const msgH = rect.height;
|
||||||
cardsDiv = await document.getElementById("cardsDiv");
|
cardsDiv = document.getElementById("cardsDiv");
|
||||||
const cdBox = cardsDiv.getBBox();
|
const cdBox = cardsDiv.getBBox();
|
||||||
|
|
||||||
if (prevCardH === 0) {
|
if (prevCardH === 0) {
|
||||||
|
|
@ -90,6 +90,29 @@ export default function useUIindexAnims() {
|
||||||
offset: 1000
|
offset: 1000
|
||||||
});
|
});
|
||||||
done;
|
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 {
|
return {
|
||||||
beforeEnter,
|
beforeEnter,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue