IOGesture 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package IOGesture --version 1.1.0                
NuGet\Install-Package IOGesture -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IOGesture" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IOGesture --version 1.1.0                
#r "nuget: IOGesture, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install IOGesture as a Cake Addin
#addin nuget:?package=IOGesture&version=1.1.0

// Install IOGesture as a Cake Tool
#tool nuget:?package=IOGesture&version=1.1.0                

IOGesture

NuGet GitHub License GitHub Release

A lightweight and easy-to-use library for handling touch and gesture events in Blazor applications. This wrapper is built on top of the TinyGesture library and provides seamless integration with Blazor components.

Features

  • Pan Gestures: Detect and handle pan gestures with start, move, and end callbacks.
  • Swipe Gestures: Easily recognize swipe gestures in all directions (up, down, left, right).
  • Tap Gestures: Identify single tap and double tap gestures.
  • Long Press: Handle long press events.
  • Pinch and Rotate: Manage pinch (zoom) and rotate gestures, complete with start and end callbacks.
  • Customizable Options: Configure gesture thresholds and other settings to fine-tune the gesture detection.

ℹī¸ For more information please check the TinyGesture repository.

Getting Started

Installation

  1. Install IOGesture with dotnet cli in your Blazor app.
dotnet add package IOGesture 
  1. Add the tinygesture.js and IOGesture.js script tag in your root file _Host.cshtml for Blazor Server Apps or index.html for Blazor WebAssembly Apps:

<script src="_framework/blazor.server.js"></script>
<script src="_content/IOGesture/js/IOGesture.js" type="module"></script>
<script src="_content/IOGesture/js/tinygesture.js" type="module"></script>

Usage

Use the IOGesture.Components and use the component:

@using IOGesture.Components

<IOGesture>
  <h1>Swipe me.</h1>
</IOGesture>

Then you can listen to gesture event callbacks and pass the options with type of GestureOptions, You can access various properties of the gesture using the Properties object after you referenced the IOGesture instance:

<IOGesture 
    @ref="ioGesture"
    OnPanMove="HandlePanMove"
    Options="gestureOptions">
    <Content>
        
    </Content>
</IOGesture>

@code {
    private IOGesture? ioGesture;
    private GestureOptions gestureOptions = new GestureOptions
    {
        VelocityThreshold = 10,
        PressThreshold = 8,
        DiagonalSwipes = false,
        DiagonalLimit = 15,
        MouseSupport = true
    };

    private void HandlePanMove()
    {
        Console.WriteLine($"X: {_panMovingInstance.Properties.TouchMoveX}, Y: {_panMovingInstance.Properties.TouchMoveY}");
    }

    private void HandleSwipeLeft()
    {
        // Handle swipe left
    }
}

GestureOptions Configuration

Customize gesture detection by setting properties in GestureOptions:

  • VelocityThreshold: Minimum velocity the gesture must be moving when the gesture ends to be considered a swipe.
  • PressThreshold: Point at which the pointer moved too much to consider it a tap or long press gesture.
  • DiagonalSwipes: If true, swiping in a diagonal direction will fire both a horizontal and a vertical swipe.
  • DiagonalLimit: The degree limit to consider a diagonal swipe when DiagonalSwipes is true.
  • MouseSupport: Listen to mouse events in addition to touch events (for desktop support).

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

This wrapper is built on top of the TinyGesture library.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 128 7/14/2024
1.1.0 102 7/6/2024
1.0.1 116 7/4/2024