xieziyu / angular2-draggable

Angular directive (for version >= 2.x ) that makes the DOM element draggable and resizable
https://xieziyu.github.io/angular2-draggable/
294 stars 103 forks source link

Click handler? #69

Closed ianfoxofficial closed 6 years ago

ianfoxofficial commented 6 years ago

Click handler doesn't work on draggable items. Not as (click)="thefunction" and not as link on an anchor tag.

How do I make draggables clickable?

 <div  *ngFor="let event of unit.events" class="planner-calendar__row__cell__event" [ngStyle]="getWidth(event)" ngDraggable
                    [bounds]="myBounds" [inBounds]="true" [outOfBounds]="{top: false, bottom: false, right: true, left: true}"
                    [trackPosition]="true" (started)="onDragBegin($event, event)" (stopped)="onDragEnd($event,event)" (endOffset)="onMoveEnd($event,event)"
                    [position]="event.position" (click)="onClick($event)">
                    {{event.name}}
                    <br>{{event.startDate | date: 'medium'}} - {{event.endDate | date: 'medium'}}

                  </div>

The click event doesn't get triggered.

xieziyu commented 6 years ago

@ianfoxofficial The draggable items are clickable in nature. I could not reproduce your issue. The click handler is called as expected in my project. Could you set up a plunkr or stackblitz for reproducing this issue? Thanks

ianfoxofficial commented 6 years ago

I've done some testing removing other handlers, and narrowed it down to the endOffset handler in my project that redraws the screen and canceled the click event.

I've fixed it. thanks

xieziyu commented 6 years ago

@ianfoxofficial Glad to know that. Will close this issue.

Vipin-vis commented 5 years ago

@ianfoxofficial The draggable items are clickable in nature. I could not reproduce your issue. The click handler is called as expected in my project. Could you set up a plunkr or stackblitz for reproducing this issue? Thanks

I've done some testing removing other handlers, and narrowed it down to the endOffset handler in my project that redraws the screen and canceled the click event.

I've fixed it. thanks

I've done some testing removing other handlers, and narrowed it down to the endOffset handler in my project that redraws the screen and canceled the click event.

I've fixed it. thanks

Hi ianfoxofficial,

We are also facing the same issue, Could you please explain the solution

ianfoxofficial commented 5 years ago

@ianfoxofficial The draggable items are clickable in nature. I could not reproduce your issue. The click handler is called as expected in my project. Could you set up a plunkr or stackblitz for reproducing this issue? Thanks

I've done some testing removing other handlers, and narrowed it down to the endOffset handler in my project that redraws the screen and canceled the click event. I've fixed it. thanks

I've done some testing removing other handlers, and narrowed it down to the endOffset handler in my project that redraws the screen and canceled the click event. I've fixed it. thanks

Hi ianfoxofficial,

We are also facing the same issue, Could you please explain the solution

Hi,

It's been a while since this project and don't know the details anymore. Looking back at my GIT commits I can't really see the affecting changes I've made to my code.

Try commenting out the code in the event that triggers what happens after you drag the item and see what cancels the click event. Then you can try to enable code again and see what cancels things out.

I'm sorry I can't help much more.

prabhatojha commented 5 years ago

I am still facing this issue and it's intermittent for me. If I restart my Angular app, it starts working. Did anyone figure out the root cause or the solution?