Created
September 3, 2019 14:00
-
-
Save ndcunningham/646c372d975e8ec17189caceeef2da28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'my-app', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent implements OnInit { | |
@ViewChild('dropZone', { static: true }) dropZone: ElementRef<HTMLDivElement>; | |
dragEnter$ = defer(() => fromEvent(this.dropZone.nativeElement, 'dragenter')).pipe( | |
tap((event: any) => { event.target.style.background = 'teal'; event.target.style.opacity = .5; }) | |
); | |
dragExit$ = defer(() => fromEvent(this.dropZone.nativeElement, 'dragleave')).pipe( | |
tap((event: any) => { event.target.style.background = ''; event.target.style.opacity = 1; }) | |
); | |
dragEnd$ = defer(() => fromEvent(this.dropZone.nativeElement, 'dragend')).pipe( | |
tap((event: any) => event.target.style.background = '') | |
); | |
ngOnInit() { | |
this.dragEnter$.subscribe(); | |
this.dragEnd$.subscribe(); | |
this.dragExit$.subscribe(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment