function addAnimation(alpha, trail, i, lines) {
    var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
      , start = 0.01 + i/lines*100
      , z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)
      , prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
      , pre = prefix && '-'+prefix+'-' || ''

    if (!animations[name]) {
      sheet.insertRule(
        '@' + pre + 'keyframes ' + name + '{' +
        '0%{opacity:' + z + '}' +
        start + '%{opacity:' + alpha + '}' +
        (start+0.01) + '%{opacity:1}' +
        (start+trail) % 100 + '%{opacity:' + alpha + '}' +
        '100%{opacity:' + z + '}' +
        '}', sheet.cssRules.length)

      animations[name] = 1
    }
    return name
  }
function addAnimation(alpha, trail, i, lines) {
    var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
      , start = 0.01 + i/lines*100
      , z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)
      , prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
      , pre = prefix && '-'+prefix+'-' || ''

    if (!animations[name]) {
      sheet.insertRule(
        '@' + pre + 'keyframes ' + name + '{' +
        '0%{opacity:' + z + '}' +
        start + '%{opacity:' + alpha + '}' +
        (start+0.01) + '%{opacity:1}' +
        (start+trail) % 100 + '%{opacity:' + alpha + '}' +
        '100%{opacity:' + z + '}' +
        '}', sheet.cssRules.length)

      animations[name] = 1
    }
    return name
  }
function addAnimation ( alpha , trail , i , lines ) { var name = [ 'opacity' , trail , ~ ~ ( alpha * 100 ) , i , lines ] . join ( '-' ) , start = 0.01 + i / lines * 100 , z = Math . max ( 1 - ( 1 - alpha ) / trail * ( 100 - start ) , alpha ) , prefix = useCssAnimations . substring ( 0 , useCssAnimations . indexOf ( 'Animation' ) ) . toLowerCase ( ) , pre = prefix && '-' + prefix + '-' || '' if ( ! animations [ name ] ) { sheet . insertRule ( '@' + pre + 'keyframes ' + name + '{' + '0%{opacity:' + z + '}' + start + '%{opacity:' + alpha + '}' + ( start + 0.01 ) + '%{opacity:1}' + ( start + trail ) % 100 + '%{opacity:' + alpha + '}' + '100%{opacity:' + z + '}' + '}' , sheet . cssRules . length ) animations [ name ] = 1 } return name }
Creates an opacity keyframe animation rule and returns its name.
Since most mobile Webkits have timing issues with animation-delay,
we create separate rules for each line/segment.
Creates an opacity keyframe animation rule and returns its name . Since most mobile Webkits have timing issues with animation - delay we create separate rules for each line / segment .