The Code Collection, Vol. 2

take me back home

Butterfly Release

BUTTERFLY RELEASE

Create a whimsical release of animated butterflies that flutter upward through your Showit design.

The butterflies emerge from the bottom of the canvas, follow individual flight paths and fly off the top of the screen. Every release is a little different, with butterflies that wander, dart and glide.

You can also add landing targets so butterflies flutter down onto specific Showit elements, rest for a moment, then take off and fly away.

WHAT YOU'LL NEED

A Showit canvas

Page Loaded Javascript

The butterfly-release Class Selector

Optional butterfly-land Class Selectors if you want butterflies to land

HOW TO INSTALL

01 — ADD THE CANVAS CLASS SELECTOR

Choose the Showit canvas where you want the Butterfly Release to appear.

Select the canvas and go to:

Advanced → Class Selectors

Add:

butterfly-release

Then click the check mark to save it.

Showit may display it as .butterfly-release after you add it.

The butterflies will release from the bottom of this canvas and fly upward through your design.

02 — ADD THE JAVASCRIPT

Select the page name in the Pages panel.

Go to:

Advanced Settings → Page Loaded Javascript

Paste the entire Butterfly Release code into the box.

Do not add <script> tags. Showit adds them automatically.

03 — CHOOSE THE NUMBER OF BUTTERFLIES

At the top of the code, find:

butterflyCount: 24,

Change the number to choose how many butterflies appear in the release.

For example:

butterflyCount: 10,

will release 10 butterflies.

04 — CUSTOMIZE THE SIZE

Find:

size: 170,

This controls the overall base size of the butterflies.

Increase the number for larger butterflies.

Decrease the number for smaller butterflies.

The butterflies automatically vary in size so the release feels more natural.

05 — CUSTOMIZE THE WING-FLAP SPEED

Find:

flapSpeed: 300,

This controls how quickly the butterfly wings flap.

Lower number = wings flap faster

Higher number = wings flap slower

This setting controls the movement of the wings only. It does not change how quickly the butterflies fly across the canvas.

Each butterfly also flaps at a slightly different pace, so the release looks natural.

06 — CUSTOMIZE THE BODY + DETAILS

Find:

wingStroke: "#756966",

This controls the outline around the butterfly wings.

Find:

bodyColor: "#302B29",

This controls the butterfly bodies, antennae, wing borders and wing details.

Replace the HEX codes with your own colors to coordinate the butterflies with your website.

Important: use 6-digit HEX codes, such as #302B29. Shorthand codes like #FFF and color names like "black" will not work correctly.

07 — CUSTOMIZE THE BUTTERFLIES

Find the section labeled:

BUTTERFLIES

Each line in this section is one butterfly.

Example:

{ scale:.72, delay:0, flap:0.983, duration:6100, type:"classic", wing:"#D9A6A1", light:"#F1D1CD" },

wing controls the main wing color.

light controls the lighter color inside the wings.

Replace the HEX codes with your own colors to create a custom butterfly palette. Use 6-digit HEX codes, such as #D9A6A1.

type controls the wing style. Choose from:

classic — soft wings with a dotted border

monarch — bold dark border and heavy veins

swallowtail — wing tails and eyespots

morpho — shimmering wings with eyespots

white — delicate, lightly bordered wings

scale controls the size of that butterfly.

delay controls how long it waits before being released, in milliseconds.

You can add or remove lines as needed.

If you have more butterflies than lines, the list repeats automatically throughout the release.

08 — OPTIONAL: MAKE BUTTERFLIES LAND

Choose a Showit element where you would like a butterfly to land.

Select the element and go to:

Advanced → Class Selectors

Add:

butterfly-land

Then click the check mark to save it.

You can add butterfly-land to more than one element inside the Butterfly Release canvas.

A butterfly lands only if its line in the BUTTERFLIES section includes a land number:

land:0 lands on the first butterfly-land element

land:1 lands on the second butterfly-land element

By default, two butterflies are set to land. To add a third landing, add land:2 to another butterfly line.

To make a butterfly fly through without landing, remove land from its line.

Landing butterflies flutter as they approach, settle onto the element, rest for a moment with slowly opening and closing wings, then take off and fly away.

You do not need to add any butterfly-land Class Selectors if you don't want butterflies to land.

09 — OPTIONAL: FLIGHT + REALISM SETTINGS

At the top of the code, you'll find these optional settings.

flightWander: 1,

This controls how much the butterflies dart and meander as they fly.

0 = smooth, simple flight paths

1 = natural flight

2 = very erratic flight

wingLighting: true,

The wings brighten and darken as they tilt, like they're catching the light.

softShadow: true,

Adds a soft shadow beneath each butterfly.

depthOfField: true,

Smaller butterflies appear slightly softer and more faded, as if they're farther away.

If your page feels slow, especially with a high butterfly count, change wingLighting, softShadow or depthOfField to false.

Wing lighting is automatically turned off on mobile to keep the animation smooth.

10 — PREVIEW + TEST

Open Preview and watch the full Butterfly Release.

Check the effect on both desktop and mobile.

If you're using landing butterflies, make sure each butterfly lands where you want it in both layouts.

Adjust the butterfly count, size, flap speed, colors or wing styles as needed for your design.

Everything below:

CODE BELOW
NO EDITING NEEDED

can be left alone.

LANDING TIP

A landing target can be text, a shape, an image or another Showit element inside the Butterfly Release canvas.

Move the Showit element to change where the butterfly lands.

You do not need to change the butterfly's flight coordinates inside the code.

MOBILE NOTE

Butterfly Release works on both desktop and mobile.

The butterflies automatically display slightly smaller on mobile to better fit the screen.

Because Showit allows you to design desktop and mobile separately, you can reposition your butterfly-land elements on mobile to control where the butterflies land.

DESIGN TIP

Try choosing a small palette of coordinating wing colors rather than making every butterfly the same color.

Mixing a few wing styles, such as classic, morpho and swallowtail, makes the release feel like a natural flock while keeping the butterflies visually cohesive with your website.

For lifelike colors, try orange for monarch butterflies and blue for morpho butterflies.

QUICK INFO

DIFFICULTY — Easy

REQUIRES — Showit Canvas + Page Loaded Javascript

CLASS SELECTORS — butterfly-release + optional butterfly-land

TRIGGER — Page load

NUMBER OF BUTTERFLIES — Customizable

BUTTERFLY SIZE — Customizable

WING-FLAP SPEED — Customizable

WING COLORS — Customizable

WING STYLES — 5 butterfly types

FLIGHT STYLE — Customizable

REALISM EFFECTS — Optional

WING OUTLINE — Customizable

BODY + DETAIL COLOR — Customizable

LANDING — Optional

MOBILE FRIENDLY — Yes

CODING KNOWLEDGE — Not required