如何使用 popmotion pure 使最后一个关键帧将我的矩形旋转 35 度角?
https://codepen.io/matthewharwood/pen/XWmRPaK?editors=1111
HTML:
<div class="flex h-screen w-screen justify-center items-center">
<div class="portal-b">
<h1 class="left"></h1>
</div>
</div>
<button class="trigger fixed z-10 left-0 top-0">
B replace A
</button>
CSS:
.portal-b {
background: blue;
width: 1px;
height: 100px;
}
JS
const { easing, keyframes, styler } = window.popmotion;
const trigger = document.querySelector('.trigger');
const [_, portalB] = [document.querySelector('.portal-a'), document.querySelector('.portal-b')];
trigger.addEventListener('click', () => {
const portalS = styler(portalB);
keyframes({
values: [
{ translateX: 0, scaleX: 0, rotateZ: 0, transformOrigin: 'left center' },
{ translateX: 200, scaleX: 400, rotateZ: 0, transformOrigin: 'left center' },
{ translateX: 200, scaleX: 400, rotateZ: 90, transformOrigin: 'left center' },
],
duration: 3000,
easings: easing.easeInOut,
}).start(portalS.set)
})