From the course: Blazor: Getting Started

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Make an interesting call to JavaScript

Solution: Make an interesting call to JavaScript - Blazor Tutorial

From the course: Blazor: Getting Started

Start my 1-month free trial

Solution: Make an interesting call to JavaScript

(upbeat electronic music) - [Rich] Now that you've had some time to invoke JavaScript on your own, I'll show you my solution. I started in the DataService. I changed the ray list so that when it's set, it's automatically ordered in reverse. In the ray list, I created a surrounding div for the rays and added a ref to it so that I can use this element reference here on line 21. As in the hint, I added this object that represents the key frames I'm going to animate with. I also added a Boolean flag for if the raycast had been called so that I don't animate when the ray wasn't cast. Down here, in OnAfterRenderAsync, if the ray had been cast, I invoke the JavaScript runtime with the animate element method that I created. I pass it the ray list container from this page, the set of key frames, and an integer representing 2,000 milliseconds. Once this is called, I reset the flag. Let's see how it looks. I'll select my…

Contents