Exemplo n.º 1
0
 /// <summary>
 /// Scrolls inside the given parent element to the given first found inner element by class name.
 /// </summary>
 /// <param name="parent">Blazor reference to an HTML (outer/wrapper) element</param>
 /// <param name="className">Inner element CSS class to scroll to</param>
 /// <returns>Async Task</returns>
 public static async Task ScrollInParentByClassAsync(this ElementReference parent, string className)
 {
     await using (var module = await parent.GetJsObject())
     {
         if (module is not null)
         {
             await module.InvokeVoidAsync("scrollInParentByClass", parent, className);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Scrolls inside the given element to the given Y position.
 /// </summary>
 /// <param name="elementReference">Blazor reference to an HTML element</param>
 /// <param name="yPos">Scroll Y position</param>
 /// <returns>Async Task</returns>
 public static async Task ScrollToYAsync(this ElementReference elementReference, double yPos)
 {
     await using (var module = await elementReference.GetJsObject())
     {
         if (module is not null)
         {
             await module.InvokeVoidAsync("scrollToY", elementReference, yPos);
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Scrolls inside the given parent element to the given inner element.
 /// </summary>
 /// <param name="parent">Blazor reference to an HTML (outer/wrapper) element</param>
 /// <param name="innerElement">Blazor reference to an inner HTML element to scroll to</param>
 /// <returns>Async Task</returns>
 public static async Task ScrollToElementInParentAsync(this ElementReference parent, ElementReference innerElement)
 {
     await using (var module = await parent.GetJsObject())
     {
         if (module is not null)
         {
             await module.InvokeVoidAsync("scrollToElementInParent", parent, innerElement);
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Returns given element is above of the view port.
        /// </summary>
        /// <param name="elementReference">Blazor reference to an HTML element</param>
        /// <returns>Async Task</returns>
        public static async Task <bool> IsElementHiddenAboveAsync(this ElementReference elementReference)
        {
            await using (var module = await elementReference.GetJsObject())
            {
                if (module is not null)
                {
                    return(await module.InvokeAsync <bool>("isElementHiddenAbove", elementReference));
                }
            }

            return(false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns given element scroll X position.
        /// </summary>
        /// <param name="elementReference">Blazor reference to an HTML element</param>
        /// <returns>Async Task with X pos</returns>
        public static async Task <double> GetScrollXPositionAsync(this ElementReference elementReference)
        {
            await using (var module = await elementReference.GetJsObject())
            {
                if (module is not null)
                {
                    return(await module.InvokeAsync <double>("getScrollXPosition", elementReference));
                }
            }

            return(0);
        }
        /// <summary>
        /// Copies the given element text content to clipboard.
        /// </summary>
        /// <param name="elementReference">ElementReference to get text</param>
        /// <returns>Async Task</returns>
        public static async Task <bool> CopyElementTextToClipboardAsync(this ElementReference elementReference)
        {
            await using (var module = await elementReference.GetJsObject())
            {
                if (module is not null)
                {
                    return(await module.InvokeAsync <bool>("copyElementTextToClipboard", elementReference));
                }
            }

            return(false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Returns the given HTML element ClintBoundRect data.
        /// </summary>
        /// <param name="elementReference">Blazor reference to an HTML element</param>
        /// <returns>Async Task with <see cref="DomRect"/> value</returns>
        public static async Task <DomRect> GetClientRectAsync(this ElementReference elementReference)
        {
            await using (var module = await elementReference.GetJsObject())
            {
                if (module is not null)
                {
                    return(await module.InvokeAsync <DomRect>("getBoundingClientRect", elementReference));
                }
            }

            return(new DomRect());
        }