Load content via fetch when element with attribute [data-load-content] comes into view
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
selector |
string | targets elements on to set up dynamic loading |
Example
<div data-load-content="more-stories">
[fetched content goes here]
</div>
Methods
(inner) init()
- Source:
Set's up InView listener on any [data-load-content] elements.
Callback is fired when element comes into view.
(inner) load($target) → {promise}
- Source:
Fetches content from the template specified by [data-load-content].
Inserts content onto page.
Parameters:
| Name | Type | Description |
|---|---|---|
$target |
element | Container element for dynamically loaded content. |
Returns:
- Fetch API promise instance.
- Type
- promise