Simple class to make smooth scroll to make fully visible givien item inside a container.
Example:
var container = $("#myContainer");
var scroll = new scroller(container);
$(".item", container).on("click", function() {
scroll.set($(this));
// Obviously this is so stupid example because you can't click non visible
// elements (even partly visiblel yes) but it is the easier one that comes
// to my mind ;-)).
});
NOTE: There are
push()
andpop()
methods too. They are intended to be used when we want to focus (and typically highlight) some items temporarily (for instance because it matches some search pattern) and later go back to previous position.
Insert text at cursor position on textarea or input (jquery) objects deleting selected text (replacing function) if any.