export default {

    data(){
        return {
            watchScroll:false,
            watchOpacity:'0.00'
        }
    },

    methods:{

        installScroll(){
            if (this.scroll && this.transitionBackgroundColor && this._transitionDistance) {
                this.watchScroll = true;
            }
        },

        watchScrollEvent(e){
            let scrollTop = e.detail.scrollTop;
            scrollTop = scrollTop > this._transitionDistance?this._transitionDistance:scrollTop;
            let opacity= scrollTop / this._transitionDistance;

            opacity = opacity.toFixed(2);

            if (this.watchOpacity !== opacity) {
                this.watchOpacity = opacity;
            }

        }

    },

    mounted(){
        if (this.transitionScroll) {
            this._transitionDistance = this.transitionDistance || (this.statusBarHeight + this.headerHeight)
        } else if (this.transitionAdd){
            this._transitionDistance = this.transitionAdd + (this.statusBarHeight + this.headerHeight);
        } else {
            this._transitionDistance = this.transitionDistance;
        }
        return this.installScroll();
    }



}