search-slider.vue
1.18 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
<template>
<transition name="search-slider" @after-enter="afterEnter">
<search-bar ref="searchBar" v-model="search" v-if="value" :full="true" @cancel="cancel"></search-bar>
</transition>
</template>
<script>
import SearchBar from './search-bar';
export default {
name: 'SearchSlider',
data() {
return {
search: ''
};
},
props: {
value: Boolean
},
methods: {
cancel() {
this.$emit('input', false);
},
afterEnter() {
this.$refs.searchBar.focus();
}
},
components: {SearchBar}
};
</script>
<style>
.search-slider-enter-active, .search-slider-leave-active {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 999;
will-change: true;
transition-duration: 280ms;
}
.search-slider-enter-active {
transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
}
.search-slider-leave-active {
transition-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
}
.search-slider-enter, .search-slider-leave-to {
transform: translateX(750px);
}
.search-slider-enter-to, .search-slider-leave {
transform: translateX(0px);
}
</style>