diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 91cfadd0..06b200a5 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -47,6 +47,7 @@ import { InfiniteScrollModule } from "ngx-infinite-scroll"; import { ShowGridComponent } from "./components/show-grid/show-grid.component"; import { MatBadgeModule } from "@angular/material/badge"; import { StartupService } from "./services/startup.service"; +import { LongPressDirective } from './misc/long-press.directive'; @NgModule({ @@ -69,7 +70,8 @@ import { StartupService } from "./services/startup.service"; FormatTimePipe, BufferToWidthPipe, VolumeToButtonPipe, - SupportedButtonPipe + SupportedButtonPipe, + LongPressDirective ], imports: [ BrowserModule, diff --git a/src/app/components/episodes-list/episodes-list.component.html b/src/app/components/episodes-list/episodes-list.component.html index 29438440..e9ca755b 100644 --- a/src/app/components/episodes-list/episodes-list.component.html +++ b/src/app/components/episodes-list/episodes-list.component.html @@ -1,12 +1,13 @@
+ [horizontal]="true" [scrollWindow]="false" + appLongPress (longPressed)="this.openMenu()"> - diff --git a/src/app/components/episodes-list/episodes-list.component.scss b/src/app/components/episodes-list/episodes-list.component.scss index 8fdf88a0..6e0c36bb 100644 --- a/src/app/components/episodes-list/episodes-list.component.scss +++ b/src/app/components/episodes-list/episodes-list.component.scss @@ -152,6 +152,7 @@ .moreBtn { display: block; + -webkit-touch-callout: none; } > div diff --git a/src/app/misc/long-press.directive.ts b/src/app/misc/long-press.directive.ts new file mode 100644 index 00000000..ae715406 --- /dev/null +++ b/src/app/misc/long-press.directive.ts @@ -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"; + +} diff --git a/static/favicon.ico b/static/favicon.ico index 41783f57..61e16024 100644 Binary files a/static/favicon.ico and b/static/favicon.ico differ