How Floating Elements & Gravity Drop Work Technically in the Browser
Every webpage is governed by the CSS Box Modelβa rigid geometric tree where block and inline elements stack deterministically according to document flow, Flexbox, or CSS Grid rules. When users browse the web, they implicitly trust that buttons, navigation links, and paragraphs will stay anchored in place. Punked.co's physics-inspired DOM effectsβGravity Drop (`gravity_drop.js`), Gravity Flip (`gravity_flip.js`), and Cursor Magnet (`cursor_magnet.js`)βshatter that expectation by liberating DOM nodes from static flow.
Bounding-Box Filtering & Cubic-Bezier Acceleration
In gravity_drop.js, the script first gives the visitor 3.5 seconds of normal browsing before displaying a subtle top-center diagnostic toast: β Gravity anomaly detected.... At the 5-second mark, the script queries the document tree (`querySelectorAll('*')`) and filters elements using Element.getBoundingClientRect():
- Smart Node Selection: To avoid animating invisible wrappers or the entire `` root at once, the filter selects up to 80 leaf/container nodes whose rendered dimensions fall between
10pxand800pxin width and height (cards, headings, images, inputs, and buttons). - Quadratic Acceleration Curve: Free-falling objects accelerate at $9.8\text{ m/s}^2$ rather than moving at a constant linear velocity. By applying
transition: transform 1s cubic-bezier(0.55, 0, 1, 0.45), each element starts falling slowly and accelerates sharply toward the bottom of the viewport (`translateY(window.innerHeight + random * 500px)`). - Angular Torque & Staggered Cascade: Each element receives a randomized rotational torque between
-45degand+45degand a staggered timeout (`i * 50ms + Math.random() * 200ms`), so the page peels apart organically from top to bottom rather than dropping as a flat sheet.
Floating & Magnetic Variations: If you select Gravity Flip (`gravity_flip`) or Cursor Magnet (`cursor_magnet`) in the generator above, elements continuously float and slide sideways as the page tilts, or drift magnetically toward the user's mouse cursor whenever they try to click!
Fun & Harmless Scenarios to Use Floating & Gravity Effects
- The "Fragile Codebase" Joke for Web Developers: Send a fellow developer a link to a staging reference page or technical article with Gravity Drop enabled. Watching the navigation bar and hero cards literally fall off the screen after five seconds is pure comedy during a sprint retro.
- Nostalgic Tribute to Mr.doob's Google Gravity: In 2009, creative coder Ricardo Cabello (Mr.doob) created Google Gravity using Box2D-JS, turning the search engine homepage into a pile of tumbling blocks. Sharing a Gravity Drop link brings that classic web-experiment magic to any modern URL.
- Unclickable Button Prank with Cursor Magnet: Switch the dropdown above to Cursor Magnet when sending a friend a link where they want to click a specific link or buttonβevery nearby element will float toward their pointer!
How Recipients Can Exit the Effect Immediately
- Click the Persistent Exit Button: The
β Exitbutton in the bottom-right corner is excluded from the DOM gravity selector and remains anchored at `z-index: 9999`. Clicking it immediately stops the effect. - Wait for the 30-Second Auto-Reveal: At 30 seconds, the reveal modal appears with a one-click Continue to website β button.
- Close or Refresh the Tab: All CSS transforms are applied in memory; closing or refreshing the tab restores the normal DOM layout immediately.
Frequently Asked Questions About Floating Elements & Gravity Drop
How does the Floating Elements / Gravity Drop effect simulate acceleration?
The script selects visible DOM bounding boxes and applies a CSS cubic-bezier(0.55, 0, 1, 0.45) transition curve combined with staggered translateY and rotational transforms, mimicking quadratic gravitational acceleration.
What happens if the target website blocks cross-origin DOM access?
If a cross-origin frame restricts individual node selection, `gravity_drop.js` automatically catches the security exception and applies a smooth `2s cubic-bezier` gravitational collapse and 5-degree tilt to the entire viewport frame!