update 0.13.2

This commit is contained in:
yehuozhili
2022-04-05 02:47:09 +08:00
parent cddf4fc0c3
commit bc2004f704
9 changed files with 44 additions and 39 deletions

View File

@@ -1,3 +1,7 @@
## 0.13.2
修复自定义动画可能失效问题。
## 0.13.1 ## 0.13.1
修复定制动画重载画布的编辑问题。 修复定制动画重载画布的编辑问题。

View File

@@ -1,10 +1,12 @@
--- ---
title: change log title: Change log
toc: menu toc: menu
nav: nav:
title: change log title: Change log
order: 6 order: 6
--- ---
## 0.13.2
Fixed possible invalidation of custom animation.
## 0.13.1 ## 0.13.1
Fixed editing problem of custom animation overloaded canvas. Fixed editing problem of custom animation overloaded canvas.
## 0.13.0 ## 0.13.0

View File

@@ -5,6 +5,10 @@ nav:
title: 变更日志 title: 变更日志
order: 6 order: 6
--- ---
## 0.13.2
修复自定义动画可能失效问题。
## 0.13.1 ## 0.13.1
修复定制动画重载画布的编辑问题。 修复定制动画重载画布的编辑问题。

View File

@@ -585,7 +585,7 @@ function AnimateControl(props: AnimateControlProps) {
setDeletModal(false); setDeletModal(false);
}} }}
> >
<Table columns={columns} dataSource={customAnimate}></Table> <Table columns={columns} dataSource={customAnimate} pagination={false}></Table>
</Modal> </Modal>
</> </>
); );

View File

@@ -1,5 +1,5 @@
{ {
"version": "0.13.1", "version": "0.13.2",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "dist/index.js",
"module": "dist/dooringx-lib.esm.js", "module": "dist/dooringx-lib.esm.js",

View File

@@ -33,15 +33,34 @@ export interface TransformItem {
animateName: string; animateName: string;
keyframes: TransformItemObj[]; keyframes: TransformItemObj[];
} }
export const styleSheetId = 'dooringx_dynamic_style';
export class AnimateFactory { export class AnimateFactory {
constructor(public customAnimateName: Array<CustomAnimateObj> = []) {} constructor(public customAnimateName: Array<CustomAnimateObj> = []) {}
getCustomAnimateName() { getCustomAnimateName() {
return this.customAnimateName; return this.customAnimateName;
} }
searchSheet(): null | CSSStyleSheet {
let sheet: null | CSSStyleSheet = null;
Array.from(document.styleSheets).forEach((v) => {
const node = v?.ownerNode as Element;
if (node?.id === styleSheetId) {
sheet = v;
}
});
return sheet;
}
getStyleSheets() { getStyleSheets() {
return document.styleSheets; let sheet = this.searchSheet();
if (!sheet) {
let style = document.createElement('style');
style.id = styleSheetId;
style.appendChild(document.createTextNode(''));
document.head.appendChild(style);
}
sheet = this.searchSheet();
return sheet;
} }
/** /**
@@ -51,32 +70,8 @@ export class AnimateFactory {
* @memberof AnimateFactory * @memberof AnimateFactory
*/ */
inserKeyframeAnimate(ruleText: string) { inserKeyframeAnimate(ruleText: string) {
const sheets = this.getStyleSheets(); const sheet = this.getStyleSheets();
if (sheets.length === 0) { if (sheet) sheet.insertRule(ruleText, sheet.cssRules.length);
let style = document.createElement('style');
style.appendChild(document.createTextNode(''));
document.head.appendChild(style);
}
// const len = sheets.length;
// let ss: number | null = null;
// let st: number | null = null;
// for (let i = 0; i < len; i++) {
// for (let k = 0; k < sheets[i].cssRules.length; k++) {
// const rule = sheets[i].cssRules[k] as CSSKeyframesRule;
// const name = rule?.name;
// if (name && name === keyframeName) {
// // 删除该keyframe
// ss = i;
// st = k;
// }
// }
// }
// if (ss !== null && st !== null) {
// sheets[ss].deleteRule(st);
// }
// let sheet = sheets[ss ? ss : sheets.length - 1] as CSSStyleSheet;
let sheet = sheets[0] as CSSStyleSheet; // 末尾的经常存在重复覆盖的问题
sheet.insertRule(ruleText, sheet.cssRules.length);
} }
/** /**
@@ -88,21 +83,20 @@ export class AnimateFactory {
*/ */
deleteKeyFrameAnimate(animateName: string) { deleteKeyFrameAnimate(animateName: string) {
const sheets = this.getStyleSheets(); const sheets = this.getStyleSheets();
if (sheets.length === 0) { if (!sheets) {
return; return;
} }
const sheet = sheets[0] as CSSStyleSheet; const len = sheets.cssRules.length;
const len = sheet.cssRules.length;
let ss = null; let ss = null;
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
const rule = sheet.cssRules[i] as CSSKeyframesRule; const rule = sheets.cssRules[i] as CSSKeyframesRule;
const name = rule?.name; const name = rule?.name;
if (name && name === animateName) { if (name && name === animateName) {
ss = i; ss = i;
} }
} }
if (ss !== null) { if (ss !== null) {
sheet.deleteRule(ss); sheets.deleteRule(ss);
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "dooringx-plugin-template", "name": "dooringx-plugin-template",
"version": "0.13.1", "version": "0.13.2",
"description": "> TODO: description", "description": "> TODO: description",
"author": "yehuozhili <673632758@qq.com>", "author": "yehuozhili <673632758@qq.com>",
"homepage": "https://github.com/H5-Dooring/dooringx#readme", "homepage": "https://github.com/H5-Dooring/dooringx#readme",

View File

@@ -40,7 +40,7 @@
"@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-node-resolve": "^13.0.4",
"@rollup/plugin-url": "^6.1.0", "@rollup/plugin-url": "^6.1.0",
"@svgr/rollup": "^5.5.0", "@svgr/rollup": "^5.5.0",
"dooringx-lib": "^0.13.1", "dooringx-lib": "^0.13.2",
"postcss": "^8.3.6", "postcss": "^8.3.6",
"rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.1", "rollup-plugin-postcss": "^4.0.1",

View File

@@ -51,6 +51,7 @@ const concatResult = (result) => {
//替换Title: //替换Title:
if (v.src.startsWith('title:') && v.dst.startsWith('Title:')) { if (v.src.startsWith('title:') && v.dst.startsWith('Title:')) {
v.dst = v.dst.replace('Title:', 'title:'); v.dst = v.dst.replace('Title:', 'title:');
v.dst = v.dst.replace('change log', 'Change log');
} }
const fi = v.src.startsWith('##') ? v.src : v.dst; const fi = v.src.startsWith('##') ? v.src : v.dst;
if (i > navstart && i < line) { if (i > navstart && i < line) {