page: 📄 自定义样式
This commit is contained in:
parent
3346703796
commit
9270bb0f4a
|
@ -1,6 +1,4 @@
|
||||||
```sh
|
```sh
|
||||||
styling
|
|
||||||
complex styling
|
|
||||||
transform events
|
transform events
|
||||||
resize limits
|
resize limits
|
||||||
rotation snaps
|
rotation snaps
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
<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 circle = new Konva.Circle({
|
||||||
|
x: 150,
|
||||||
|
y: 150,
|
||||||
|
radius: 70,
|
||||||
|
fill: 'red',
|
||||||
|
draggable: true,
|
||||||
|
});
|
||||||
|
layer.add(circle);
|
||||||
|
|
||||||
|
const tr = new Konva.Transformer({
|
||||||
|
anchorStyleFunc(anchor) {
|
||||||
|
anchor.cornerRadius(10);
|
||||||
|
if (anchor.hasName('top-center') || anchor.hasName('bottom-center')) {
|
||||||
|
anchor.height(8);
|
||||||
|
anchor.offsetY(3);
|
||||||
|
anchor.width(30);
|
||||||
|
anchor.offsetX(15);
|
||||||
|
}
|
||||||
|
if (anchor.hasName('middle-left') || anchor.hasName('middle-right')) {
|
||||||
|
anchor.height(30);
|
||||||
|
anchor.offsetY(15);
|
||||||
|
anchor.width(6);
|
||||||
|
anchor.offsetX(3);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
nodes: [circle],
|
||||||
|
});
|
||||||
|
layer.add(tr);
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
initial();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div id="container"></div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss"></style>
|
Loading…
Reference in New Issue