✌️
This commit is contained in:
		
							parent
							
								
									de90b25561
								
							
						
					
					
						commit
						a2f16c1364
					
				
					 2 changed files with 9 additions and 8 deletions
				
			
		|  | @ -32,7 +32,7 @@ | |||
| </template> | ||||
| 
 | ||||
| <script lang="ts"> | ||||
| import { computed, ComputedRef, isRef, nextTick, onActivated, onBeforeUnmount, onDeactivated, onMounted, ref, watch } from 'vue'; | ||||
| import { computed, ComputedRef, isRef, nextTick, onActivated, onBeforeUnmount, onDeactivated, onMounted, ref, watch, watchEffect } from 'vue'; | ||||
| import * as misskey from 'misskey-js'; | ||||
| import * as os from '@/os'; | ||||
| import { onScrollTop, isTopVisible, getBodyScrollHeight, getScrollContainer, onScrollBottom, scrollToBottom, scroll, isBottomVisible } from '@/scripts/scroll'; | ||||
|  | @ -130,7 +130,8 @@ const observer = new IntersectionObserver(entries => { | |||
| 	} | ||||
| }); | ||||
| 
 | ||||
| watch([items, $$(itemsContainer), $$(rootEl)], observeLatestElement); | ||||
| watch([$$(itemsContainer), $$(rootEl)], observeLatestElement); | ||||
| watch(items, observeLatestElement, { deep: true }); | ||||
| 
 | ||||
| function observeLatestElement() { | ||||
| 	observer.disconnect(); | ||||
|  | @ -141,7 +142,7 @@ function observeLatestElement() { | |||
| 	}); | ||||
| } | ||||
| 
 | ||||
| watch($$(backed), () => { | ||||
| watch([$$(backed), $$(contentEl)], () => { | ||||
| 	if (!backed) { | ||||
| 		if (!contentEl) return; | ||||
| 
 | ||||
|  | @ -151,7 +152,7 @@ watch($$(backed), () => { | |||
| 				prepend(item, true); | ||||
| 			} | ||||
| 			queue.value = []; | ||||
| 		}); | ||||
| 		}, 16); | ||||
| 	} else { | ||||
| 		if (scrollRemove) scrollRemove(); | ||||
| 		scrollRemove = null; | ||||
|  |  | |||
|  | @ -25,7 +25,7 @@ export function getScrollPosition(el: HTMLElement | null): number { | |||
| 	return container == null ? window.scrollY : container.scrollTop; | ||||
| } | ||||
| 
 | ||||
| export function onScrollTop(el: HTMLElement, cb: Function) { | ||||
| export function onScrollTop(el: HTMLElement, cb: Function, asobi: number = 1) { | ||||
| 	// とりあえず評価してみる
 | ||||
| 	if (isTopVisible(el)) { | ||||
| 		cb(); | ||||
|  | @ -36,7 +36,7 @@ export function onScrollTop(el: HTMLElement, cb: Function) { | |||
| 
 | ||||
| 	const onScroll = ev => { | ||||
| 		if (!document.body.contains(el)) return; | ||||
| 		if (isTopVisible(el)) { | ||||
| 		if (isTopVisible(el, asobi)) { | ||||
| 			cb(); | ||||
| 			removeListener(); | ||||
| 		} | ||||
|  | @ -47,11 +47,11 @@ export function onScrollTop(el: HTMLElement, cb: Function) { | |||
| 	return removeListener; | ||||
| } | ||||
| 
 | ||||
| export function onScrollBottom(el: HTMLElement, cb: Function) { | ||||
| export function onScrollBottom(el: HTMLElement, cb: Function, asobi: number = 1) { | ||||
| 	const container = getScrollContainer(el); | ||||
| 
 | ||||
| 	// とりあえず評価してみる
 | ||||
| 	if (isBottomVisible(el, 1, container)) { | ||||
| 	if (isBottomVisible(el, asobi, container)) { | ||||
| 		cb(); | ||||
| 		return null; | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue