@@ -3,6 +3,7 @@ import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
3
3
import { isIE } from "@ui5/webcomponents-base/dist/Device.js" ;
4
4
import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
5
5
import { isTabNext } from "@ui5/webcomponents-base/dist/Keys.js" ;
6
+ import Integer from "@ui5/webcomponents-base/dist/types/Integer.js" ;
6
7
import BusyIndicatorSize from "./types/BusyIndicatorSize.js" ;
7
8
import Label from "./Label.js" ;
8
9
@@ -78,6 +79,27 @@ const metadata = {
78
79
active : {
79
80
type : Boolean ,
80
81
} ,
82
+
83
+ /**
84
+ * Defines the delay in milliseconds, after which the busy indicator will be visible on the screen.
85
+ *
86
+ * @type {Integer }
87
+ * @defaultValue 1000
88
+ * @public
89
+ */
90
+ delay : {
91
+ type : Integer ,
92
+ defaultValue : 1000 ,
93
+ } ,
94
+
95
+ /**
96
+ * Defines if the component is currently in busy state.
97
+ * @private
98
+ */
99
+ _isBusy : {
100
+ type : Boolean ,
101
+ noAttribute : true ,
102
+ } ,
81
103
} ,
82
104
} ;
83
105
@@ -143,6 +165,11 @@ class BusyIndicator extends UI5Element {
143
165
}
144
166
145
167
onExitDOM ( ) {
168
+ if ( this . _busyTimeoutId ) {
169
+ clearTimeout ( this . _busyTimeoutId ) ;
170
+ delete this . _busyTimeoutId ;
171
+ }
172
+
146
173
this . removeEventListener ( "keydown" , this . _keydownHandler , true ) ;
147
174
this . removeEventListener ( "keyup" , this . _preventEventHandler , true ) ;
148
175
}
@@ -188,6 +215,23 @@ class BusyIndicator extends UI5Element {
188
215
} ;
189
216
}
190
217
218
+ onBeforeRendering ( ) {
219
+ if ( this . active ) {
220
+ if ( ! this . _isBusy && ! this . _busyTimeoutId ) {
221
+ this . _busyTimeoutId = setTimeout ( ( ) => {
222
+ delete this . _busyTimeoutId ;
223
+ this . _isBusy = true ;
224
+ } , Math . max ( 0 , this . delay ) ) ;
225
+ }
226
+ } else {
227
+ if ( this . _busyTimeoutId ) {
228
+ clearTimeout ( this . _busyTimeoutId ) ;
229
+ delete this . _busyTimeoutId ;
230
+ }
231
+ this . _isBusy = false ;
232
+ }
233
+ }
234
+
191
235
_handleKeydown ( event ) {
192
236
if ( ! this . active ) {
193
237
return ;
0 commit comments