-
Notifications
You must be signed in to change notification settings - Fork 407
Expand file tree
/
Copy pathparabolaCss.vue
More file actions
63 lines (59 loc) · 1.38 KB
/
parabolaCss.vue
File metadata and controls
63 lines (59 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<style scoped lang="scss">
.parabola-container {
position: relative;
height: 400px;
border: 1px solid #eee;
.parabola-item {
width: 30px;
height: 30px;
background: #00adb5;
position: absolute;
left: 0;
top: calc(100% - 30px);
--left: 0;
--top: calc(100% - 30px);
transition: left 0.5s ease-in, top 0.5s ease-out;
&.active {
left: var(--left);
top: var(--top);
}
}
.placehloder{
position: absolute;
left:0;right:0;
top:0;bottom:0;
margin:auto;
display: flex;
justify-content: center;
align-items: center;
font-size: 22px;
color:#ddd;
}
}
</style>
<template>
<div class="parabola-container" @click="containerClick">
<div class="placehloder">click panel to animate</div>
<div class="parabola-item" ref="parabolaItem" :class="{active:isActive}"></div>
</div>
</template>
<script>
export default {
name: "parabola",
data() {
return {
isActive: false
};
},
methods: {
containerClick(e) {
let rect = e.target.getBoundingClientRect();
let offsetX = e.pageX - rect.left - window.pageXOffset;
let offsetY = e.pageY - rect.top - window.pageYOffset;
this.$refs["parabolaItem"].style.setProperty("--left", `${offsetX}px`);
this.$refs["parabolaItem"].style.setProperty("--top", `${offsetY}px`);
this.isActive = true;
}
}
};
</script>