Coder Social home page Coder Social logo

dndPlaceholder usage about ngx-drag-drop HOT 3 CLOSED

reppners avatar reppners commented on August 30, 2024
dndPlaceholder usage

from ngx-drag-drop.

Comments (3)

reppners avatar reppners commented on August 30, 2024

Hi :)

To reference a dndPlaceholder mark the element with a template reference variable #ph1

         <div class="list-group" id="ph1" #ph1>
           <a href="#" class="list-group-item list-group-item-action"
             *ngFor="let item of itemDest1; let i=index"
             [dndDraggable]="item.data"
             [dndEffectAllowed]="item.effectAllowed"
             [dndDisableIf]="item.disable"
             (dndStart)="onDragStart($event)"
             (dndCopied)="onDraggableCopied($event)"
             (dndLinked)="onDraggableLinked($event)"
             (dndMoved)="onDraggableMoved($event)"
             (dndCanceled)="onDragCanceled($event)"
             (dndEnd)="onDragEnd($event)"
             (click)="selectObj($event, i)">
             {{item.data.nombre}}
           </a>
         </div>

See the angular docs about template ref vars https://angular.io/guide/template-syntax#ref-vars

Also the placeholder should be a dedicated element which does not contain draggables itself, so your markup should be more like

  <td [dndDropzone]="['SERVICE', 'ADDRESS']"
         [dndPlaceholder]="ph1"
         (dndDragover)="onDragover($event)"
         (dndDrop)="onDrop($event)">

        <div #ph1>
            PLACEHOLDER CONTENT HERE
        </div>

         <div class="list-group" id="ph1">
           <a href="#" class="list-group-item list-group-item-action"
             *ngFor="let item of itemDest1; let i=index"
             [dndDraggable]="item.data"
             [dndEffectAllowed]="item.effectAllowed"
             [dndDisableIf]="item.disable"
             (dndStart)="onDragStart($event)"
             (dndCopied)="onDraggableCopied($event)"
             (dndLinked)="onDraggableLinked($event)"
             (dndMoved)="onDraggableMoved($event)"
             (dndCanceled)="onDragCanceled($event)"
             (dndEnd)="onDragEnd($event)"
             (click)="selectObj($event, i)">
             {{item.data.nombre}}
           </a>
         </div>
    </td>

You can apply styling and content on the placeholder as you like but it does not serve any other purpose than being a visual element which indicates the drop index. Therefore it makes sense to have it look similar to the draggables contained in the dropzone.

I'm also thinking about having dynamic placeholders by using the currently dragged element as a placeholder. If you'd like such functionality please let me know.

from ngx-drag-drop.

fperezgaliana avatar fperezgaliana commented on August 30, 2024

Hi!
Thank you very much for your fast response! I added the template var to the placeholder div and it worked like a charm! Now that I've read the documentation more in detail, I realized that you specified it in the placeholder definition... (sorry about that :))

Regarding the dynamic placeholders, it would be a useful feature but, at the moment, I'm happy with the behaviour of the library.

Best regards,

from ngx-drag-drop.

reppners avatar reppners commented on August 30, 2024

Glad I could help 👍

from ngx-drag-drop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.