search-slider.vue 1.18 KB
<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>