Giter Club home page Giter Club logo

Comments (6)

xieziyu avatar xieziyu commented on May 25, 2024 1

@Ekaanth I think you might set [preventDefaultEvent] to true. Turning it off can make it work.
But if you need to set [preventDefaultEvent], I suggest to use handle to drag div. Only handle element will be affected by [preventDefaultEvent].

from angular2-draggable.

xieziyu avatar xieziyu commented on May 25, 2024 1

@Ekaanth Sure, you can use an array to store multiple blocks and use *ngFor to render multiple draggable div.

A simple example:

<div *ngFor="let b of blocks">
    <div ngDraggable class="drag-block">
        <textarea></textarea>
    </div>
</div>

<button (click)="addBlock()"></button>
blocks = [];

addBlock() {
    this.blocks.push({ text: '' });
}

from angular2-draggable.

Ekaanth avatar Ekaanth commented on May 25, 2024

This code worked for me.

<div ngDraggable class="drag-block" (edge)="checkEdge($event)" (started)="onStart($event)" (stopped)="onStop($event)" (movingOffset)="onMoving($event)" [preventDefaultEvent]="false" (endOffset)="onMoveEnd($event)" [bounds]="myBounds" [inBounds]="inBounds">
                        <textarea name="" id="" cols="30" rows="1"></textarea>
                    </div>

Thanks for your support it worked for me.
Now, I have a button on click of that is displaying the div, is it possible for me to get multiple divs on click of the button multiple times and all those draggable divs should be different from others so that I can enter different text msg in different draggable div.

Thanks.

from angular2-draggable.

Ekaanth avatar Ekaanth commented on May 25, 2024

Hello sir, thanks for your help, and I have a doubt, is it possible to know the x and y position in % not in 'px' because with the change in the screen resolution the position of the element should be same.

from angular2-draggable.

xieziyu avatar xieziyu commented on May 25, 2024

@Ekaanth Currently, it only supports translating by length not percentage. Maybe we can support this feature in future.

from angular2-draggable.

Ekaanth avatar Ekaanth commented on May 25, 2024

Thanks a lot @xieziyu

from angular2-draggable.

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.