Skip to content

animate

animate.js

Handles all the animation process

init(animationId, opts, eventType)

Initiate the event listener with the animation

Kind: static function of animate

See:

ParamTypeDefaultDescription
animationIdnumberThe ID of the animation in *_ANIMS_ID object
optsObjectAll options passed by the user
eventTypestring"click"The event to attach the animation to

end(triggerSelector, eventType)

Removes the event listener of all elements represented by the triggerSelector

Kind: static function of animate

ParamTypeDefaultDescription
triggerSelectorstringnullA valid CSS selector for the trigger Element. If ommited, CLASS_NAMES.trigger will be used instead.
eventTypestring"click"The event name. If ommited, 'click' is the default value.

animate(element, action, id, opts)

Handles all the animation process

Kind: static function of animate

See:

ParamTypeDescription
elementHTMLElementThe DOM element to animate
actionstring'show', 'hide', or 'move'
idnumberID of an animation in the *_ANIMS_ID objects
optsObject.<string, any>All the options passed by the user

preset(el, args)

Sets the CSS properties customized by the user, prior to the begining of the animation

Kind: static function of animate

ParamTypeDescription
elHTMLElementThe DOM element being animated
argsObjectThe animation's ID and type and all the options passed by the user

isEnabled(element) ⇒ boolean

Verifies if an element is already being animated or not

Kind: static function of animate

Returns: True if the element is not currently being animated

ParamTypeDescription
elementHTMLElementThe DOM element to check

configurations : Object.<string, any>

Contains the default value for each custom option. Those values can be overwritten by the user by calling jsCssAnimations.config() and passing new default values for all the animations.

Kind: inner constant of animate

See: js-css-animations.config()

configHandler

ProxyHandler passed to the CONFIG object to ensure that if an option is not customized by the user, the default value set in configurations.default will be returned instead.

Kind: inner constant of animate

See

CONFIG : Object.<string, any>

Object that handles configurations, either customized by the user or default values defined in configurations.default object

Kind: inner constant of animate

See: configurations

DURATION_REGEX : RegExp

Matches duration or delay CSS properties values

Kind: inner constant of animate

CALLBACK_TRACKER : Object

Keeps track of the callbacks being executed, preventing the callbacks to be executed multiple times if multiple elements are being animated by a single trigger.

When an element triggers an animation, no matter how many elements are being animated, the start() and complete() callbacks should each be executed only once.

Kind: inner constant of animate

CALLBACK_TRACKER.init(trigger)

Initiates the tracker

Kind: static function of CALLBACK_TRACKER

ParamTypeDescription
triggerstringA CSS selector representing the element
which triggered the animation

CALLBACK_TRACKER.remove(trigger)

Removes 'trigger' from the tracker

Kind: static function of CALLBACK_TRACKER

ParamTypeDescription
triggerstringA CSS selector representing the element
which triggered the animation

TARGETS_STACK : Object

Keeps track of all the targets being animated to ensure that the callback tracker will be removed only when all the targets have been animated. Also ensures that all targets will be re-enabled only when all targets have already been animated.

Kind: inner constant of animate

TARGETS_STACK.add(elem, trigger)

Adds an element to the stack

Kind: static function of TARGETS_STACK

ParamTypeDescription
elemHTMLElementElement being animated
triggerstringCSS selector for the element that triggered the animation

TARGETS_STACK.remove(trigger)

Removes from the stack all the elements animated by the same trigger button

Kind: static function of TARGETS_STACK

ParamTypeDescription
triggerstringCSS selector for the element that triggered the animation

TARGETS_STACK.get(trigger) ⇒ Array.<HTMLElement>

Gets all elements included in the stack for a given trigger button

Kind: static function of TARGETS_STACK

Returns: An array of elements that have been animated by the same trigger button

ParamTypeDescription
triggerstringCSS selector for the element that triggered the animation

updateDefaultConfig(opts)

Customize the default animations configurations by overwriting the CONFIG values

Kind: inner method of animate

See: CONFIG

ParamTypeDescription
optsObjectAll the options customized by the user

resetDefaultConfig()

Reset the configurations to its default values by removing from CONFIG all options customized by the user

Kind: inner method of animate

See: CONFIG

removeCustomCssProperties(element)

Removes the CSS properties customized by the user

Kind: static function of animate

