0.2.0 • Published 7 years ago

ember-css-animation-triggers v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Ember CSS Animation Triggers

Ember CSS Animation Triggers is an Ember addon with a collection of components for triggering CSS animations.

Installation

As an addon

  • ember install ember-css-animation-triggers

For development

  • git clone this repository
  • npm install
  • bower install

Usage

Ember CSS Animation Triggers currently includes two components: animate-on-change and animate-on-interval.

These components animate their content by applying a CSS class with an animation to their elements and removes it again after the animation is finished. Note that this addon doesn't provide any ready-made CSS animation classes; these have to be declared separately.

The components' individual usage is detailed below.

Component: animate-on-change

The animate-on-change component animates its content when a particular value changes.

In the example below, the CSS class grow will be applied to the element when the value of count changes:

{{#animate-on-change animationClass="grow" observedValue=count}}
  {{count}}
{{/animate-on-change}}

Which can look like this:

Example result of using `animate-on-change`

See tests/dummy/app for the complete implementation of the example above. It can be previewed by running the demo app.

The public interface of the component is given in the table below.

Property nameTypeDefaultDescription
animationClassStringnullName of the CSS class defining the animation.
observedValue*nullValue to observe.
enabledBooleantrueWhether the animation should run.

Component: animate-on-interval

The animate-on-interval component animates its content at a particular time interval.

In the example below, the CSS class hop will be applied to the component's element with pauses between 2 and 3 seconds between each animation, but it will be applied within 1 second the first time the animation is run.

{{#animate-on-interval
   animationClass="hop"
   minWait=2000
   maxWait=3000
   minInitialwait=0
   maxInitialwait=1000}}
  Hello!
{{/animate-on-interval}}

See the demo app in tests/dummy/app for en example of how to achieve the following effect:

Example result of using `animate-on-interval`

The public interface of the component is given in the table below.

Property nameTypeDefaultDescription
animationClassStringnullName of the CSS class defining the animation.
minWaitNumber1000Minimum time (ms) to wait before showing the animation again.
maxWaitNumber2000Maximum time (ms) to wait before showing the animation again.
minInitialWaitNumber500Minimum time (ms) to wait before showing the animation for the first time.
maxInitialWaitNumber1000Maximum time (ms) to wait before showing the animation for the first time.
enabledBooleantrueWhether the animation shuld run.

Demo App

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.