Skip to content
Snippets Groups Projects
Unverified Commit c49003f7 authored by xgui3783's avatar xgui3783 Committed by GitHub
Browse files

Merge pull request #219 from HumanBrainProject/dev_swipe_error

correct nativeElement is not found error
parents ba0b340d 964d3a7e
No related branches found
No related tags found
No related merge requests found
...@@ -495,22 +495,25 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { ...@@ -495,22 +495,25 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit {
closeMenuWithSwipe(documentToSwipe: ElementRef) { closeMenuWithSwipe(documentToSwipe: ElementRef) {
const swipeDistance = 150; // swipe distance if (documentToSwipe && documentToSwipe.nativeElement) {
const swipeLeft$ = fromEvent(documentToSwipe.nativeElement, "touchstart") const swipeDistance = 150; // swipe distance
.pipe( const swipeLeft$ = fromEvent(documentToSwipe.nativeElement, 'touchstart')
switchMap(startEvent => .pipe(
fromEvent(documentToSwipe.nativeElement, "touchmove") switchMap(startEvent =>
.pipe( fromEvent(documentToSwipe.nativeElement, 'touchmove')
takeUntil(fromEvent(documentToSwipe.nativeElement, "touchend")) .pipe(
,map(event => event['touches'][0].pageX) takeUntil(fromEvent(documentToSwipe.nativeElement, 'touchend')),
,scan((acc, pageX) => Math.round(startEvent['touches'][0].pageX - pageX), 0) map(event => event['touches'][0].pageX),
,takeLast(1) scan((acc, pageX) => Math.round(startEvent['touches'][0].pageX - pageX), 0),
,filter(difference => difference >= swipeDistance) takeLast(1),
))) filter(difference => difference >= swipeDistance)
// Subscription )))
swipeLeft$.subscribe(val => { this.subscriptions.push(
this.changeMenuState({close: true}) swipeLeft$.subscribe(() => {
}) this.changeMenuState({close: true})
})
)
}
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment