feat: 🚀 complex Tweening
This commit is contained in:
parent
fbf929cc81
commit
e9e0dab2f8
|
@ -1,8 +1,4 @@
|
|||
```sh
|
||||
https://konvajs.org/docs/tweens/All_Easings.html
|
||||
https://konvajs.org/docs/tweens/All_Controls.html
|
||||
https://konvajs.org/docs/tweens/Tween_Filter.html
|
||||
|
||||
https://konvajs.org/docs/animations/Create_an_Animation.html
|
||||
https://konvajs.org/docs/animations/Moving.html
|
||||
https://konvajs.org/docs/animations/Rotation.html
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<script setup lang="ts">
|
||||
import { useWindowSize } from '@vueuse/core';
|
||||
import { onMounted } from 'vue';
|
||||
import Konva from 'konva/lib';
|
||||
|
||||
const { width, height } = useWindowSize();
|
||||
|
||||
const initial = () => {
|
||||
const stage = new Konva.Stage({ container: 'container', width: width.value, height: height.value });
|
||||
const layer = new Konva.Layer();
|
||||
stage.add(layer);
|
||||
|
||||
const image = new Image();
|
||||
const lion = new Konva.Image({
|
||||
x: 80,
|
||||
y: 30,
|
||||
width: 50,
|
||||
height: 50,
|
||||
draggable: true,
|
||||
image,
|
||||
});
|
||||
layer.add(lion);
|
||||
|
||||
image.crossOrigin = 'Anonymous';
|
||||
image.src = 'https://konvajs.org/assets/darth-vader.jpg';
|
||||
|
||||
image.onload = function () {
|
||||
lion.image(image);
|
||||
lion.cache();
|
||||
lion.filters([Konva.Filters.Blur]);
|
||||
lion.blurRadius(100);
|
||||
|
||||
const tween = new Konva.Tween({
|
||||
node: lion,
|
||||
duration: 0.6,
|
||||
blurRadius: 0,
|
||||
easing: Konva.Easings.EaseInOut,
|
||||
});
|
||||
|
||||
lion.on('mouseover', function () {
|
||||
tween.play();
|
||||
});
|
||||
|
||||
lion.on('mouseout', function () {
|
||||
tween.reverse();
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
initial();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div id="container"></div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
Loading…
Reference in New Issue