Honeymate waits for images, background images, and videos
inside blocks, then reveals them with the selected animation.
Allows you to easily manage the page load order,
indicating the order in which items are displayed.
Simple. Honeymate has declarative API therefore has a low entry threshold.
Small. 2.2 kilobytes (minified and gzipped). No dependencies.
Fast. Only CSS animations are used.
Use npm:
npm install honeymate --saveOr build from source:
pnpm install
pnpm buildLink the CSS and the browser bundle:
<link rel="stylesheet" href="node_modules/honeymate/style.css" />
<script src="node_modules/honeymate/dist/honeymate.js"></script>If built from source, use style.css and dist/honeymate.js from this repository.
Now any element with class="honey" fades in after its media is loaded:
<div class="honey">... Show this only when it is ready ...</div>The script initializes automatically when loaded. Any element with class="honey-replay"
will replay all .honey animations on click.
Before showing a .honey element, Honeymate waits for media in the element itself and
in all descendants:
<img>elements.- CSS background images declared through
backgroundorbackground-image. <video>elements.
Images resolve on both load and error, so broken images do not block the reveal.
By default, Honeymate waits for the canplaythrough event on each video. Use
data-event to choose another video readiness event:
<div class="honey" data-event="loadedmetadata">
<video src="intro.mp4" muted playsinline></video>
</div>This is useful when you want to reveal a block earlier (loadedmetadata, loadeddata,
canplay) or keep the default stricter wait (canplaythrough). Videos that already
have current data, or already have an error when Honeymate checks them, do not block the
reveal.
<div class="honey" data-effect="helix" data-hold="400" data-spin="true">
<img src="img/example.jpg" alt="" />
</div><div id="hero" class="honey" data-effect="zoom">Hero</div>
<div class="honey" data-await="hero" data-effect="fade">Shown after hero starts showing</div>Specify options as data-* attributes on .honey elements.
data-effect— Current effect. Available effects:fade(default),zoom,helix,slide,relax,focus.data-duration— Animation duration in milliseconds. Default is640.data-hold— Extra wait before revealing the element, in milliseconds. Default is50.data-await— Wait for the.honeyelement with this ID to start showing.data-continue— Withtrue, wait for the previous.honeyelement in DOM order to start showing.data-expose— Withtrue, wait until the element intersects the viewport. This option usesIntersectionObserver.data-event— Video event to wait for. Default iscanplaythrough.data-scale— Initial scale forzoom,helix,relax, andfocus. Default is1.22forfocusand0.87for other effects.data-origin— Transform origin forslideandrelax. Available values:top,bottom(default),left,right.data-strength— Blur strength in pixels forfocus. Default is20.data-up,data-down,data-left,data-right— Direction and offset forslide, for exampledata-left="56px". Default isdata-up="32px".data-spin— Show a loading indicator while the element waits. Set it to a non-empty value, for exampletrue.data-spin-size— Indicator diameter in pixels. Default is24.data-spin-color— Indicator color. Default is#000.
The original idea belongs to Ilya Birman, who made the Emerge.
Honeymate supports the latest versions of Safari, Chrome and Firefox.
data-expose requires IntersectionObserver support.
