Sam
Sam

Reputation: 632

Why this Angular 2 drag & drop example prevents scrolling?

I found an example drag & drop code for Angular 2 app and here it's plunkr code :

plnkr.co/edit/wXLvaOlD4GVW2hg7utGx?p=preview

It works perfectly (when you remove the br tags).

But I have to use browser's default scroll behavior while dragging element. This example prevents scrolling while dragging.

How should I use this example with scroll?

Upvotes: 0

Views: 933

Answers (1)

Abdullah Khan
Abdullah Khan

Reputation: 645

you have to implement the angular host for example like :

@HostListener('mousemove', ['$event']) onMousemove(event: MouseEvent) {      
  window.scrollTo(document.body.scrollLeft + (curXPos - e.pageX); 
}

Upvotes: 1

Related Questions