Pixel UI/Physics & time/Quake

Quake

One press and the page falls down. Throw the pieces, then put it all back.

<piix-quake>DOM + canvas
Quake

Everything here is a body.

Grab a piece and throw it. Press Quake again to put it all back.

Cards

They stack.

Still clickable
Gravity
Bounce

A real rigid-body simulation running on your actual elements: boxes that collide at their corners, stack, slide with friction and come to rest. The ground shakes, every block inside falls, bounces and piles up; grab any piece and throw it. Text collides by the shape of its lines, not its full-width box. Pieces are only moved, never copied, so buttons and links still work while they lie on the floor. Press again and every piece flies back into place. Anything with data-piix-quake="its id" toggles it.

Installation

<!-- once, anywhere on the page: every component -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.6/piixpal.min.js"></script>

Usage

<piix-glow-button data-piix-quake="page">Quake</piix-glow-button>

<piix-quake id="page" style="height:420px">
  <h2 class="ex-h2">Everything here is a body.</h2>
  <p>Grab a piece and throw it. Press Quake again to put it all back.</p>
  <piix-glow-card style="width:220px"><h3>Cards</h3><p>They stack.</p></piix-glow-card>
  <piix-button tone="coral">Still clickable</piix-button>
</piix-quake>

Examples

Click anywhere

With trigger="click" a click on an empty spot brings it down, and another puts it back.

Click an empty spot

Then throw things around.

Q U A K E

Keep some things standing

data-fixed stays put and things land on it. data-body makes a whole group fall as one piece.

A shelf catches me

One piece
with two lines
Quake

API reference

AttributeWhat it doesDefault
triggerclick: a click on an empty spot toggles itnone
gravityhow hard things fall, 0.2 to 31
bouncehow much things bounce, 0 to 10.15
snappieces move on a grid this many px wide2
restseconds before it puts itself back, or nevernever
soundmake sounds even without <piix-chiptune>; off keeps it silent–
data-piix-quakeon any element: clicking it toggles the quake with that id–
data-bodyon an element inside: it and everything in it fall as one piece–
data-fixedon an element inside: it stays standing, and things land on it–

Events

EventWhen
quakeit starts falling
restoreevery piece is back in place

Methods

MethodWhat it does
quake()bring it down
restore()put everything back
toggle()one or the other

Accessibility