클릭 "메뉴 열기"버튼 :
<template>
<transition @enter="animateOpening" @leave="animateClosing">
<div
class="SearchProductsPane-DimUnderlay"
v-if="isOpen"
:ref="elementsReferencesIDs.overlay"
>
<div
class="SearchProductsPane-Body"
:ref="elementsReferencesIDs.body"
>
<!-- ... -->
</div>
</div>
</transition>
</template>
import { Vue, Component } from "vue-property-decorator";
import Animation from "animejs";
@Component
export default class SearchProductsPane extends Vue {
private elementsReferencesIDs: Record<"overlay" | "body", string> = {
overlay: "Overlay", body: "Body"
};
private animateOpening(_element: Element, done: () => {}): void {
Animation
.timeline({
easing: "linear",
duration: 500,
complete: done
})
.add({
targets: this.$refs[this.elementsReferencesIDs.overlay],
opacity: [0, 1]
})
.add({
targets: this.$refs[this.elementsReferencesIDs.body],
translateY: "100%"
})
}
private animateClosing(): void {
}
}
현재 솔루션을 사용하면가 .SearchProductsPane-Body
정상 위치에서 화면 바깥쪽으로 아래쪽으로 이동합니다. 대신 화면 위쪽에서 정상 위치로 이동해야합니다.
아래 클래스를 추가하여 도달했습니다.
.SearchProductsPane-Body__InitialPosition {
transform: translateY(-100%);
}
그러나, animejs
애니메이션은에서 시작 0%
하지 -100%
. 어떻게 변경합니까?
From Value
애니메이션 출처를 정의 할 수 있는 animeJs에서 사용할 수 있습니다.
anime.stagger(100, {from: 'center'})
옵션은 다음과 같습니다.
여기에 문서가 있습니다.
또는 From to
애니메이션이 지정된 값에서 시작되도록 강제 할 수 있습니다 .
당신의 코드에서 :
anime({
targets: '.SearchProductsPane-DimUnderlay'
});
여기에 문서
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다