Mask
Masks a target element (document.body if none is specified). Call static methods for ease of use or make instance
for reusability.
Mask.mask('hello');
Mask.unmask();
//<code-header>
fiddle.title = 'Mask';
//</code-header>
new Button({
appendTo : targetElement,
text : 'Show mask',
onClick : () => {
Mask.mask({
target : targetElement,
text : 'Masked (2 seconds)'
});
setTimeout(() => {
Mask.unmask(targetElement);
}, 2000);
}
});
new Button({
appendTo : targetElement,
text : 'Show Progress',
style : 'margin-inline-start: 1em',
onClick : () => {
const mask = Mask.mask({
target : targetElement,
text : 'The task is in progress',
progress : 0,
maxProgress : 100
});
const timer = setInterval(() => {
mask.progress += 5;
if (mask.progress >= mask.maxProgress) {
Mask.unmask(targetElement);
clearInterval(timer);
}
}, 100);
}
});Can show progress:
// Using progress by calling static method
const mask = Mask.mask({
text :'The task is in progress',
progress : 0,
maxProgress : 100
});
let timer = setInterval(() => {
mask.progress += 5;
if (mask.progress >= mask.maxProgress) {
Mask.unmask();
clearInterval(timer);
}
}, 100);
Stacking Multiple Masks
An element can have multiple masks attached to it (for example, to handle independent asynchronous activities). When an element has multiple masks attached, only the first mask created is visible to the user. This avoids unpleasant transparency layering that would occur if all masks were visible at the same time. When the active mask is destroyed or hidden (via hide), the next oldest mask is made visible. That is, masks are displayed in FIFO order.
When a mask is hidden, it is not a candidate in the FIFO order and is ignored when looking for the next oldest mask. If the mask is shown (via show), the mask is again a candidate for being shown, and will be shown immediately if there is not already a currently visible mask. This eliminates flickering effects that would otherwise come from multiple masks competing for display.
When the last mask is hidden or destroyed, the target element becomes unmasked. Showing and hiding of masks is useful when the masks may be needed repeatedly over time.
Masking Bryntum Widgets
Shortcut to masking Bryntum components:
// Using progress to mask a Bryntum component
scheduler.mask({
text:'Loading in progress',
progress: 0,
maxProgress: 100
});
let timer = setInterval(() => {
scheduler.masked.progress += 5;
if (scheduler.masked.progress >= scheduler.masked.maxProgress) {
scheduler.unmask();
clearInterval(timer);
}
},100);
Configs
79
Configs
79Common
Other
By default in versions below 8.0, the text is not HTML-encoded. Set this flag to true to
automatically HTML-encode the text.
The icon to show next to the text. Defaults to showing a spinner
The number of milliseconds to delay before making the mask visible. If set, the mask will have an
initial opacity of 0 but will function in all other ways as a normal mask. Setting this delay can
reduce flicker in cases where load operations are typically short (for example, a second or less).
The element to be masked. If this config is a string, that string is the name of the property of the
owner that holds the HTMLElement that is the actual target of the mask.
NOTE: In prior releases, this used to be specified as the element config.
The text (or HTML) to show in the mask, the text is not HTML encoded. See also the htmlEncode config for displaying raw HTML. As of v8.0 the text is automatically HTML encoded.
DOM
Float & align
Layout
Misc
Scrolling
Properties
69
Properties
69Class hierarchy
Other
By default in versions below 8.0, the text is not HTML-encoded. Set this flag to true to
automatically HTML-encode the text.
The maximum value of the progress indicator
Number expressing the progress
The text (or HTML) to show in the mask, the text is not HTML encoded. See also the htmlEncode config for displaying raw HTML. As of v8.0 the text is automatically HTML encoded.
CSS
DOM
Layout
Misc
Functions
60
Functions
60Other
Close mask (removes it)
A promise which is resolved after the mask is closed and destroyed.
Returns the array of Mask instances for the given element.
| Parameter | Type | Description |
|---|---|---|
element | HTMLElement | The element for which to return |
Shows a mask with the specified message.
Masks stack, call unmask to remove the topmost mask. Or call close
on the returned mask to close it specifically. Only one mask is displayed for a given target element at a time.
For example, if two masks are added to an element, the first mask is displayed. If the first mask is closed,
then the second mask will become visible.
| Parameter | Type | Description |
|---|---|---|
text | String | MaskConfig | Message |
target | HTMLElement | The element to mask (default is |
Close the most recently created mask for the specified element.
| Parameter | Type | Description |
|---|---|---|
element | HTMLElement | The element to unmask (default is |
A promise which is resolved when the mask is gone, or null if element is not masked
Configuration
Events
Misc
Widget hierarchy
Events
14
Events
14Event handlers
14
Event handlers
14Typedefs
6
Typedefs
6CSS variables
28
CSS variables
28| Name | Description |
|---|---|
--b-mask-border-radius | Mask border-radius |
--b-mask-padding | Mask padding |
--b-mask-text-background | Mask text background |
--b-mask-progress-height | Mask progress bar height |
--b-mask-background | Mask background |
--b-mask-text-color | Mask text color |
--b-mask-progress-color | Mask progress bar color |
--b-mask-color | Mask color |