enhance(frontend/PullToRefresh): コンポーネントがDOMから消えた時点でタッチ操作などのコールバック関数が止まるように (MisskeyIO#244)

This commit is contained in:
まっちゃとーにゅ 2023-11-22 01:10:06 +09:00 committed by kakkokari-gtyih
parent 15ae1605ec
commit 92dd9a0782
1 changed files with 13 additions and 2 deletions

View File

@ -23,7 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { onMounted, onUnmounted, ref, shallowRef } from 'vue';
import { onMounted, onUnmounted, onActivated, onDeactivated, ref, shallowRef } from 'vue';
import { i18n } from '@/i18n.js';
import { getScrollContainer } from '@@/js/scroll.js';
import { isHorizontalSwipeSwiping } from '@/scripts/touch.js';
@ -198,8 +198,8 @@ function unregisterEventListenersForReadyToPull() {
}
onMounted(() => {
isRefreshing.value = false;
if (rootEl.value == null) return;
scrollEl = getScrollContainer(rootEl.value);
if (scrollEl == null) return;
@ -210,7 +210,18 @@ onMounted(() => {
registerEventListenersForReadyToPull();
});
onActivated(() => {
isRefreshing.value = false;
});
onDeactivated(() => {
scrollEl!.style.touchAction = 'auto';
isRefreshing.value = true;
});
onUnmounted(() => {
scrollEl!.style.touchAction = 'auto';
isRefreshing.value = true;
if (scrollEl) scrollEl.removeEventListener('scroll', onScrollContainerScroll);
unregisterEventListenersForReadyToPull();