Kebechet.Blazor.EventHandlers.LongPress
2.5.2.1
Prefix Reserved
dotnet add package Kebechet.Blazor.EventHandlers.LongPress --version 2.5.2.1
NuGet\Install-Package Kebechet.Blazor.EventHandlers.LongPress -Version 2.5.2.1
<PackageReference Include="Kebechet.Blazor.EventHandlers.LongPress" Version="2.5.2.1" />
<PackageVersion Include="Kebechet.Blazor.EventHandlers.LongPress" Version="2.5.2.1" />
<PackageReference Include="Kebechet.Blazor.EventHandlers.LongPress" />
paket add Kebechet.Blazor.EventHandlers.LongPress --version 2.5.2.1
#r "nuget: Kebechet.Blazor.EventHandlers.LongPress, 2.5.2.1"
#:package Kebechet.Blazor.EventHandlers.LongPress@2.5.2.1
#addin nuget:?package=Kebechet.Blazor.EventHandlers.LongPress&version=2.5.2.1
#tool nuget:?package=Kebechet.Blazor.EventHandlers.LongPress&version=2.5.2.1
Blazor.EventHandlers.LongPress
This package contains @onlongpress event handler built from John Doherty's JS long-press
Motivation: For similar functionality you can also use oncontextmenu what is built-in event. But it doesnt work on iOS devices. Source
- Before using the JS, I renamed triggered event name from
long-presstolongpressto be able to use it in Blazor. - I have also changed default show time from
1500msto400msBased on android longpress implementation.- iOS has 500ms
- In case you would like to specify your custom time, you can do so by adding tag attribute with your custom time like:
<div @onlongpress="LongPressHandler" data-long-press-delay="100">
TIP: For better usage experience put: @using Blazor.EventHandlers.LongPress into _Imports.razor file.
TIP2 For combination with @onlongpress consider also use of @onshortclick
⚠️ Auto-initializers
- In previous MAUI versions JS initializers were not working. So if you dont see text "Registering LongPress.js" in your JS console then you have to register this event handler manually in your
index.html. At the end after blazor script put this:
<script defer src="_content/Kebechet.Blazor.EventHandlers.LongPress/LongPress.js"></script>
<script async>
window.onload = function () {
console.log("Registering LongPress.js");
Blazor.registerCustomEventType('longpress', {
createEventArgs: event => {
return {
bubbles: event.bubbles,
cancelable: event.cancelable,
screenX: event.detail.screenX,
screenY: event.detail.screenY,
clientX: event.detail.clientX,
clientY: event.detail.clientY,
offsetX: event.detail.offsetX,
offsetY: event.detail.offsetY,
pageX: event.detail.pageX,
pageY: event.detail.pageY,
sourceElement: event.srcElement.localName,
targetElement: event.target.localName,
timeStamp: event.timeStamp,
type: event.type,
};
}
});
};
</script>
- and then it should work as expected
Used resources
License
This repository is licensed with the MIT license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.0)
-
net6.0
- Microsoft.AspNetCore.Components.Web (>= 6.0.0)
-
net7.0
- Microsoft.AspNetCore.Components.Web (>= 7.0.0)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.0)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Lowered Microsoft.AspNetCore.Components.Web floor per TFM to the major.minor base version to prevent NU1605 downgrade errors when consumers pin a lower patch.