Skip to content

Commit e794e36

Browse files
Merge branch 'master' of https://github.com/primefaces/primeng
2 parents b0f0154 + aabb598 commit e794e36

File tree

2 files changed

+44
-17
lines changed

2 files changed

+44
-17
lines changed

packages/primeng/src/scrolltop/scrolltop.ts

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { CommonModule, isPlatformBrowser } from '@angular/common';
2-
import { ChangeDetectionStrategy, Component, computed, ContentChild, ContentChildren, inject, InjectionToken, input, Input, NgModule, numberAttribute, QueryList, TemplateRef, ViewEncapsulation } from '@angular/core';
2+
import { ChangeDetectionStrategy, Component, computed, ContentChild, ContentChildren, inject, InjectionToken, input, Input, NgModule, numberAttribute, QueryList, signal, TemplateRef, ViewEncapsulation } from '@angular/core';
33
import { MotionEvent, MotionOptions } from '@primeuix/motion';
44
import { getWindowScrollTop } from '@primeuix/utils';
55
import { PrimeTemplate, SharedModule } from 'primeng/api';
66
import { BaseComponent, PARENT_INSTANCE } from 'primeng/basecomponent';
77
import { Bind } from 'primeng/bind';
88
import { Button, ButtonProps } from 'primeng/button';
99
import { ChevronUpIcon } from 'primeng/icons';
10-
import { MotionModule } from 'primeng/motion';
10+
import { MotionDirective } from 'primeng/motion';
1111
import { ScrollTopPassThrough } from 'primeng/types/scrolltop';
1212
import { ZIndexUtils } from 'primeng/utils';
1313
import { ScrollTopStyle } from './style/scrolltopstyle';
@@ -21,10 +21,26 @@ const SCROLLTOP_INSTANCE = new InjectionToken<ScrollTop>('SCROLLTOP_INSTANCE');
2121
@Component({
2222
selector: 'p-scrollTop, p-scrolltop, p-scroll-top',
2323
standalone: true,
24-
imports: [CommonModule, ChevronUpIcon, Button, SharedModule, MotionModule],
24+
imports: [CommonModule, ChevronUpIcon, Button, SharedModule, MotionDirective],
2525
template: `
26-
<p-motion [visible]="visible" name="p-scrolltop" [options]="computedMotionOptions()" (onBeforeEnter)="onBeforeEnter($event)" (onBeforeLeave)="onBeforeLeave()">
27-
<p-button [attr.aria-label]="buttonAriaLabel" (click)="onClick()" [pt]="ptm('pcButton')" [styleClass]="cn(cx('root'), styleClass)" [ngStyle]="style" type="button" [buttonProps]="buttonProps" [unstyled]="unstyled()">
26+
@if (render()) {
27+
<p-button
28+
[pMotion]="visible()"
29+
[pMotionAppear]="true"
30+
[pMotionName]="'p-scrolltop'"
31+
[pMotionOptions]="computedMotionOptions()"
32+
(pMotionOnBeforeEnter)="onBeforeEnter($event)"
33+
(pMotionOnBeforeLeave)="onBeforeLeave()"
34+
(pMotionOnAfterLeave)="onAfterLeave()"
35+
[attr.aria-label]="buttonAriaLabel"
36+
(click)="onClick()"
37+
[pt]="ptm('pcButton')"
38+
[styleClass]="cn(cx('root'), styleClass)"
39+
[ngStyle]="style"
40+
type="button"
41+
[buttonProps]="buttonProps"
42+
[unstyled]="unstyled()"
43+
>
2844
<ng-template #icon>
2945
<ng-container *ngIf="!iconTemplate && !_iconTemplate">
3046
<span *ngIf="_icon" [class]="cn(cx('icon'), _icon)"></span>
@@ -33,7 +49,7 @@ const SCROLLTOP_INSTANCE = new InjectionToken<ScrollTop>('SCROLLTOP_INSTANCE');
3349
<ng-template [ngIf]="!icon" *ngTemplateOutlet="iconTemplate || _iconTemplate; context: { styleClass: cx('icon') }"></ng-template>
3450
</ng-template>
3551
</p-button>
36-
</p-motion>
52+
}
3753
`,
3854
changeDetection: ChangeDetectionStrategy.OnPush,
3955
encapsulation: ViewEncapsulation.None,
@@ -135,7 +151,9 @@ export class ScrollTop extends BaseComponent<ScrollTopPassThrough> {
135151

136152
parentScrollListener: VoidFunction | null | undefined;
137153

138-
visible: boolean = false;
154+
visible = signal<boolean>(false);
155+
156+
render = signal<boolean>(false);
139157

140158
overlay: any;
141159

@@ -175,10 +193,19 @@ export class ScrollTop extends BaseComponent<ScrollTopPassThrough> {
175193
this.overlay = null;
176194
}
177195

196+
onAfterLeave() {
197+
this.render.set(false);
198+
}
199+
178200
checkVisibility(scrollY: number) {
179-
if (scrollY > this.threshold) this.visible = true;
180-
else this.visible = false;
181-
this.cd.markForCheck();
201+
if (scrollY > this.threshold) {
202+
this.visible.set(true);
203+
if (!this.render()) {
204+
this.render.set(true);
205+
}
206+
} else {
207+
this.visible.set(false);
208+
}
182209
}
183210

184211
bindParentScrollListener() {

packages/primeng/src/toast/style/toaststyle.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,32 @@ const style = /*css*/ `
55
${toast_style}
66
/* Animations */
77
.p-toast-enter-active {
8-
animation: p-toast-enter-animation 450ms cubic-bezier(0, 1, 0, 1);
8+
animation: p-toast-enter 0.3s ease-out;
99
}
1010
1111
.p-toast-leave-active {
12-
animation: p-toast-leave-animation 250ms ease-out;
12+
animation: p-toast-leave 0.45s cubic-bezier(0, 0.2, 0, 0.8);
1313
}
1414
1515
/* Bottom positions - slide down on leave */
1616
.p-toast.p-toast-bottom-left .p-toast-message.p-toast-leave-active,
1717
.p-toast.p-toast-bottom-right .p-toast-message.p-toast-leave-active,
1818
.p-toast.p-toast-bottom-center .p-toast-message.p-toast-leave-active {
19-
animation: p-toast-leave-bottom-animation 250ms ease-out;
19+
animation: p-toast-leave-bottom 0.45s cubic-bezier(0, 0.2, 0, 0.8);
2020
}
2121
22-
@keyframes p-toast-enter-animation {
22+
@keyframes p-toast-enter {
2323
from {
2424
opacity: 0;
25-
transform: translateY(100%);
25+
transform: translateY(50%);
2626
}
2727
to {
2828
opacity: 1;
2929
transform: translateY(0);
3030
}
3131
}
3232
33-
@keyframes p-toast-leave-animation {
33+
@keyframes p-toast-leave {
3434
from {
3535
max-height: 1000px;
3636
opacity: 1;
@@ -44,7 +44,7 @@ ${toast_style}
4444
}
4545
}
4646
47-
@keyframes p-toast-leave-bottom-animation {
47+
@keyframes p-toast-leave-bottom {
4848
from {
4949
max-height: 1000px;
5050
opacity: 1;

0 commit comments

Comments
 (0)