This commit is contained in:
Fairy-Phy 2023-10-22 21:14:06 +09:00
parent aab714b277
commit 8435a4b363
No known key found for this signature in database
GPG key ID: 53E58673D5961DB5
2 changed files with 13 additions and 19 deletions

View file

@ -39,7 +39,7 @@ let scrollEl: HTMLElement | null = null;
let disabled = false;
const emits = defineEmits<{
(e: 'refresh'): void;
(ev: 'refresh'): void;
}>();
const getScrollableParentElement = (node) => {
@ -49,8 +49,7 @@ const getScrollableParentElement = (node) => {
if (node.scrollHeight > node.clientHeight) {
return node;
}
else {
} else {
return getScrollableParentElement(node.parentNode);
}
};
@ -62,10 +61,10 @@ const getScreenY = (event) => {
return event.touches[0].screenY;
};
const moveStart = (e) => {
const moveStart = (event) => {
if (!isPullStart && !isRefreshing && !disabled) {
isPullStart = true;
startScreenY = getScreenY(e);
startScreenY = getScreenY(event);
currentHeight = 0;
}
};
@ -111,14 +110,13 @@ const moveEnd = () => {
isPullEnd = false;
isRefreshing = true;
fixOverContent().then(() => emits('refresh'));
}
else {
} else {
closeContent().then(() => isPullStart = false);
}
}
};
const moving = (e) => {
const moving = (event) => {
if (!isPullStart || isRefreshing || disabled) return;
if (!scrollEl) {
@ -132,18 +130,16 @@ const moving = (e) => {
}
if (startScreenY === null) {
startScreenY = getScreenY(e);
startScreenY = getScreenY(event);
}
const moveScreenY = getScreenY(e);
const moveScreenY = getScreenY(event);
const moveHeight = moveScreenY - startScreenY!;
if (moveHeight < 0) {
currentHeight = 0;
}
else if (moveHeight >= maxFrameSize) {
} else if (moveHeight >= maxFrameSize) {
currentHeight = maxFrameSize;
}
else {
} else {
currentHeight = moveHeight;
}
@ -157,12 +153,11 @@ onMounted(() => {
rootEl.addEventListener('pointerdown', moveStart);
// downup
window.addEventListener('pointerup', moveEnd);
rootEl.addEventListener('pointermove', moving, {passive: true});
}
else {
rootEl.addEventListener('pointermove', moving, { passive: true });
} else {
rootEl.addEventListener('touchstart', moveStart);
rootEl.addEventListener('touchend', moveEnd);
rootEl.addEventListener('touchmove', moving, {passive: true});
rootEl.addEventListener('touchmove', moving, { passive: true });
}
});

View file

@ -35,7 +35,6 @@ export function reloadStream() {
stream.stream.reconnect();
timeoutHeadBeat = window.setTimeout(heartbeat, 1000 * 60);
return stream;
}