mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Adding a long press action on episodes
This commit is contained in:
parent
d11cff9176
commit
1efeab69bb
@ -47,6 +47,7 @@ import { InfiniteScrollModule } from "ngx-infinite-scroll";
|
|||||||
import { ShowGridComponent } from "./components/show-grid/show-grid.component";
|
import { ShowGridComponent } from "./components/show-grid/show-grid.component";
|
||||||
import { MatBadgeModule } from "@angular/material/badge";
|
import { MatBadgeModule } from "@angular/material/badge";
|
||||||
import { StartupService } from "./services/startup.service";
|
import { StartupService } from "./services/startup.service";
|
||||||
|
import { LongPressDirective } from './misc/long-press.directive';
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@ -69,7 +70,8 @@ import { StartupService } from "./services/startup.service";
|
|||||||
FormatTimePipe,
|
FormatTimePipe,
|
||||||
BufferToWidthPipe,
|
BufferToWidthPipe,
|
||||||
VolumeToButtonPipe,
|
VolumeToButtonPipe,
|
||||||
SupportedButtonPipe
|
SupportedButtonPipe,
|
||||||
|
LongPressDirective
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
<div class="root">
|
<div class="root">
|
||||||
<div class="episodes" #scrollView
|
<div class="episodes" #scrollView
|
||||||
(scroll)="onScroll()" infinite-scroll (scrolled)="this.episodes?.loadNext(this.client)"
|
(scroll)="onScroll()" infinite-scroll (scrolled)="this.episodes?.loadNext(this.client)"
|
||||||
[horizontal]="true" [scrollWindow]="false">
|
[horizontal]="true" [scrollWindow]="false"
|
||||||
|
appLongPress (longPressed)="this.openMenu()">
|
||||||
<a *ngFor="let episode of this.episodes?.items"
|
<a *ngFor="let episode of this.episodes?.items"
|
||||||
routerLink="/watch/{{episode.slug}}" href="/watch/{{episode.slug}}"
|
routerLink="/watch/{{episode.slug}}" href="/watch/{{episode.slug}}"
|
||||||
class="episode" #itemsDom>
|
class="episode" #itemsDom>
|
||||||
<button mat-icon-button class="moreBtn" [matMenuTriggerFor]="more" [matMenuTriggerData]="{episode: episode}"
|
<button mat-icon-button class="moreBtn" tabindex="-1"
|
||||||
tabindex="-1"
|
[matMenuTriggerFor]="more" [matMenuTriggerData]="{episode: episode}"
|
||||||
(click)="$event.stopImmediatePropagation(); $event.preventDefault()">
|
(click)="$event.stopImmediatePropagation(); $event.preventDefault()">
|
||||||
<mat-icon>more_vert</mat-icon>
|
<mat-icon>more_vert</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
@ -152,6 +152,7 @@
|
|||||||
.moreBtn
|
.moreBtn
|
||||||
{
|
{
|
||||||
display: block;
|
display: block;
|
||||||
|
-webkit-touch-callout: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
> div
|
> div
|
||||||
|
43
src/app/misc/long-press.directive.ts
Normal file
43
src/app/misc/long-press.directive.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { Directive, Output, EventEmitter, HostListener, HostBinding } from "@angular/core";
|
||||||
|
|
||||||
|
@Directive({
|
||||||
|
selector: `[appLongPress]`
|
||||||
|
})
|
||||||
|
export class LongPressDirective
|
||||||
|
{
|
||||||
|
@Output() longPressed = new EventEmitter();
|
||||||
|
timer: NodeJS.Timeout = null;
|
||||||
|
|
||||||
|
@HostBinding('class.longpress')
|
||||||
|
get longPress(): boolean
|
||||||
|
{
|
||||||
|
return this.timer !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener("touchstart", ["$event"])
|
||||||
|
@HostListener("mousedown", ["$event"])
|
||||||
|
start(): void
|
||||||
|
{
|
||||||
|
this.timer = setTimeout(() => {
|
||||||
|
this.longPressed.emit();
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener("touchend", ["$event"])
|
||||||
|
@HostListener("mouseup", ["$event"])
|
||||||
|
end(): void
|
||||||
|
{
|
||||||
|
clearTimeout(this.timer);
|
||||||
|
this.timer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener("contextmenu", ["$event"])
|
||||||
|
context(event): void
|
||||||
|
{
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostBinding("style.-webkit-touch-callout")
|
||||||
|
defaultLongTouchEvent: string = "none";
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 15 KiB |
Loading…
x
Reference in New Issue
Block a user