cross-fade.js 863 B

1234567891011121314151617181920212223242526272829303132333435
  1. let list = require('postcss').list
  2. let Value = require('../value')
  3. class CrossFade extends Value {
  4. replace(string, prefix) {
  5. return list
  6. .space(string)
  7. .map(value => {
  8. if (value.slice(0, +this.name.length + 1) !== this.name + '(') {
  9. return value
  10. }
  11. let close = value.lastIndexOf(')')
  12. let after = value.slice(close + 1)
  13. let args = value.slice(this.name.length + 1, close)
  14. if (prefix === '-webkit-') {
  15. let match = args.match(/\d*.?\d+%?/)
  16. if (match) {
  17. args = args.slice(match[0].length).trim()
  18. args += `, ${match[0]}`
  19. } else {
  20. args += ', 0.5'
  21. }
  22. }
  23. return prefix + this.name + '(' + args + ')' + after
  24. })
  25. .join(' ')
  26. }
  27. }
  28. CrossFade.names = ['cross-fade']
  29. module.exports = CrossFade