vUX / Core / v4.1.0

The small things,
done once.

Importing any vUX module puts $$ on window: selection, class and style chores, slides, flips, tweens, delegated events, a countdown and a handful of built-in extensions.

0on $$
0on $$.sm()
0easing curves
$$.sm(h1).fill("linear-gradient(…)") · $$.sm(n).animate(draw, 120)
face-a · shown first
$$.sm

Wrap an element or a selector, then call one of nineteen manipulators on it. Click the card.

face-b · after the flip
flip.card

Rotated by the core on the Y axis. The option object is passed on every call.

01Select and manipulate

$$.ss and $$.sa are querySelector and querySelectorAll. $$.sm wraps an element or a selector: given a selector, hide, unHide and the class methods act on every match, while index, cssStyle and class.has read the first.

Board · 12 tiles
Selector
Pick an operation.
makeActive(className, parent)pass the parent

The active tab gets active and cOff, and being a <button> it is also disabled: clicking it again does nothing. The parent scopes the clearing; without one, every element in the document with that class is cleared.

02Motion

Slides are CSS transitions the core sets up for you: it adds .vSlide, writes a start value, forces a reflow and writes the end value. In position mode the direction is in the numbers: toLeft and toRight both move x[0] → x[1].

Shared slide settings

Drawer · position

A right-anchored panel, slid by its right with positionProperty: "right".

The drawer lives off the right edge at right: -260px.

Reveal · dimension

toRight opens the width to the content's own width; toLeft takes it back to 0.

width: 0 → scrollWidth
Accordion · toBottom / toTopuse: "dimension"

After the transition the core hands the height back to CSS, so content that grows later (a late image, a wrapped line on resize) is not clipped at the height measured at open time.

toLeft and toRight fill in defaults for use, positions and dimensions. toTop and toBottom do not: leave use out and they take the position branch with no positions, and throw.

The element and the end size (a number of pixels) once speed milliseconds have passed. It is a timer, not a transitionend listener, so it fires even when nothing actually moved.

animate(draw, value, options)

A requestAnimationFrame tween that hands each value to your draw(element, value). value is a change, not a target, and the core remembers where each element ended, so +300 then −300 brings the ball home.

timingFunction
Ball0

The seven curves are the core's own timing table, a global. Two animate() calls on one element run side by side, both writing: wait for one to finish.

filter(type, value, options)

grayscale · blur

03Layout helpers

Each writes inline styles or classes and leaves the rest to CSS. center* on a positioned element is 50% plus a translate; on a static one it is auto margins, and the vertical part adds a resize listener that is never removed.

centerX()left 50%
centerY()top 50%
center()both

addOverlay("first", id, css)

A gradient layer under the content. The CSS text is attached once under id.

Generated art

No image, just gradients.

scroll.y(true) · lock · unlock

A vertical scroller with its bar hidden. Locking sets overflow-y: hidden.

    scrolls

    04Delegated events

    $$.attachEventHandler(event, classes, fn) puts one listener on window and calls fn when the event's target carries the class. Tags added later work without rebinding. "tag, pinned" means tag but not pinned; "keyup:key=Enter" filters on the event's own properties.

    Click a tag to remove it
    
                    
    attached

    The tag with a bold word inside: click the bold part and nothing happens: the target is the <b>, which does not carry tag.

    05Data, time and the environment

    The utilities that are not about the DOM at all.

    getTimeSegments(unixSeconds)

    Time left until a moment, broken into parts. null once it has passed.

    0days
    0hrs
    0mins
    0sec

    ScreenBreakPoint

    A getter over innerWidth, banded by your two breakpoints. Resize the window.

    -

    randomString · randomInteger

    From Math.random(): for ids and demo data, not for secrets.

    IO.get(urls, fn)

    Parallel GETs; fn runs once per response with every body so far and the progress.

    idle

    getURLParams · browserType

    A query value, and the browser read from the user agent.

    06Built-in extensions and global helpers

    The core patches a few built-ins and promotes every helper in src/helpers.js to a global. Each row below is evaluated live on this page.

    Rows in amber are where the result is not what the name suggests: trimChar strips every occurrence, and has/unique show up in a for…in over any array.

    07Bad input, and repaired calls

    Most utilities check their arguments and throw an Error naming the method and the argument. Each button makes the call and prints exactly what was thrown.

    No error yet: press one of the buttons above.

    Repaired in this release

    Each of these calls threw or returned the wrong thing earlier in v4.0.0. The buttons show what they return now. IO.save downloads a small JSON file.

    Press one of the buttons above.

    $$.delay blocks the page

    The spinner stops: $$.delay is a synchronous wait by design. Use setTimeout for a timer.