/// <summary>
        /// Create an observer instance with a unique id, adding it
        /// to the list of observers.
        /// </summary>
        /// <param name="onIntersectUpdate">On an intersection update, pass the entries to the callback</param>
        /// <param name="options">The intersection observer options</param>
        /// <returns>The observer instance</returns>
        public async Task <IntersectionObserver> Create(
            Action <IList <IntersectionObserverEntry> > onIntersectUpdate,
            IntersectionObserverOptions options = null
            )
        {
            var callbackId = Guid.NewGuid().ToString();

            await this.jsRuntime.InvokeAsync <object>(Constants.CREATE, this.dotnetObjRef, options);

            return(this.CreateObserver(callbackId, onIntersectUpdate));
        }
示例#2
0
        /// <summary>
        /// Create an observer instance and immediately observe
        /// the element.
        /// </summary>
        /// <param name="element">The element</param>
        /// <param name="onIntersectUpdate">On an intersection update, pass the entries</param>
        /// <param name="options">The intersection observer options</param>
        /// <returns></returns>
        public async Task <IntersectionObserver> Observe(
            ElementReference element,
            Action <IList <IntersectionObserverEntry> > onIntersectUpdate,
            IntersectionObserverOptions options = null
            )
        {
            var module = await this.moduleTask;

            var callbackId = Guid.NewGuid().ToString();

            await module.InvokeAsync <object>(Constants.OBSERVE, this.objectRef, callbackId, element, options);

            return(this.CreateObserver(callbackId, onIntersectUpdate));
        }