Skip to content

Commit 96206cc

Browse files
committed
fix projects filter & add swipe to close
1 parent faf5835 commit 96206cc

5 files changed

Lines changed: 77 additions & 14 deletions

File tree

projects/social_platform/src/app/office/projects/list/list.component.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@
2424
@if (isAll) {
2525
<div class="filter page__filter" [class.page__filter--open]="isFilterOpen">
2626
<div class="filter__overlay" (click)="isFilterOpen = false"></div>
27-
<div class="filter__body">
28-
<div class="filter__bar"></div>
29-
<app-projects-filter></app-projects-filter>
27+
<div class="filter__body" #filterBody>
28+
<div
29+
class="filter__bar"
30+
(touchstart)="onSwipeStart($event)"
31+
(touchmove)="onSwipeMove($event)"
32+
(touchend)="onSwipeEnd($event)"
33+
></div>
34+
<app-projects-filter (closeFilter)="closeFilter()"></app-projects-filter>
3035
</div>
3136
</div>
3237
} @else if (!searchedProjects.length && isMy) {

projects/social_platform/src/app/office/projects/list/list.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
display: flex;
7171
width: 100%;
7272
height: 25px;
73+
touch-action: none;
7374

7475
@include responsive.apply-desktop {
7576
display: none;
@@ -83,6 +84,7 @@
8384
content: "";
8485
background-color: var(--gray);
8586
border-radius: var(--rounded-lg);
87+
transition: transform 0.2s;
8688
}
8789
}
8890

@@ -96,10 +98,12 @@
9698
overflow-y: auto;
9799
background-color: var(--white);
98100
border-radius: var(--rounded-lg);
101+
transform: translateY(0%);
99102

100103
@include responsive.apply-desktop {
101104
position: static;
102105
max-height: unset;
106+
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
103107
}
104108
}
105109
}

projects/social_platform/src/app/office/projects/list/list.component.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ElementRef,
88
OnDestroy,
99
OnInit,
10+
Renderer2,
1011
ViewChild,
1112
} from "@angular/core";
1213
import { ActivatedRoute, NavigationEnd, Params, Router, RouterLink } from "@angular/router";
@@ -50,9 +51,12 @@ export class ProjectsListComponent implements OnInit, AfterViewInit, OnDestroy {
5051
private readonly projectService: ProjectService,
5152
private readonly cdref: ChangeDetectorRef,
5253
private readonly router: Router,
53-
private readonly subscriptionService: SubscriptionService
54+
private readonly subscriptionService: SubscriptionService,
55+
private readonly renderer: Renderer2
5456
) {}
5557

58+
@ViewChild("filterBody") filterBody!: ElementRef<HTMLElement>;
59+
5660
ngOnInit(): void {
5761
this.navService.setNavTitle("Проекты");
5862

@@ -220,6 +224,49 @@ export class ProjectsListComponent implements OnInit, AfterViewInit, OnDestroy {
220224
});
221225
}
222226

227+
private swipeStartY = 0;
228+
private swipeThreshold = 50;
229+
private isSwiping = false;
230+
231+
onSwipeStart(event: TouchEvent): void {
232+
this.swipeStartY = event.touches[0].clientY;
233+
this.isSwiping = true;
234+
}
235+
236+
onSwipeMove(event: TouchEvent): void {
237+
if (!this.isSwiping) return;
238+
239+
const currentY = event.touches[0].clientY;
240+
const deltaY = currentY - this.swipeStartY;
241+
242+
// Добавляем визуальную индикацию
243+
const progress = Math.min(deltaY / this.swipeThreshold, 1);
244+
this.renderer.setStyle(
245+
this.filterBody.nativeElement,
246+
"transform",
247+
`translateY(${progress * 100}px)`
248+
);
249+
}
250+
251+
onSwipeEnd(event: TouchEvent): void {
252+
if (!this.isSwiping) return;
253+
254+
const endY = event.changedTouches[0].clientY;
255+
const deltaY = endY - this.swipeStartY;
256+
257+
if (deltaY > this.swipeThreshold) {
258+
this.closeFilter();
259+
}
260+
261+
this.isSwiping = false;
262+
263+
this.renderer.setStyle(this.filterBody.nativeElement, "transform", "translateY(0)");
264+
}
265+
266+
closeFilter(): void {
267+
this.isFilterOpen = false;
268+
}
269+
223270
onScroll() {
224271
if (this.isSubs) {
225272
return of({});

projects/social_platform/src/app/office/projects/projects.component.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,23 @@
2929
},
3030
]"
3131
>
32-
<div class="bar__right">
33-
@if (isMy) {
32+
</app-bar>
33+
<div class="bar__right">
34+
@if (isMy) {
35+
<div>
3436
<button (click)="addProject()" class="text-body-14 bar__add-project">
3537
<span class="bar__add-project-text">Добавить проект</span>
3638
<i appIcon icon="plus" appSquare="18"></i>
3739
</button>
38-
} @else if (isAll) {
40+
</div>
41+
} @else if (isAll) {
42+
<div class="bar__bottom">
3943
<form [formGroup]="searchForm">
4044
<app-search formControlName="search"></app-search>
4145
</form>
42-
}
4346
</div>
44-
</app-bar>
47+
}
48+
</div>
4549
}
4650
</div>
4751

projects/social_platform/src/app/office/projects/projects.component.scss

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
margin-left: auto;
1616
}
1717

18+
.bar__bottom {
19+
background-color: var(--white);
20+
border-radius: 15px;
21+
padding: 20px 0;
22+
border: 1px solid var(--medium-grey-for-outline);
23+
}
24+
1825
.bar__add-project {
1926
display: flex;
2027
align-items: center;
@@ -27,10 +34,6 @@
2734
}
2835

2936
.bar__add-project-text {
30-
display: none;
31-
32-
@include responsive.apply-desktop {
33-
display: inline;
34-
}
37+
display: inline;
3538
}
3639
}

0 commit comments

Comments
 (0)