Files
psp_panel/src/app/domains/pos/layouts/layout.component.ts
T

54 lines
1.5 KiB
TypeScript
Raw Normal View History

import { CommonModule } from '@angular/common';
import { Component, computed, signal } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { PosSplashComponent } from '../components/splash.component';
import { PosPagesLayoutComponent } from './pagesLayout/layout.component';
2026-03-18 13:35:57 +03:30
@Component({
selector: 'pos-layout',
templateUrl: 'layout.component.html',
imports: [PosSplashComponent, PosPagesLayoutComponent, RouterOutlet, CommonModule],
2026-03-18 13:35:57 +03:30
})
export class PosLayoutComponent {
showSplash = signal(true);
isAuth = computed(() => window.location.pathname === '/auth');
private touchStartY = 0;
private pulling = false;
pullDistance = signal(0);
readonly pullThreshold = 80;
2026-03-18 13:35:57 +03:30
onSplashCompleted() {
this.showSplash.set(false);
}
onTouchStart(event: TouchEvent) {
if (window.scrollY > 0 || event.touches.length !== 1) return;
this.touchStartY = event.touches[0].clientY;
this.pulling = true;
}
onTouchMove(event: TouchEvent) {
if (!this.pulling) return;
const delta = event.touches[0].clientY - this.touchStartY;
if (delta <= 0) {
this.pullDistance.set(0);
return;
}
const damped = Math.min(delta * 0.5, 140);
this.pullDistance.set(damped);
event.preventDefault();
}
onTouchEnd() {
if (!this.pulling) return;
const shouldRefresh = this.pullDistance() >= this.pullThreshold;
this.pulling = false;
this.pullDistance.set(0);
if (shouldRefresh) {
this.showSplash.set(true);
}
}
2026-03-18 13:35:57 +03:30
}