Sophomore Dev Projects

  • Increase font size
  • Default font size
  • Decrease font size
Home

Y.Effects Helper Methods

E-mail Print PDF

The following helper methods are added to Y.DOM and Y.Node as convenience methods. Some of them are inspired by the Prototype library while others are ones you've always wanted.

Y.DOM.show and show()

Shows an element.

Y.DOM.show(element);

Y.get("#node").show();

Y.DOM.hide and hide()

Hides an element.

Y.DOM.hide(element);

Y.get("#node").hide();

Y.DOM.displayed and displayed()

Simple method to determine whether an element is displayed (just checks if the display is set to none.

var isDisplayed = Y.DOM.displayed(element);

var isDisplayed = Y.get("#node").displayed();

Y.DOM.toggle and toggle()

Displays an element if it's not being displayed and vice versa.

Y.DOM.toggle(element);

Y.get("#node").toggle();

Y.DOM.getPositionedOffset and getPositionedOffset()

Get positioned offset. This is useful for taking into account offset relative ancestor, relative positioned nodes. This returns an array of the left and top offsets.

var offsets = Y.DOM.getPositionedOffset(element);

var offsets = Y.get("#node").getPositionedOffset();

Y.DOM.positionAbsolutely and positionAbsolutely()

Position an element absolutely, but maintain its current position with respect to the entire page.

Y.DOM.positionAbsolutely(element);

Y.get("#node").positionAbsolutely();

Y.DOM.getDimensions and getDimensions()

Returns an array of the dimensions of a particular element. If the element is not currently in the DOM tree (because "display" is "none"), then it adjusts its styles to get the dimensions and then resets the element.

var dimensions = Y.DOM.getDimensions(element);

var dimensions = Y.get("#node").getDimensions();

Y.DOM.makePositioned and makePositioned()

Force a node to be positioned, which essentially means setting the position to be non-static. This differs from Y.DOM.positionAbsolutely in that it will not force the position to be absolute, but rather take statically positioned elements and position them relatively.

Y.DOM.makePositioned(element);

Y.get("#node").makePositioned();

Y.DOM.undoPositioned and undoPositioned()

An undo method for Y.DOM.makePositioned.

Y.DOM.undoPositioned(element);

Y.get("#node").undoPositioned();