Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

refactor(frontend): replace Hammer.js with `TapDirective` and remove related dependencies

johaven8bdd8acf7867
diff --git a/frontend/angular.json b/frontend/angular.json
index 12c10756..0217fd1c 100644
--- a/frontend/angular.json
+++ b/frontend/angular.json
@@ -42,7 +42,6 @@
"src/styles/index.scss"
],
"scripts": [
- "hammerjs/hammer.min.js",
"codemirror/lib/codemirror.js",
"codemirror/mode/meta.js",
"codemirror/addon/mode/loadmode.js",
diff --git a/frontend/package.json b/frontend/package.json
index 6ac5dab0..1efdce60 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -40,7 +40,6 @@
"angular-l10n": "^17.0.0",
"codemirror": "^5.65.16",
"dayjs": "^1.11.13",
- "hammerjs": "^2.0.8",
"ngx-bootstrap": "^20.0.0",
"ngx-clipboard": "^16.0.0",
"ngx-socket-io": "^4.9.3",
diff --git a/frontend/src/app/app.config.ts b/frontend/src/app/app.config.ts
index 916b40cf..90417394 100644
--- a/frontend/src/app/app.config.ts
+++ b/frontend/src/app/app.config.ts
@@ -7,7 +7,6 @@
import { HashLocationStrategy, LocationStrategy } from '@angular/common'
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi, withXsrfConfiguration } from '@angular/common/http'
import { ApplicationConfig, importProvidersFrom, provideZoneChangeDetection } from '@angular/core'
-import { HAMMER_GESTURE_CONFIG, HammerModule } from '@angular/platform-browser'
import { provideAnimations } from '@angular/platform-browser/animations'
import { provideRouter } from '@angular/router'
import { CSRF_KEY } from '@sync-in-server/backend/src/authentication/constants/auth'
@@ -17,7 +16,6 @@ import { TooltipConfig } from 'ngx-bootstrap/tooltip'
import { SocketIoModule } from 'ngx-socket-io'
import { provideToastr } from 'ngx-toastr'
import { l10nConfig, TranslationStorage } from '../i18n/l10n'
-import { AppHammerConfig } from './app.hammer'
import { routes } from './app.routes'
import { AuthInterceptor } from './auth/auth.interceptor'
import { getToolTipConfig } from './layout/layout.tooltip.config'
@@ -32,8 +30,6 @@ export const appConfig: ApplicationConfig = {
provideHttpClient(withInterceptorsFromDi(), withXsrfConfiguration({ cookieName: CSRF_KEY, headerName: CSRF_KEY })),
provideL10nTranslation(l10nConfig, { storage: TranslationStorage }),
provideL10nIntl(),
- importProvidersFrom(HammerModule),
- { provide: HAMMER_GESTURE_CONFIG, useClass: AppHammerConfig },
provideAnimations(),
provideToastr({ positionClass: 'toast-bottom-right', preventDuplicates: false, timeOut: 7000 }),
{ provide: TooltipConfig, useFactory: getToolTipConfig },
diff --git a/frontend/src/app/app.hammer.ts b/frontend/src/app/app.hammer.ts
deleted file mode 100644
index dbacdcc8..00000000
--- a/frontend/src/app/app.hammer.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2012-2025 Johan Legrand <[email protected]>
- * This file is part of Sync-in | The open source file sync and share solution
- * See the LICENSE file for licensing details
- */
-
-import { Injectable } from '@angular/core'
-import { HammerGestureConfig } from '@angular/platform-browser'
-
-@Injectable({
- providedIn: 'root'
-})
-export class AppHammerConfig extends HammerGestureConfig {
- override overrides = {
- pinch: { enable: false },
- swipe: { enable: false },
- pan: { enable: false },
- rotate: { enable: false },
- tap: { taps: 2, interval: 600 }
- } as any
-}
diff --git a/frontend/src/app/applications/admin/components/admin-groups.component.html b/frontend/src/app/applications/admin/components/admin-groups.component.html
index bdee41ff..113b8f8a 100644
--- a/frontend/src/app/applications/admin/components/admin-groups.component.html
+++ b/frontend/src/app/applications/admin/components/admin-groups.component.html
@@ -100,8 +100,7 @@
@for (m of scrollView?.viewPortItems; track m.mid) {
<tr (click)="onSelect(m)"
(contextmenu)="onTargetContextMenu($event, m)"
- (pressup)="onTargetContextMenu($event, m)"
- (tap)="browse(m)"
+ (appTap)="browse(m)"
[class.selected]="m.mid === selected?.mid">
@for (th of tableHeaders | keyvalue: originalOrderKeyValue; track th.key) {
@if (th.value.show) {
diff --git a/frontend/src/app/applications/admin/components/admin-groups.component.ts b/frontend/src/app/applications/admin/components/admin-groups.component.ts
index 00248967..6918a805 100644
--- a/frontend/src/app/applications/admin/components/admin-groups.component.ts
+++ b/frontend/src/app/applications/admin/components/admin-groups.component.ts
@@ -36,6 +36,7 @@ import { TooltipDirective } from 'ngx-bootstrap/tooltip'
import { filter, take } from 'rxjs/operators'
import { FilterComponent } from '../../../common/components/filter.component'
import { VirtualScrollComponent } from '../../../common/components/virtual-scroll.component'
+import { TapDirective } from '../../../common/directives/tap.directive'
import { TableHeaderConfig } from '../../../common/interfaces/table.interface'
import { JoinCountsPipe } from '../../../common/pipes/join-counts.pipe'
import { SearchFilterPipe } from '../../../common/pipes/search.pipe'
@@ -73,7 +74,8 @@ import { AdminGroupEditUserDialogComponent } from './dialogs/admin-group-edit-us
BsDropdownToggleDirective,
BsDropdownMenuDirective,
ButtonCheckboxDirective,
- FormsModule
+ FormsModule,
+ TapDirective
],
templateUrl: 'admin-groups.component.html'
})
diff --git a/frontend/src/app/applications/admin/components/admin-users.component.html b/frontend/src/app/applications/admin/components/admin-users.component.html
index 23237f57..ff861af2 100644
--- a/frontend/src/app/applications/admin/components/admin-users.component.html
+++ b/frontend/src/app/applications/admin/components/admin-users.component.html
@@ -85,8 +85,7 @@
@for (u of scrollView?.viewPortItems; track u.id) {
<tr (click)="onSelect(u)"
(contextmenu)="onTargetContextMenu($event, u)"
- (pressup)="onTargetContextMenu($event, u)"
- (tap)="openDialog()"
+ (appTap)="openDialog()"
[class.disabled]="!u.isActive"
[class.selected]="u.id === selected?.id">
@for (th of tableHeaders | keyvalue: originalOrderKeyValue; track th.key) {
diff --git a/frontend/src/app/applications/admin/components/admin-users.component.ts b/frontend/src/app/applications/admin/components/admin-users.component.ts
index 75f0763d..f6647b7b 100644
--- a/frontend/src/app/applications/admin/components/admin-users.component.ts
+++ b/frontend/src/app/applications/admin/components/admin-users.component.ts
@@ -33,6 +33,7 @@ import { take } from 'rxjs/operators'
import { FilterComponent } from '../../../common/components/filter.component'
import { StorageUsageComponent } from '../../../common/components/storage-usage.component'
import { VirtualScrollComponent } from '../../../common/components/virtual-scroll.component'
+import { TapDirective } from '../../../common/directives/tap.directive'
import { TableHeaderConfig } from '../../../common/interfaces/table.interface'
import { SearchFilterPipe } from '../../../common/pipes/search.pipe'
import { TimeDateFormatPipe } from '../../../common/pipes/time-date-format.pipe'
@@ -64,7 +65,8 @@ import { AdminUserDialogComponent } from './dialogs/admin-user-dialog.component'
ContextMenuModule,
ButtonCheckboxDirective,
FormsModule,
- UserAvatarComponent
+ UserAvatarComponent,
+ TapDirective
],
templateUrl: 'admin-users.component.html'
})
diff --git a/frontend/src/app/applications/files/components/sidebar/files-tree.component.html b/frontend/src/app/applications/files/components/sidebar/files-tree.component.html
index 0711845e..8129b6a5 100644
--- a/frontend/src/app/applications/files/components/sidebar/files-tree.component.html
+++ b/frontend/src/app/applications/files/components/sidebar/files-tree.component.html
@@ -62,7 +62,7 @@
<tree-root #tree [nodes]="nodes" [options]="options">
<ng-template #treeNodeWrapperTemplate let-index="index" let-node>
<div (click)="node.mouseAction('click', $event)"
- (tap)="node.mouseAction('dblClick', $event)"
+ (appTap)="node.mouseAction('dblClick', $event)"
[class.tree-selected]="node.isActive"
[class.tree-disabled]="!node.data.enabled"
[style.padding-left]="node.getNodePadding()"
diff --git a/frontend/src/app/applications/files/components/sidebar/files-tree.component.ts b/frontend/src/app/applications/files/components/sidebar/files-tree.component.ts
index ad5da089..bd6922d7 100644
--- a/frontend/src/app/applications/files/components/sidebar/files-tree.component.ts
+++ b/frontend/src/app/applications/files/components/sidebar/files-tree.component.ts
@@ -18,6 +18,7 @@ import { USER_PERMISSION } from '@sync-in-server/backend/src/applications/users/
import { L10nTranslateDirective } from 'angular-l10n'
import { Subscription } from 'rxjs'
import { AutoResizeDirective } from '../../../../common/directives/auto-resize.directive'
+import { TapDirective } from '../../../../common/directives/tap.directive'
import { defaultResizeOffset } from '../../../../layout/layout.constants'
import { LayoutService } from '../../../../layout/layout.service'
import { StoreService } from '../../../../store/store.service'
@@ -28,7 +29,7 @@ import { FilesService } from '../../services/files.service'
@Component({
selector: 'app-files-tree',
- imports: [AutoResizeDirective, TreeModule, L10nTranslateDirective, FaIconComponent],
+ imports: [AutoResizeDirective, TreeModule, L10nTranslateDirective, FaIconComponent, TapDirective],
templateUrl: 'files-tree.component.html'
})
export class FilesTreeComponent implements OnInit, OnDestroy {
diff --git a/frontend/src/app/applications/links/components/links.component.html b/frontend/src/app/applications/links/components/links.component.html
index 58c6b1ba..a0b37787 100644
--- a/frontend/src/app/applications/links/components/links.component.html
+++ b/frontend/src/app/applications/links/components/links.component.html
@@ -65,8 +65,7 @@
@for (s of scrollView?.viewPortItems; track s.id) {
<div (click)="onSelect(s)"
(contextmenu)="onTargetContextMenu($event, s)"
- (pressup)="onTargetContextMenu($event, s)"
- (tap)="openLinkDialog()"
+ (appTap)="openLinkDialog()"
[class.selected]="s.id === selected?.id"
[class.disabled]="!s.link.isActive"
[style.height.px]="galleryMode.dimensions"
@@ -125,8 +124,7 @@
@for (s of scrollView?.viewPortItems; track s.id) {
<tr (click)="onSelect(s)"
(contextmenu)="onTargetContextMenu($event, s)"
- (pressup)="onTargetContextMenu($event, s)"
- (tap)="openLinkDialog()"
+ (appTap)="openLinkDialog()"
[class.selected]="s.id === selected?.id"
[class.disabled]="!s.link.isActive">
@for (th of tableHeaders | keyvalue: originalOrderKeyValue; track th.key) {
diff --git a/frontend/src/app/applications/links/components/links.component.ts b/frontend/src/app/applications/links/components/links.component.ts
index 559781e1..6b230c5f 100644
--- a/frontend/src/app/applications/links/components/links.component.ts
+++ b/frontend/src/app/applications/links/components/links.component.ts
@@ -31,6 +31,7 @@ import { take } from 'rxjs/operators'
import { FilterComponent } from '../../../common/components/filter.component'
import { NavigationViewComponent, ViewMode } from '../../../common/components/navigation-view/navigation-view.component'
import { VirtualScrollComponent } from '../../../common/components/virtual-scroll.component'
+import { TapDirective } from '../../../common/directives/tap.directive'
import { TableHeaderConfig } from '../../../common/interfaces/table.interface'
import { SearchFilterPipe } from '../../../common/pipes/search.pipe'
import { originalOrderKeyValue } from '../../../common/utils/functions'
@@ -61,7 +62,8 @@ import { LinkDialogComponent } from './dialogs/link-dialog.component'
VirtualScrollComponent,
SearchFilterPipe,
ShareRepositoryComponent,
- FilePermissionsComponent
+ FilePermissionsComponent,
+ TapDirective
],
templateUrl: 'links.component.html'
})
diff --git a/frontend/src/app/applications/search/components/search.component.html b/frontend/src/app/applications/search/components/search.component.html
index 30c186db..ae3810a0 100644
--- a/frontend/src/app/applications/search/components/search.component.html
+++ b/frontend/src/app/applications/search/components/search.component.html
@@ -45,7 +45,7 @@
<div class="p-3 text-danger fw-500">{{ errorMessage }}</div>
}
@for (f of this.store.filesSearch() | searchFilter:inputFilter.search(); track f.id) {
- <div class="app-div-striped py-2" (click)="selectedId = f.id" (tap)="goTo(f)" [class.selected]="f.id === selectedId">
+ <div class="app-div-striped py-2" (click)="selectedId = f.id" (appTap)="goTo(f)" [class.selected]="f.id === selectedId">
<div class="d-flex align-items-center text-truncate px-2 py-1">
<img [src]="f.mimeUrl" (error)="f.fallBackMimeUrl()" alt="" draggable="false" height="28">
<div class="d-flex flex-column text-truncate ms-2" style="height: 34px">
diff --git a/frontend/src/app/applications/search/components/search.component.ts b/frontend/src/app/applications/search/components/search.component.ts
index 305d4fd0..00b4d7b0 100644
--- a/frontend/src/app/applications/search/components/search.component.ts
+++ b/frontend/src/app/applications/search/components/search.component.ts
@@ -18,6 +18,7 @@ import { TooltipDirective } from 'ngx-bootstrap/tooltip'
import { FilterComponent } from '../../../common/components/filter.component'
import { AutofocusDirective } from '../../../common/directives/auto-focus.directive'
import { AutoResizeDirective } from '../../../common/directives/auto-resize.directive'
+import { TapDirective } from '../../../common/directives/tap.directive'
import { SearchFilterPipe } from '../../../common/pipes/search.pipe'
import { LayoutService } from '../../../layout/layout.service'
import { StoreService } from '../../../store/store.service'
@@ -37,7 +38,8 @@ import { SEARCH_ICON, SEARCH_PATH } from '../search.constants'
FormsModule,
AutoResizeDirective,
TooltipDirective,
- SearchFilterPipe
+ SearchFilterPipe,
+ TapDirective
],
templateUrl: './search.component.html'
})
diff --git a/frontend/src/app/applications/shares/components/shared.component.html b/frontend/src/app/applications/shares/components/shared.component.html
index cb03e04f..449e79f5 100644
--- a/frontend/src/app/applications/shares/components/shared.component.html
+++ b/frontend/src/app/applications/shares/components/shared.component.html
@@ -73,8 +73,7 @@
@for (s of scrollView?.viewPortItems; track s.id) {
<div (click)="onSelect(s)"
(contextmenu)="onTargetContextMenu($event, s)"
- (pressup)="onTargetContextMenu($event, s)"
- (tap)="openShareDialog()"
+ (appTap)="openShareDialog()"
[class.disabled]="!s.enabled"
[class.selected]="s.id === selected?.id"
[style.height.px]="galleryMode.dimensions"
@@ -141,8 +140,7 @@
@for (s of scrollView?.viewPortItems; track s.id) {
<tr (click)="onSelect(s)"
(contextmenu)="onTargetContextMenu($event, s)"
- (pressup)="onTargetContextMenu($event, s)"
- (tap)="openShareDialog()"
+ (appTap)="openShareDialog()"
[class.disabled]="!s.enabled"
[class.selected]="s.id === selected?.id">
@for (th of tableHeaders | keyvalue: originalOrderKeyValue; track th.key) {
diff --git a/frontend/src/app/applications/shares/components/shared.component.ts b/frontend/src/app/applications/shares/components/shared.component.ts
index cb13ca31..e95f7d67 100644
--- a/frontend/src/app/applications/shares/components/shared.component.ts
+++ b/frontend/src/app/applications/shares/components/shared.component.ts
@@ -32,6 +32,7 @@ import { take } from 'rxjs/operators'
import { FilterComponent } from '../../../common/components/filter.component'
import { NavigationViewComponent, ViewMode } from '../../../common/components/navigation-view/navigation-view.component'
import { VirtualScrollComponent } from '../../../common/components/virtual-scroll.component'
+import { TapDirective } from '../../../common/directives/tap.directive'
import { TableHeaderConfig } from '../../../common/interfaces/table.interface'
import { JoinCountsPipe } from '../../../common/pipes/join-counts.pipe'
import { SearchFilterPipe } from '../../../common/pipes/search.pipe'
@@ -63,7 +64,8 @@ import { ShareRepositoryComponent } from './utils/share-repository.component'
JoinCountsPipe,
BsDropdownModule,
ContextMenuModule,
- ShareRepositoryComponent
+ ShareRepositoryComponent,
+ TapDirective
],
templateUrl: 'shared.component.html'
})
diff --git a/frontend/src/app/applications/spaces/components/spaces-browser.component.html b/frontend/src/app/applications/spaces/components/spaces-browser.component.html
index 5549b48b..afe75290 100644
--- a/frontend/src/app/applications/spaces/components/spaces-browser.component.html
+++ b/frontend/src/app/applications/spaces/components/spaces-browser.component.html
@@ -232,8 +232,7 @@
@for (f of scrollView?.viewPortItems; track f.id) {
<div (click)="onSelect($event, f)"
(contextmenu)="onTargetContextMenu($event, f)"
- (pressup)="onTargetContextMenu($event, f)"
- (tap)="browse(f)"
+ (appTap)="browse(f)"
[class.disabled]="f.isDisabled"
[class.deleted]="f.isBeingDeleted"
[class.selected]="f.isSelected"
@@ -353,8 +352,7 @@
@for (f of scrollView?.viewPortItems; track f.id) {
<tr (click)="onSelect($event, f)"
(contextmenu)="onTargetContextMenu($event, f)"
- (pressup)="onTargetContextMenu($event, f)"
- (tap)="browse(f)"
+ (appTap)="browse(f)"
[class.disabled]="f.isDisabled"
[class.deleted]="f.isBeingDeleted"
[class.selected]="f.isSelected">
diff --git a/frontend/src/app/applications/spaces/components/spaces-browser.component.ts b/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
index 9943414f..50c7a790 100644
--- a/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
+++ b/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
@@ -54,6 +54,7 @@ import { FilterComponent } from '../../../common/components/filter.component'
import { NavigationViewComponent, ViewMode } from '../../../common/components/navigation-view/navigation-view.component'
import { VirtualScrollComponent } from '../../../common/components/virtual-scroll.component'
import { InputEditDirective } from '../../../common/directives/input-edit.directive'
+import { TapDirective } from '../../../common/directives/tap.directive'
import { UploadFilesDirective } from '../../../common/directives/upload-files.directive'
import { TableHeaderConfig } from '../../../common/interfaces/table.interface'
import { SearchFilterPipe } from '../../../common/pipes/search.pipe'
@@ -103,7 +104,8 @@ import { SpaceAnchorFileDialogComponent } from './dialogs/space-anchor-file-dial
SearchFilterPipe,
UserAvatarComponent,
UploadFilesDirective,
- FilePermissionsComponent
+ FilePermissionsComponent,
+ TapDirective
],
templateUrl: 'spaces-browser.component.html'
})
diff --git a/frontend/src/app/applications/spaces/components/spaces.component.html b/frontend/src/app/applications/spaces/components/spaces.component.html
index 24eff2f6..c04edbdc 100644
--- a/frontend/src/app/applications/spaces/components/spaces.component.html
+++ b/frontend/src/app/applications/spaces/components/spaces.component.html
@@ -75,8 +75,7 @@
@for (s of scrollView?.viewPortItems; track s.id) {
<div (click)="onSelect(s)"
(contextmenu)="onTargetContextMenu($event, s)"
- (pressup)="onTargetContextMenu($event, s)"
- (tap)="browse(s)"
+ (appTap)="browse(s)"
[class.disabled]="!s.enabled"
[class.selected]="s.id === selected?.id"
[style.height.px]="galleryMode.dimensions"
@@ -142,8 +141,7 @@
@for (s of scrollView?.viewPortItems; track s.id) {
<tr (click)="onSelect(s)"
(contextmenu)="onTargetContextMenu($event, s)"
- (pressup)="onTargetContextMenu($event, s)"
- (tap)="browse(s)"
+ (appTap)="browse(s)"
[class.disabled]="!s.enabled"
[class.selected]="s.id === selected?.id">
@for (th of tableHeaders | keyvalue: originalOrderKeyValue; track th.key) {
diff --git a/frontend/src/app/applications/spaces/components/spaces.component.ts b/frontend/src/app/applications/spaces/components/spaces.component.ts
index 8cfb6959..d1b04e39 100644
--- a/frontend/src/app/applications/spaces/components/spaces.component.ts
+++ b/frontend/src/app/applications/spaces/components/spaces.component.ts
@@ -31,6 +31,7 @@ import { take } from 'rxjs/operators'
import { FilterComponent } from '../../../common/components/filter.component'
import { NavigationViewComponent, ViewMode } from '../../../common/components/navigation-view/navigation-view.component'
import { VirtualScrollComponent } from '../../../common/components/virtual-scroll.component'
+import { TapDirective } from '../../../common/directives/tap.directive'
import { TableHeaderConfig } from '../../../common/interfaces/table.interface'
import { JoinCountsPipe } from '../../../common/pipes/join-counts.pipe'
import { SearchFilterPipe } from '../../../common/pipes/search.pipe'
@@ -64,7 +65,8 @@ import { SpaceUserAnchorsDialogComponent } from './dialogs/space-user-anchors-di
NavigationViewComponent,
FilterComponent,
SearchFilterPipe,
- FilePermissionsComponent
+ FilePermissionsComponent,
+ TapDirective
],
templateUrl: 'spaces.component.html'
})
diff --git a/frontend/src/app/applications/spaces/components/trash.component.html b/frontend/src/app/applications/spaces/components/trash.component.html
index f3ca7107..c593552d 100644
--- a/frontend/src/app/applications/spaces/components/trash.component.html
+++ b/frontend/src/app/applications/spaces/components/trash.component.html
@@ -42,8 +42,7 @@
@for (t of scrollView?.viewPortItems; track t.id) {
<div (click)="onSelect(t)"
(contextmenu)="onTargetContextMenu($event, t)"
- (pressup)="onTargetContextMenu($event, t)"
- (tap)="browse(t)"
+ (appTap)="browse(t)"
[class.selected]="t.id === selected?.id"
[style.height.px]="galleryMode.dimensions"
[style.width.px]="galleryMode.dimensions"
@@ -110,8 +109,7 @@
@for (t of scrollView?.viewPortItems; track t.id) {
<tr (click)="onSelect(t)"
(contextmenu)="onTargetContextMenu($event, t)"
- (pressup)="onTargetContextMenu($event, t)"
- (tap)="browse(t)"
+ (appTap)="browse(t)"
[class.selected]="t.id === selected?.id">
@for (th of tableHeaders | keyvalue: originalOrderKeyValue; track th.key) {
@if (th.value.show) {
diff --git a/frontend/src/app/applications/spaces/components/trash.component.ts b/frontend/src/app/applications/spaces/components/trash.component.ts
index 2a674235..96d47848 100644
--- a/frontend/src/app/applications/spaces/components/trash.component.ts
+++ b/frontend/src/app/applications/spaces/components/trash.component.ts
@@ -16,6 +16,7 @@ import { TooltipModule } from 'ngx-bootstrap/tooltip'
import { FilterComponent } from '../../../common/components/filter.component'
import { NavigationViewComponent, ViewMode } from '../../../common/components/navigation-view/navigation-view.component'
import { VirtualScrollComponent } from '../../../common/components/virtual-scroll.component'
+import { TapDirective } from '../../../common/directives/tap.directive'
import { TableHeaderConfig } from '../../../common/interfaces/table.interface'
import { SearchFilterPipe } from '../../../common/pipes/search.pipe'
import { originalOrderKeyValue } from '../../../common/utils/functions'
@@ -39,7 +40,8 @@ import { SPACES_ICON, SPACES_PATH, SPACES_TITLE } from '../spaces.constants'
VirtualScrollComponent,
SearchFilterPipe,
L10nTranslateDirective,
- ContextMenuModule
+ ContextMenuModule,
+ TapDirective
],
templateUrl: 'trash.component.html'
})
diff --git a/frontend/src/app/applications/users/components/user-groups.component.html b/frontend/src/app/applications/users/components/user-groups.component.html
index 2219f977..136cf46b 100644
--- a/frontend/src/app/applications/users/components/user-groups.component.html
+++ b/frontend/src/app/applications/users/components/user-groups.component.html
@@ -94,8 +94,7 @@
@for (m of scrollView?.viewPortItems; track m.mid) {
<tr (click)="onSelect(m)"
(contextmenu)="onTargetContextMenu($event, m)"
- (pressup)="onTargetContextMenu($event, m)"
- (tap)="browse(m)"
+ (appTap)="browse(m)"
[class.selected]="m.mid === selected?.mid">
@for (th of tableHeaders | keyvalue: originalOrderKeyValue; track th.key) {
@if (th.value.show) {
diff --git a/frontend/src/app/applications/users/components/user-groups.component.ts b/frontend/src/app/applications/users/components/user-groups.component.ts
index fa261ceb..7bcc2939 100644
--- a/frontend/src/app/applications/users/components/user-groups.component.ts
+++ b/frontend/src/app/applications/users/components/user-groups.component.ts
@@ -32,6 +32,7 @@ import { TooltipDirective } from 'ngx-bootstrap/tooltip'
import { filter, take } from 'rxjs/operators'
import { FilterComponent } from '../../../common/components/filter.component'
import { VirtualScrollComponent } from '../../../common/components/virtual-scroll.component'
+import { TapDirective } from '../../../common/directives/tap.directive'
import { TableHeaderConfig } from '../../../common/interfaces/table.interface'
import { JoinCountsPipe } from '../../../common/pipes/join-counts.pipe'
import { SearchFilterPipe } from '../../../common/pipes/search.pipe'
@@ -65,7 +66,8 @@ import { UserPersonalGroupLeaveDialogComponent } from './dialogs/user-personal-g
TimeAgoPipe,
BsDropdownDirective,
BsDropdownToggleDirective,
- BsDropdownMenuDirective
+ BsDropdownMenuDirective,
+ TapDirective
],
templateUrl: 'user-groups.component.html'
})
diff --git a/frontend/src/app/applications/users/components/user-guests.component.html b/frontend/src/app/applications/users/components/user-guests.component.html
index 22dbbc1f..86897bef 100644
--- a/frontend/src/app/applications/users/components/user-guests.component.html
+++ b/frontend/src/app/applications/users/components/user-guests.component.html
@@ -64,8 +64,7 @@
@for (u of scrollView?.viewPortItems; track u.id) {
<tr (click)="onSelect(u)"
(contextmenu)="onTargetContextMenu($event, u)"
- (pressup)="onTargetContextMenu($event, u)"
- (tap)="openGuestDialog()"
+ (appTap)="openGuestDialog()"
[class.disabled]="!u.isActive"
[class.selected]="u.id === selected?.id">
@for (th of tableHeaders | keyvalue: originalOrderKeyValue; track th.key) {
diff --git a/frontend/src/app/applications/users/components/user-guests.component.ts b/frontend/src/app/applications/users/components/user-guests.component.ts
index c3e2799d..59c2eb0f 100644
--- a/frontend/src/app/applications/users/components/user-guests.component.ts
+++ b/frontend/src/app/applications/users/components/user-guests.component.ts
@@ -17,6 +17,7 @@ import { TooltipDirective } from 'ngx-bootstrap/tooltip'
import { take } from 'rxjs/operators'
import { FilterComponent } from '../../../common/components/filter.component'
import { VirtualScrollComponent } from '../../../common/components/virtual-scroll.component'
+import { TapDirective } from '../../../common/directives/tap.directive'
import { TableHeaderConfig } from '../../../common/interfaces/table.interface'
import { SearchFilterPipe } from '../../../common/pipes/search.pipe'
import { TimeDateFormatPipe } from '../../../common/pipes/time-date-format.pipe'
@@ -42,7 +43,8 @@ import { UserAvatarComponent } from './utils/user-avatar.component'
SearchFilterPipe,
TimeDateFormatPipe,
ContextMenuModule,
- UserAvatarComponent
+ UserAvatarComponent,
+ TapDirective
],
templateUrl: 'user-guests.component.html'
})
diff --git a/frontend/src/app/common/directives/tap.directive.ts b/frontend/src/app/common/directives/tap.directive.ts
new file mode 100644
index 00000000..a4bbf54e
--- /dev/null
+++ b/frontend/src/app/common/directives/tap.directive.ts
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2012-2025 Johan Legrand <[email protected]>
+ * This file is part of Sync-in | The open source file sync and share solution
+ * See the LICENSE file for licensing details
+ */
+
+import { Directive, ElementRef, EventEmitter, inject, Input, NgZone, OnDestroy, Output } from '@angular/core'
+
+type TapKind = 'single' | 'double'
+interface TapEvent {
+ x: number
+ y: number
+ type: TapKind
+ sourceEvent?: PointerEvent | KeyboardEvent
+}
+
+@Directive({
+ selector: '[appTap]',
+ standalone: true,
+ host: {
+ style: 'touch-action: manipulation; -webkit-tap-highlight-color: transparent;'
+ }
+})
+export class TapDirective implements OnDestroy {
+ /** Movement tolerance (in px) for a valid tap */
+ @Input() maxMove = 10
+ /** Maximum duration (in ms) for a single tap */
+ @Input() maxDuration = 350
+ /** Maximum interval (in ms) between two taps to be considered a double tap */
+ @Input() doubleTapInterval = 600
+ /** Maximum distance (in px) between the two taps for a double tap */
+ @Input() doubleTapSlop = 24
+ /** Enables or disables double-tap detection */
+ @Input() enableDoubleTap = true
+ /**
+ * ⚙️ Hammer-like behavior control.
+ * false → STRICT Hammer mode: no single tap is emitted if the second tap does not occur (default)
+ * true → emits a delayed single tap if no second tap is detected within the interval
+ */
+ @Input() emitSingleWhenNoDouble = false
+
+ @Input() preventGhostClick = true
+ @Input() preventDefault = false
+ @Input() disabled = false
+
+ @Output() appTap = new EventEmitter<TapEvent>()
+
+ private readonly elRef = inject<ElementRef<HTMLElement>>(ElementRef as any)
+ private readonly zone = inject(NgZone)
+ private el: HTMLElement
+ private removeFns: (() => void)[] = []
+ private active = false
+ private pointerId: number | null = null
+ private startX = 0
+ private startY = 0
+ private startTime = 0
+ private moved = false
+ private lastEmitTs = 0
+
+ private pendingSingle: { x: number; y: number; t: number } | null = null
+ private singleTimer: any = null
+
+ constructor() {
+ this.el = this.elRef.nativeElement
+ this.zone.runOutsideAngular(() => {
+ this.add('pointerdown', this.onDown, { passive: true })
+ this.add('pointermove', this.onMove, { passive: true })
+ this.add('pointerup', this.onUp, { passive: false })
+ this.add('pointercancel', this.onCancel, { passive: true })
+ this.add('pointerleave', this.onCancel, { passive: true })
+ this.add('keydown', this.onKey, { passive: false })
+ this.add('contextmenu', this.onContextMenu, { passive: false })
+ this.add('click', this.onNativeClick, { passive: false, capture: true })
+ })
+ }
+
+ ngOnDestroy() {
+ for (const off of this.removeFns) off()
+ this.removeFns = []
+ clearTimeout(this.singleTimer)
+ }
+
+ private onDown = (ev: PointerEvent) => {
+ if (this.disabled || ev.button !== 0 || this.active) return
+ this.active = true
+ this.pointerId = ev.pointerId
+ this.startX = ev.clientX
+ this.startY = ev.clientY
+ this.startTime = ev.timeStamp
+ this.moved = false
+ ;(ev.target as Element).setPointerCapture?.(ev.pointerId)
+ }
+
+ private onMove = (ev: PointerEvent) => {
+ if (!this.active || ev.pointerId !== this.pointerId) return
+ if (!this.moved) {
+ const dx = Math.abs(ev.clientX - this.startX)
+ const dy = Math.abs(ev.clientY - this.startY)
+ if (dx > this.maxMove || dy > this.maxMove) this.moved = true
+ }
+ }
+
+ private onUp = (ev: PointerEvent) => {
+ if (!this.active || ev.pointerId !== this.pointerId) return
+ const dt = ev.timeStamp - this.startTime
+ const dx = Math.abs(ev.clientX - this.startX)
+ const dy = Math.abs(ev.clientY - this.startY)
+ const isTap = !this.moved && dx <= this.maxMove && dy <= this.maxMove && dt <= this.maxDuration
+ this.resetGesture()
+ if (!isTap) return
+
+ if (this.preventDefault) ev.preventDefault()
+
+ const now = performance.now()
+ const x = ev.clientX
+ const y = ev.clientY
+
+ if (!this.enableDoubleTap) {
+ this.emit('single', x, y, ev)
+ return
+ }
+
+ // Double tap detection
+ if (this.pendingSingle) {
+ const dt2 = now - this.pendingSingle.t
+ const dist = Math.hypot(x - this.pendingSingle.x, y - this.pendingSingle.y)
+ if (dt2 <= this.doubleTapInterval && dist <= this.doubleTapSlop) {
+ clearTimeout(this.singleTimer)
+ this.singleTimer = null
+ this.pendingSingle = null
+ this.emit('double', x, y, ev)
+ return
+ }
+ }
+
+ // First tap
+ this.pendingSingle = { x, y, t: now }
+ clearTimeout(this.singleTimer)
+ this.singleTimer = setTimeout(() => {
+ if (this.emitSingleWhenNoDouble) {
+ const p = this.pendingSingle!
+ this.emit('single', p.x, p.y)
+ }
+ this.pendingSingle = null
+ this.singleTimer = null
+ }, this.doubleTapInterval)
+ }
+
+ private onCancel = () => this.resetGesture()
+
+ private onKey = (ev: KeyboardEvent) => {
+ if (this.disabled) return
+ const k = ev.key.toLowerCase()
+ if (k === 'enter' || k === ' ') {
+ ev.preventDefault()
+ if (this.enableDoubleTap && !this.emitSingleWhenNoDouble) return
+ this.emit('single', 0, 0, ev)
+ }
+ }
+
+ private onContextMenu = (ev: MouseEvent) => {
+ if (this.preventDefault) ev.preventDefault()
+ }
+
+ private onNativeClick = (ev: MouseEvent) => {
+ if (!this.preventGhostClick) return
+ if (performance.now() - this.lastEmitTs < 350) {
+ ev.stopImmediatePropagation()
+ ev.stopPropagation()
+ ev.preventDefault()
+ }
+ }
+
+ private emit(type: TapKind, x: number, y: number, sourceEvent?: PointerEvent | KeyboardEvent) {
+ this.lastEmitTs = performance.now()
+ this.zone.run(() => this.appTap.emit({ x, y, type, sourceEvent }))
+ }
+
+ private add<K extends keyof HTMLElementEventMap>(type: K, handler: (ev: any) => void, opts?: AddEventListenerOptions & { capture?: boolean }) {
+ this.el.addEventListener(type, handler as EventListener, opts)
+ this.removeFns.push(() => this.el.removeEventListener(type, handler as EventListener, opts))
+ }
+
+ private resetGesture() {
+ this.active = false
+ this.pointerId = null
+ this.startTime = 0
+ }
+}
diff --git a/package-lock.json b/package-lock.json
index 948459d0..fee2107d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -166,7 +166,6 @@
"angular-l10n": "^17.0.0",
"codemirror": "^5.65.16",
"dayjs": "^1.11.13",
- "hammerjs": "^2.0.8",
"ngx-bootstrap": "^20.0.0",
"ngx-clipboard": "^16.0.0",
"ngx-socket-io": "^4.9.3",
@@ -17976,15 +17975,6 @@
"dev": true,
"license": "MIT"
},
- "node_modules/hammerjs": {
- "version": "2.0.8",
- "resolved": "https://registry.npmjs.org/hammerjs/-/hammerjs-2.0.8.tgz",
- "integrity": "sha512-tSQXBXS/MWQOn/RKckawJ61vvsDpCom87JgxiYdGwHdOa0ht0vzUWDlfioofFCRU0L+6NGDt6XzbgoJvZkMeRQ==",
- "license": "MIT",
- "engines": {
- "node": ">=0.8.0"
- }
- },
"node_modules/handlebars": {
"version": "4.7.8",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz",