<template>
	<scroll-view
		class="cu-scrollView"
		@scrolltolower="scrollFunc"
		refresher-enabled
		@refresherpulling="refresherpulling"
		:refresher-triggered="triggered"
		@refresherabort="refresherabort"
		@refresherrefresh="refresherrefresh"
		scroll-with-animation
		:style="{ height }"
		scroll-y="true"
	>
		<slot />
	</scroll-view>
</template>

<script>
export default {
	props: {
		height: { type: String, default: '100vh' }
	},
	data() {
		return {
			triggered: false,
			scrollLock: false,
			nowDate: 0
		};
	},
	methods: {
		refresherpulling() {
			
		},
		async refresherrefresh(){
			try {
				if (this.triggered) return false;
				this.triggered = true;
				await this.$emit('refresherpulling');
			} finally {
				this.triggered = false;
			}
		},
		refresherabort(){
			console.log("终端")
		},
		async scrollFunc(e) {
			try {
				if (this.scrollLock) return false;
				this.scrollLock = true;
				await this.$emit('scroll');
			} finally {
				this.scrollLock = false;
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.cu-scrollView {
	transition: height 0.3s linear;
}
</style>
