DemuMesDataV/components/decoration2/index.vue

102 lines
1.9 KiB
Vue
Raw Normal View History

2018-12-05 18:31:23 +08:00
<template>
2019-06-25 19:57:04 +08:00
<div class="dv-decoration-2" :ref="ref">
<svg :width="`${width}px`" :height="`${height}px`">
<rect :x="x" :y="y" :width="w" :height="h" fill="#3faacb">
<animate
:attributeName="reverse ? 'height' : 'width'"
from="0"
:to="reverse ? height : width"
dur="6s"
calcMode="spline"
keyTimes="0;1"
keySplines=".42,0,.58,1"
repeatCount="indefinite"
/>
</rect>
<rect :x="x" :y="y" width="1" height="1" fill="#fff">
<animate
:attributeName="reverse ? 'y' : 'x'"
from="0"
:to="reverse ? height : width"
dur="6s"
calcMode="spline"
keyTimes="0;1"
keySplines=".42,0,.58,1"
repeatCount="indefinite"
/>
</rect>
</svg>
2018-12-05 18:31:23 +08:00
</div>
</template>
<script>
2019-06-25 19:57:04 +08:00
import autoResize from '../../mixins/autoResize.js'
2018-12-05 18:31:23 +08:00
export default {
name: 'Decoration2',
2019-06-25 19:57:04 +08:00
mixins: [autoResize],
props: {
reverse: {
type: Boolean,
default: false
}
},
2018-12-05 18:31:23 +08:00
data () {
return {
2019-06-25 19:57:04 +08:00
ref: 'decoration-2',
x: 0,
y: 0,
w: 0,
h: 0
2018-12-05 18:31:23 +08:00
}
},
2019-06-25 19:57:04 +08:00
watch: {
reverse () {
const { calcSVGData } = this
2018-12-05 18:31:23 +08:00
2019-06-25 19:57:04 +08:00
calcSVGData()
2018-12-05 18:31:23 +08:00
}
},
2019-06-25 19:57:04 +08:00
methods: {
afterAutoResizeMixinInit () {
const { calcSVGData } = this
2018-12-05 18:31:23 +08:00
2019-06-25 19:57:04 +08:00
calcSVGData()
},
calcSVGData () {
const { reverse, width, height } = this
2018-12-05 18:31:23 +08:00
2019-06-25 19:57:04 +08:00
if (reverse) {
this.w = 1
this.h = height
this.x = width / 2
this.y = 0
} else {
this.w = width
this.h = 1
this.x = 0
this.y = height / 2
}
},
onResize () {
const { calcSVGData } = this
2018-12-05 18:31:23 +08:00
2019-06-25 19:57:04 +08:00
calcSVGData()
2018-12-05 18:31:23 +08:00
}
}
2019-06-25 19:57:04 +08:00
}
</script>
2018-12-05 18:31:23 +08:00
2019-06-25 19:57:04 +08:00
<style lang="less">
.dv-decoration-2 {
display: flex;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
2018-12-05 18:31:23 +08:00
}
</style>