<script>
import { animate } from'svelte/animate';
let style = {
transform: 'translate(0, 0) scale(1)',
opacity: 1
};
const start = {
transform: 'translate(0, 0) scale(1)',
opacity: 1
};
const end = {
transform: 'translate(100%, 100%) scale(0.5)',
opacity: 0.5
};
const options = {
duration: 2000,
easing: 'ease-in-out'
};
function startAnimation() {
animate(style, end, options).then(() => {
// 动画结束后的操作
});
}
</script>
<button on:click={startAnimation}>开始动画</button>
<div style={style}>要移动和变化的元素</div>