Skip to content

Commit

Permalink
perf: only recompute draggable position on window scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlewis92 committed Jun 17, 2018
1 parent c5ef775 commit f6a5cde
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/droppable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,21 @@ export class DroppableDirective implements OnInit, OnDestroy {
ngOnInit(): void {
this.currentDragSubscription = this.draggableHelper.currentDrag.subscribe(
drag$ => {
let droppableRectangle = this.element.nativeElement.getBoundingClientRect();

/* istanbul ignore next */
this.renderer.listen('window', 'scroll', () => {
droppableRectangle = this.element.nativeElement.getBoundingClientRect();
});

let currentDragDropData: any;
const overlaps$ = drag$.pipe(
map(({ clientX, clientY, dropData }) => {
currentDragDropData = dropData;
return isCoordinateWithinRectangle(
clientX,
clientY,
this.element.nativeElement.getBoundingClientRect()
droppableRectangle
);
})
);
Expand Down

0 comments on commit f6a5cde

Please sign in to comment.