/**
 * perform transition animation on an element specified by id
 * @param  {HTMLElement}    dom
 * @param  {object}         options
 * @param  {object}         options.styles
 * @param  {number}         options.duration(ms) || 0
 * @param  {string}         [options.timingFunction] || 'linear'
 * @param  {number}         [options.delay=0(ms)] || 0
 * @param  {Function}       callback
 */
function transition(dom, options, callback) {
  const {styles, duration = 0, timingFunction='linear', delay=0} = options
  if (dom && options && styles) {
    dom.style = {...dom.style, ...styles}
    dom.style.transitionDuration = `${duration}ms`
    dom.style.animationTimingFunction = `${timingFunction}`
    dom.style.transitionDelay = `${delay}ms`
    setTimeout(() =>{
      callback && callback()
    },duration + delay)
  }
}
export default {
  transition,
}
