jquery.copycat
A jQuery plugin that copies position and size of an element to another.
Respondes to resize and scroll events in order to keep it updated.
API
.copycat(target, [options])
Makes an element looks like target
.
Available options
:
-
scroll
: scroll element to listen for scroll events (defaults towindow
) -
handleResize
: true to handle resize, false otherwise (defaults totrue
) -
subtractScroll
: true to subtract scroll offsets, false otherwise (defaults tonull
which means automatic) -
update
: true to automatically call.copycat('update')
right away, false otherwise (defaults totrue
)
Note that if you call this function with different target
s, the previous instances will be destroyed.
Once initialized, you can't change the options.
$('.some-el').copycat('.target-el');
.copycat('update')
Manually updates element.
$('.some-el').copycat('update');
.copycat('destroy', [keepPosition])
Destroy copycat instance, releasing all events and clearing element position.
If you wish to keep the position set by copycat, pass keepPosition
as true.
$('.some-el').copycat('destroy');
How to use
Simply include the jquery.copycat.js
file after jQuery is loaded.
This plugin also integrates with AMD
(no shim required) and CommonJS
.
This plugin only works in modern browsers, that is IE >= 9
.
Tests
No tests yet :(