Skip to content

Instantly share code, notes, and snippets.

@SQL-MisterMagoo
Created April 24, 2020 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SQL-MisterMagoo/1ff4e489a4b43e1f931549178dd0c4d4 to your computer and use it in GitHub Desktop.
Save SQL-MisterMagoo/1ff4e489a4b43e1f931549178dd0c4d4 to your computer and use it in GitHub Desktop.
TouchEvents example
<main @ontouchstart="TouchStart" @ontouchend="TouchEnd" style="height:100vh;">
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</main>
@code
{
void TouchStart(TouchEventArgs args)
{
Console.WriteLine($"Started with {args.Touches.Length} touches");
foreach (var touch in args.Touches)
{
Console.WriteLine($"Started with {touch.ClientX},{touch.ClientY} point");
}
}
void TouchEnd(TouchEventArgs args)
{
Console.WriteLine($"Ended with {args.Touches.Length} touches");
foreach (var touch in args.Touches)
{
Console.WriteLine($"Ended with {touch.ClientX},{touch.ClientY} point");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment