DragulaDropula 1.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DragulaDropula --version 1.3.0                
NuGet\Install-Package DragulaDropula -Version 1.3.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="DragulaDropula" Version="1.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DragulaDropula --version 1.3.0                
#r "nuget: DragulaDropula, 1.3.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 DragulaDropula as a Cake Addin
#addin nuget:?package=DragulaDropula&version=1.3.0

// Install DragulaDropula as a Cake Tool
#tool nuget:?package=DragulaDropula&version=1.3.0                

DragulaDropula

Library for simple Drag-And-Drop functionality in Blazor.

You can pull request and create issue here 👉 https://github.com/marat0n/DragulaDropula

How to start using

  1. Add DradNDropController to Scoped Services.
builder.Service.AddScoped<DragNDropController>();
  1. Add DragulaDropula namespace to _Imports.razor.
@using DragulaDropula
  1. Done ✅

API

Components

DraggingZone — Component you need to use as an underlay for Draggable components.

Parameters:

Width - width of DraggingZone.

Height - height of DraggingZone.


Draggable — Component you can drag.

Parameters:

ItemToDrop - object you need to drop (Example below).

MustReturnBackOnDrop - boolean parameter means this component will return to start position when it's dropped.

OnDrop - if you need to run some logic when Draggable is dropped then put your method here.

OnDropWithPosition - the same as OnDrop but also set X and Y parameters when component dropped.

ChildContent - default child content.

ContentWhenDragging - child content will be rendered when user drags Draggable component.

Bindings:

X - position on the X-axis.

Y - position on the Y-axis.


DropTarget — Component for creating dropping area.

Parameters:

OnDrop - your method for getting dropped DraggableModel (and ItemToDrop inside) and something else you need.

ValidateItem - method for validating dropped item. If validation is successful then OnAccept will be invoked.

OnAccept - action will be invoked only if ValidateItem method returns true.

OnReject - action will be invoked only if ValidateItem method returns false.

Example

Let's create a test page in blazor and use DragulaDropula here. Page Test.razor:

@page "/Test"

<DraggingZone Width="100vw" Height="100vh">
    <h1>Some test here!</h1>
    
    <Draggable
        OnDrop="@(o => Console.WriteLine("Drop banana!"))"
        ItemToDrop="@("banana")">
        
        <div style="background-color: yellow; width: 100px; height: 100px; color: white;">
            <span style="background-color: darkorange">The banana</span>
        </div>
    </Draggable>
    
    <Draggable
        OnDrop="@(o => Console.WriteLine("Drop apple!"))"
        ItemToDrop="@("apple")">
        
        <div style="background-color: red; width: 100px; height: 100px; color: white;">
            <span>The apple</span>
        </div>
    </Draggable>
    
    <hr />
    
    <DropTarget
        ValidateItem="@(o => o is "banana")"
        OnAccept="@(item => { _result = item; Console.WriteLine(_result); })"
        OnReject="@(o => _result = "absolutely nothing because YOU JUST CAN'T PUT APPLES IN THE BANANA BOX")">
        <div style="background-color: sandybrown; width: 250px; height: 250px; color: black;">
            The banana box
        </div>
    </DropTarget>
    
    <hr />
    
    The result is @(_result).
    
    <hr>
    
    
</DraggingZone>

@code {

    private object _result = "nothing";

}
Product 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 was computed.  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 was computed.  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
2.1.2 382 6/4/2023
2.1.0 143 5/15/2023
2.0.0 288 2/3/2023
1.3.2 318 12/24/2022
1.3.0 438 9/26/2022
1.2.1 924 8/6/2022
1.2.0 439 8/2/2022
1.1.0 436 7/28/2022
1.0.2 433 7/24/2022
1.0.1 410 7/24/2022
1.0.0 411 7/22/2022