tab swipe fix finally

This commit is contained in:
ThatOneCalculator 2022-10-25 19:19:35 -07:00
parent 82fe676092
commit e93f0939bd
1 changed files with 3 additions and 14 deletions

View File

@ -62,13 +62,9 @@ const props = defineProps<{
}>(); }>();
const tabs = ['featured', 'users', 'search']; const tabs = ['featured', 'users', 'search'];
let tab = $ref(tabs[0]);
watch($$(tab), () => (syncSlide(tabs.indexOf(tab))));
let tab = $computed({
get: () => tabs[0],
set: (x) => {
syncSlide(tabs.indexOf(x));
},
});
let tagsEl = $ref<InstanceType<typeof MkFolder>>(); let tagsEl = $ref<InstanceType<typeof MkFolder>>();
let searchQuery = $ref(null); let searchQuery = $ref(null);
let searchOrigin = $ref('combined'); let searchOrigin = $ref('combined');
@ -109,20 +105,13 @@ definePageMetadata(computed(() => ({
let swiperRef = null; let swiperRef = null;
const emit = defineEmits<{
(ev: 'update:tab', key: string);
}>();
function setSwiperRef(swiper) { function setSwiperRef(swiper) {
swiperRef = swiper; swiperRef = swiper;
syncSlide(tabs.indexOf(tab)); syncSlide(tabs.indexOf(tab));
} }
function onSlideChange() { function onSlideChange() {
let theTab = tabs[swiperRef.activeIndex]; tab = tabs[swiperRef.activeIndex];
console.log(theTab);
emit('update:tab', theTab);
tab = theTab;
} }
function syncSlide(index) { function syncSlide(index) {