@@ -8,9 +8,9 @@ import ToastPlacement from "./types/ToastPlacement.js";
8
8
// Styles
9
9
import ToastCss from "./generated/themes/Toast.css.js" ;
10
10
11
- // Static Constants
12
- const MAXIMUM_ALLOWED_TRANSITION_DURATION_IN_MILLISECONDS = 1000 ;
13
- const MINIMUM_ALLOWED_DURATION_IN_MILLISECONDS = 500 ;
11
+ // Constants
12
+ const MIN_DURATION = 500 ;
13
+ const MAX_DURATION = 1000 ;
14
14
15
15
/**
16
16
* @public
@@ -147,22 +147,6 @@ class Toast extends UI5Element {
147
147
return ToastTemplate ;
148
148
}
149
149
150
- static get maximumAllowedTransition ( ) {
151
- return MAXIMUM_ALLOWED_TRANSITION_DURATION_IN_MILLISECONDS ;
152
- }
153
-
154
- static get minimumAllowedDuration ( ) {
155
- return MINIMUM_ALLOWED_DURATION_IN_MILLISECONDS ;
156
- }
157
-
158
- onBeforeRendering ( ) {
159
- // If the minimum duration is lower than 500ms, we force
160
- // it to be 500ms, as described in the documentation.
161
- if ( this . duration < Toast . minimumAllowedDuration ) {
162
- this . duration = Toast . minimumAllowedDuration ;
163
- }
164
- }
165
-
166
150
onAfterRendering ( ) {
167
151
if ( this . _reopen ) {
168
152
this . _reopen = false ;
@@ -187,22 +171,32 @@ class Toast extends UI5Element {
187
171
}
188
172
}
189
173
174
+ /**
175
+ * If the minimum duration is lower than 500ms, we force
176
+ * it to be 500ms, as described in the documentation.
177
+ * @private
178
+ * @returns {* }
179
+ */
180
+ get effectiveDuration ( ) {
181
+ return this . duration < MIN_DURATION ? MIN_DURATION : this . duration ;
182
+ }
183
+
190
184
get rtl ( ) {
191
185
return getRTL ( ) ? "rtl" : undefined ;
192
186
}
193
187
194
188
get styles ( ) {
195
189
// Transition duration (animation) should be a third of the duration
196
190
// property, but not bigger than the maximum allowed (1000ms).
197
- const transitionDuration = Math . min ( this . duration / 3 , Toast . maximumAllowedTransition ) ;
191
+ const transitionDuration = Math . min ( this . effectiveDuration / 3 , MAX_DURATION ) ;
198
192
199
193
return {
200
194
root : {
201
195
"transition-duration" : this . open ? `${ transitionDuration } ms` : "" ,
202
196
203
197
// Transition delay is the duration property minus the
204
198
// transition duration (animation).
205
- "transition-delay" : this . open ? `${ this . duration - transitionDuration } ms` : "" ,
199
+ "transition-delay" : this . open ? `${ this . effectiveDuration - transitionDuration } ms` : "" ,
206
200
207
201
// We alter the opacity property, in order to trigger transition
208
202
"opacity" : this . open && ! this . hover ? "0" : "" ,
0 commit comments