<template>
    <div class="fixButton" :class="btnType" :style="{position: position}">{{text}}</div>
</template>

<script>
export default {
    name: 'fixButton',
    props: {
        type: String,
        text: String
    },
    computed: {
        btnType() {
            return `fixButton-${this.type}`
        }
    },
    data() {
        return {
            position: 'fixed'
        }
    },
    created() {
        let Vm = this
        let height = window.innerHeight
        window.onresize = function(event) {
            if (height !== event.target.innerHeight) {
                Vm.position = 'relative'
            } else {
                Vm.position = 'fixed'
            }
        }
    },
    destroyed() {
        window.onresize = null
    }
}
</script>
