jQuery.fracs

determine the visible fractions of an HTML element

1.0.1

jQuery.fracs calculates some fractions for an HTML element (visible fraction, fraction of the viewport, ...) and also provides the coordinates of these areas. See a demo to get an impression of some of the features.

Usage

To retrieve the fractions of an element use:

var fracs = $(selector).fracs();

this will return an object of type Fractions.

Or bind a callback function:

function callback(fracs: Fractions, prev_fracs: Fractions) {
    ...
    // context variable *this* will be the corresponding HTMLElement
    ...
};

$(selector).fracs(callback);

The callback function will be called whenever fracs and prev_fracs are unequal. A check will be triggered on every window resize or window scroll event. To trigger it manually use

$(selector).fracs('check');

API

Currently there is only the documented source code.

Works best with JavaScript enabled!Works best in modern browsers!