Skip to content

Commit

Permalink
fix(controls): Fix seek to not stop seeking when leaving out the scru…
Browse files Browse the repository at this point in the history
…b bar

Fix seek to not stop seeking when leaving out the scrub bar
  • Loading branch information
Elecash committed Feb 7, 2018
1 parent 41e8d6a commit 81b718f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 65 deletions.
43 changes: 0 additions & 43 deletions src/controls/vg-scrub-bar/vg-scrub-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,6 @@ describe('Scrub bar', () => {
});
});

describe('onMouseOutScrubBar', () => {
it('should modify time.current to 10 when offsetX is 20 and scrollWidth is 200 and vgSlider is true and isSeeking is true', () => {
spyOn(api, 'seekTime');

media.onCanPlay({});
api.registerMedia(media);

scrubBar.target = api;
scrubBar.vgSlider = false;

scrubBar.onMouseOutScrubBar({ offsetX: 20 });

expect(api.seekTime).toHaveBeenCalledTimes(0);

scrubBar.vgSlider = true;
scrubBar.isSeeking = true;

scrubBar.onMouseOutScrubBar({ offsetX: 20 });

expect(api.seekTime).toHaveBeenCalledWith(10, true);
});
});

describe('onMouseUpScrubBar', () => {
it('should modify time.current to 10 when offsetX is 20 and scrollWidth is 200 and vgSlider is true and isSeeking is true', () => {
spyOn(api, 'seekTime');
Expand Down Expand Up @@ -253,24 +230,4 @@ describe('Scrub bar', () => {
expect(api.seekTime).toHaveBeenCalledTimes(0);
});
});

describe('onTouchLeaveScrubBar', () => {
it('should not seek', () => {
spyOn(api, 'seekTime');

scrubBar.target = api;
scrubBar.vgSlider = false;

scrubBar.onTouchLeaveScrubBar({ touches: [ {pageX: 20 }]});

expect(api.seekTime).toHaveBeenCalledTimes(0);

scrubBar.vgSlider = true;
scrubBar.isSeeking = true;

scrubBar.onTouchLeaveScrubBar({ touches: [ {pageX: 20 }]});

expect(api.seekTime).toHaveBeenCalledTimes(0);
});
});
});
30 changes: 8 additions & 22 deletions src/controls/vg-scrub-bar/vg-scrub-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,16 @@ export class VgScrubBar implements OnInit, OnDestroy {
}
}

@HostListener('mousemove', [ '$event' ])
@HostListener('document:mousemove', [ '$event' ])
onMouseMoveScrubBar($event: any) {
if (!this.target.isLive && this.vgSlider && this.isSeeking) {
this.seekMove($event.offsetX);
}
}

@HostListener('mouseout', [ '$event' ])
onMouseOutScrubBar($event: any) {
if (!this.target.isLive && this.vgSlider && this.isSeeking) {
this.seekEnd($event.offsetX);
}
}

@HostListener('mouseup', [ '$event' ])
@HostListener('document:mouseup', [ '$event' ])
onMouseUpScrubBar($event: any) {
if (!this.target.isLive && this.vgSlider) {
if (!this.target.isLive && this.vgSlider && this.isSeeking) {
this.seekEnd($event.offsetX);
}
}
Expand All @@ -205,30 +198,23 @@ export class VgScrubBar implements OnInit, OnDestroy {
}
}

@HostListener('touchmove', [ '$event' ])
@HostListener('document:touchmove', [ '$event' ])
onTouchMoveScrubBar($event: any) {
if (!this.target.isLive && this.vgSlider && this.isSeeking) {
this.seekMove(this.getTouchOffset($event));
}
}

@HostListener('touchcancel', [ '$event' ])
@HostListener('document:touchcancel', [ '$event' ])
onTouchCancelScrubBar($event: any) {
if (!this.target.isLive && this.vgSlider) {
if (!this.target.isLive && this.vgSlider && this.isSeeking) {
this.touchEnd();
}
}

@HostListener('touchend', [ '$event' ])
@HostListener('document:touchend', [ '$event' ])
onTouchEndScrubBar($event: any) {
if (!this.target.isLive && this.vgSlider) {
this.touchEnd();
}
}

@HostListener('touchleave', [ '$event' ])
onTouchLeaveScrubBar($event: any) {
if (!this.target.isLive && this.vgSlider) {
if (!this.target.isLive && this.vgSlider && this.isSeeking) {
this.touchEnd();
}
}
Expand Down

0 comments on commit 81b718f

Please sign in to comment.