JavaScript API
Earmark adds a small window.Earmark object.
Methods
| Method | Description |
|---|---|
Earmark.supported |
true when the browser can run Earmark. |
Earmark.preset(name, factory) |
Register a motion preset. See Motion. |
Earmark.store(name, factory) |
Register a custom store. See Where views are stored. |
Earmark.configure(changes) |
Change visitor settings, e.g. Earmark.configure({ preset: 'genie', layout: 'mini' }). |
Earmark.place(side, align) |
Move the Wings, e.g. Earmark.place('right', 'center'). |
Earmark.look() |
The visitor's current settings, such as layout, side, align, reveal and preset. |
Earmark.save() |
Earmark the current page, as if the visitor pressed +. Returns false if it could not. |
Earmark.reveal(ms) |
Slide the drawer open for a moment so the visitor can see their saved views. |
Events
All events are dispatched on document.
| Event | detail |
When |
|---|---|---|
earmark:switched |
{ path } |
A saved view was swapped onto the stage. Use it to update navigation outside the stage. |
earmark:limit |
{ live, limit, locked? } |
A view could not come alive or be locked because the limit was reached. |
earmark:locked |
{ path, title } |
A locked view was protected from being replaced. |
earmark:placed |
{ side, align } |
The visitor chose a new position. |
earmark:fanned |
{ count } |
The last free slot filled and the saved views fanned out. |
earmark:configured |
{ changes, look } |
Settings were changed with Earmark.configure(). |
earmark:popped |
{ path } |
A view was popped out into a Picture-in-Picture window. |
earmark:popout-failed |
{ path, reason } |
The browser refused to open the window. |
document.addEventListener('earmark:limit', ({ detail }) => {
toast(`Only ${detail.limit} views can be live at once.`)
})