Reload
Usage
The Reload component allows the user to reload a content via URL. The content is reloaded only when the
element is in the viewport. The IntersectionObserver
API is used.
Im Standard wird der Inhalt nur einmal geladen. Möchte man den Inhalt immer wieder neu Laden,
so muss die Option data-monster-reload
auf “always” gesetzt werden.
It is important to follow the CORS guidelines.
// reload element
const reload = document.createElement('monster-reload');
// loader content
const defaultContent = document.createElement('div');
defaultContent.setAttribute('data-monster-role','container');
defaultContent.innerHTML='load'
reload.appendChild(defaultContent);
// fetch follow url
reload.setAttribute('data-monster-url',
'https://monsterjs.org/assets/16-forms-reload-content.html')
// append element
document.getElementById('example').appendChild(reload);
<monster-reload>
<div data-monster-role="container">
LOADER ...
</div>
</monster-reload>
If the child element has the attribute data-monster-role="container"
, then the
content is replaced with the fetched content.
Events
The following events are fired by the component.
Layout
The tabs control can be customized to your own needs. For this purpose, the control can be designed via css.
The different parts of the control can be designed using CSS.
By default, the Shadow DOM is disabled for this component.
You can enable it by setting the option shadowMode: false,
to open
or closed
.
Since the internals of the component are optionally encapsulated in a shadow tree, access is via css pseudo-element parts.
#reload::part(container) {
background-color: white;
}
The individual parts and slots are shown in the following picture.