ParamTypeDescription
elementHTMLElementThe DOM element with the custom CSS properties

setCssProperty(element, property, value)

Sets an inline CSS property

Kind: static function of animate

See: globals.PROPERTY_NAMES

ParamTypeDescription
elementHTMLElementThe DOM element which will receive the property
propertystringProperty key in the PROPERTY_NAMES object
valuestringValue of the CSS Property

updateCssProperties(element, opts)

Sets the CSS properties customized by the user in the animation function's options

Kind: static function of animate

ParamTypeDescription
elementHTMLElementThe DOM element to update the CSS Properties
optsObject.<string, string>Object containing a custom property key and a CSS value to be updated

getTargetSelector(eventTarget) ⇒ string

Searches and returns the 'target-selector' attribute

If the element which triggered the event doesn't have the attribute, will bubbles up untill the attribute is found. If no attribute is found, an empty string is returned and so no element will be selected to be animated

Kind: inner method of animate

Returns: The CSS selector for the animation target(s) or an empty string

ParamTypeDescription
eventTargetHTMLElementThe DOM element wich triggers the event

getTimeInMs(value) ⇒ number

Removes the unit from the duration or delay and returns the value in milliseconds

Kind: inner method of animate

Returns: The duration or delay in milliseconds

ParamTypeDescription
valuestringduration or delay CSS property value

getTotalAnimTime(element) ⇒ Object

Returns an object with the duration and delay time in milliseconds

Kind: inner method of animate

Returns: Both the duration and delay, in milliseconds

ParamTypeDescription
elementHTMLElementThe DOM element being animated

isVisibility(animType) ⇒ boolean

Returns true if the animation type is 'visibility'

Kind: inner method of animate

Returns: True if animation type is 'visibility'. False otherwise.

ParamTypeDescription
animTypestringEither 'motion' or 'visibility'

isMotion(animType) ⇒ boolean

Returns true if the animation type is 'motion'

Kind: inner method of animate

Returns: True if animation type is 'motion'. False otherwise.

ParamTypeDescription
animTypestringEither 'motion' or 'visibility'

removeMotionCssClass(element)

Removes the current motion animation CSS class from the element

Kind: inner method of animate

ParamTypeDescription
elementHTMLElementThe DOM element being animated

disable(element)

Sets an attribute to indicate that the element is currently being animated and so can not perform any other animations

Kind: inner method of animate

ParamTypeDescription
elementHTMLElementThe DOM element being animated

enable(element)

Removes the attribute that indicates that an element is currently being animated

Kind: inner method of animate

ParamType
elementHTMLElement

hasIterationProp(element) ⇒ boolean

Verifies if an element has defined an iteration CSS property

Kind: inner method of animate

Returns: True if the element has an iteration CSS property set, False otherwise

ParamType
elementHTMLElement

handleVisibilityToggle(element, args)

Sets the parent element dimensions, if needed.

Removes the collapsed or hidden class from the element, when necessary

Kind: inner method of animate

ParamTypeDescription
elementHTMLElementThe DOM element being animated
argsObjectAll the necessary arguments

endVisibilityToggle(element, opts)

Adds the hidden or collapsed class, when necessary. Finalize parent element's resize operations, if needed.

Kind: inner method of animate

ParamTypeDescription
elementHTMLElementThe DOM element being animated
optsObjectAll the necessary options

initCallback(trigger, fn, type)

Executes a given callback, checking, when necessary, if the callback was already executed by another element being animated by the same trigger button

Kind: inner method of animate

ParamTypeDescription
triggerstringThe CSS selector of the element that triggered the animation
fnfunctionThe callback to execute
typestringEither 'start' or 'complete'

getAction(element, animType) ⇒ string | null

Checks which animation CSS class is set to determine wich action to perform next

Kind: inner method of animate

Returns: 'show' or 'hide' or 'move' or 'moveBack'

ParamTypeDescription
elementHTMLElementThe DOM element being animated
animType*Either 'motion' or 'visibility'

eventHandler(el, animationId, opts) ⇒ function

Generates the handler function to be passed to the event listener

Kind: inner method of animate

Returns: A function to be passed to the addEventListener() as a handler

See:

ParamTypeDescription
elHTMLElementThe DOM element being animated
animationIdnumberThe ID of the animation in the *_ANIMS_ID
optsObjectThe options passed by the user