import { LoadBlockController } from "./load_block_controller" ; import { useIntersection } from "../../mixins/use_intersection" ; export class LazyBlockController extends LoadBlockController { declare observe : ( ) => void ; declare unobserve : ( ) => void ; declare isVisible : boolean ; declare disappear : ( ) => void ; async connect ( ) { let element = this . el ; if ( "IntersectionObserver" in window ) { let { observe , unobserve } = useIntersection ( this , element , this . appear , null , { threshold : 0.3 } ) ; this . observe = observe ; this . unobserve = unobserve ; } else { await this . loadContent ( ) ; } } async appear ( entry ) { if ( entry . target === this . el && entry . isIntersecting ) { await this . loadContent ( ) ; if ( this . unobserve ) { this . unobserve ( ) ; } } } }