mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-12-22 08:20:10 +00:00
c2370a1be6
* chore: Add the SPDX information to each file Add copyright and licensing information as defined in version 3.0 of the REUSE Specification. * tweak format --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
40 lines
1 KiB
TypeScript
40 lines
1 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { Directive } from 'vue';
|
|
import { getScrollContainer, getScrollPosition } from '@/scripts/scroll';
|
|
|
|
export default {
|
|
mounted(src, binding, vn) {
|
|
if (binding.value === false) return;
|
|
|
|
let isBottom = true;
|
|
|
|
const container = getScrollContainer(src)!;
|
|
container.addEventListener('scroll', () => {
|
|
const pos = getScrollPosition(container);
|
|
const viewHeight = container.clientHeight;
|
|
const height = container.scrollHeight;
|
|
isBottom = (pos + viewHeight > height - 32);
|
|
}, { passive: true });
|
|
container.scrollTop = container.scrollHeight;
|
|
|
|
const ro = new ResizeObserver((entries, observer) => {
|
|
if (isBottom) {
|
|
const height = container.scrollHeight;
|
|
container.scrollTop = height;
|
|
}
|
|
});
|
|
|
|
ro.observe(src);
|
|
|
|
// TODO: 新たにプロパティを作るのをやめMapを使う
|
|
src._ro_ = ro;
|
|
},
|
|
|
|
unmounted(src, binding, vn) {
|
|
if (src._ro_) src._ro_.unobserve(src);
|
|
},
|
|
} as Directive;
|