版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

64 строки
1.9 KiB

  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const CSSRule_1 = __importDefault(require("../CSSRule"));
  7. const CSSStyleDeclaration_1 = __importDefault(require("../declaration/CSSStyleDeclaration"));
  8. const CSSKeyframeRule_1 = __importDefault(require("./CSSKeyframeRule"));
  9. const CSS_RULE_REGEXP = /([^{]+){([^}]+)}/;
  10. /**
  11. * CSSRule interface.
  12. */
  13. class CSSKeyframesRule extends CSSRule_1.default {
  14. constructor() {
  15. super(...arguments);
  16. this.type = CSSRule_1.default.KEYFRAMES_RULE;
  17. this.cssRules = [];
  18. this.name = null;
  19. }
  20. /**
  21. * Returns css text.
  22. *
  23. * @returns CSS text.
  24. */
  25. get cssText() {
  26. let cssText = '';
  27. for (const cssRule of this.cssRules) {
  28. cssText += cssRule.cssText + ' ';
  29. }
  30. return `@keyframes ${this.name} { ${cssText}}`;
  31. }
  32. /**
  33. * Appends a rule.
  34. *
  35. * @param rule Rule. E.g. "0% { transform: rotate(360deg); }".
  36. */
  37. appendRule(rule) {
  38. const match = rule.match(CSS_RULE_REGEXP);
  39. if (match) {
  40. const cssRule = new CSSKeyframeRule_1.default();
  41. const style = new CSSStyleDeclaration_1.default();
  42. cssRule.parentRule = this;
  43. cssRule.keyText = match[1].trim();
  44. style.cssText = match[2].trim();
  45. style.parentRule = this;
  46. cssRule.style = style;
  47. }
  48. }
  49. /**
  50. * Removes a rule.
  51. *
  52. * @param rule Rule. E.g. "0%".
  53. */
  54. deleteRule(rule) {
  55. for (let i = 0, max = this.cssRules.length; i < max; i++) {
  56. if (this.cssRules[i].keyText === rule) {
  57. this.cssRules.splice(i, 1);
  58. break;
  59. }
  60. }
  61. }
  62. }
  63. exports.default = CSSKeyframesRule;
  64. //# sourceMappingURL=CSSKeyframesRule.js.map