import {ref} from "vue";

const listTouchStart = ref(0);
const listTouchDirection = ref<string | null>('');
const modalName = ref<string | null>('');
// ListTouch触摸开始
const handleListTouchStart = (e: any) => {
    listTouchStart.value = e.touches[0].pageX
}

// ListTouch计算方向
const handleListTouchMove = (e: any) => {
    listTouchDirection.value = e.touches[0].pageX - listTouchStart.value > -80 ? 'right' : 'left'
}

// ListTouch计算滚动
const handleListTouchEnd = (e: any) => {
    if (listTouchDirection.value == 'left') {
        modalName.value = e.currentTarget.dataset.target
    } else {
        modalName.value = null
    }
    listTouchDirection.value = null
}

export {modalName, handleListTouchStart, handleListTouchMove, handleListTouchEnd}
