cross-fade.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
  3. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
  4. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  5. var list = require('postcss').list;
  6. var Value = require('../value');
  7. var CrossFade = /*#__PURE__*/function (_Value) {
  8. _inheritsLoose(CrossFade, _Value);
  9. function CrossFade() {
  10. return _Value.apply(this, arguments) || this;
  11. }
  12. var _proto = CrossFade.prototype;
  13. _proto.replace = function replace(string, prefix) {
  14. var _this = this;
  15. return list.space(string).map(function (value) {
  16. if (value.slice(0, +_this.name.length + 1) !== _this.name + '(') {
  17. return value;
  18. }
  19. var close = value.lastIndexOf(')');
  20. var after = value.slice(close + 1);
  21. var args = value.slice(_this.name.length + 1, close);
  22. if (prefix === '-webkit-') {
  23. var match = args.match(/\d*.?\d+%?/);
  24. if (match) {
  25. args = args.slice(match[0].length).trim();
  26. args += ", " + match[0];
  27. } else {
  28. args += ', 0.5';
  29. }
  30. }
  31. return prefix + _this.name + '(' + args + ')' + after;
  32. }).join(' ');
  33. };
  34. return CrossFade;
  35. }(Value);
  36. _defineProperty(CrossFade, "names", ['cross-fade']);
  37. module.exports = CrossFade;