bem-contrib / bem-animations

:bell: Easy and Fast in use (based on Animate CSS)
MIT License
13 stars 6 forks source link

Add API: queue #6

Closed belozer closed 8 years ago

belozer commented 8 years ago
// Simple queue
animation.queue(['fade-in-down', 'flip-x', 'fade-out']);

// Queue with callback
animation.queue(['fade-in-down', 'flip-x', 'fade-out'], callback);

// Queue extended version
animation.queue([
  {type: 'fade-in-down', onStart: callback, onEnd: callback}, 
  {type: 'flip-x', onStart: callback, onEnd: callback}, 
  {type: 'fade-out', onIteration: callback}
], callback);
belozer commented 8 years ago

alternative method name scene and sequence

belozer commented 8 years ago

.queue(queue [,callback][,hide])

// Simple and hide block (display: none) after animation
animation.queue(['fade-in', 'fade-out'], true);

// Simple with callback
animation.queue(['fade-in', 'fade-out'], () => console.log('ended queue'));

// Extended
animation.queue([
  // step 1
  {type: 'fade-in', duration: 200, delay: 100, callbacks: {
    onStart: () => console.log('fade-in started'),
    onEnd: () => console.log('fade-in ended')
  }},

  // step 2
  () => console.log('call function after first step'),

  // step 3
  {type: 'fade-out', delay: 200},
], () => console.log('ended queue'));