pixuireactcomponents 1.3.34 → 1.3.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +0 -2
- package/index.js +0 -2
- package/package.json +1 -1
- package/src/components/react/app/bulletscreen/BulletScreenAnimation.js +1 -2
- package/src/components/react/app/frameAnimation/FrameAnimation.d.ts +2 -2
- package/src/components/react/app/frameAnimation/FrameAnimation.js +21 -8
- package/src/components/tools/Logger.d.ts +0 -6
- package/src/components/tools/Logger.js +0 -138
- package/src/components/tools/makeImage.d.ts +0 -1
- package/src/components/tools/makeImage.js +0 -90
package/index.d.ts
CHANGED
|
@@ -7,7 +7,5 @@ export { ToggleGroup } from "./src/components/react/app/togglegroup/ToggleGroup"
|
|
|
7
7
|
export { GradientText } from "./src/components/react/base/gradient/GradientText";
|
|
8
8
|
export { PVideo } from "./src/components/react/base/pixVideo/PixVideo";
|
|
9
9
|
export { OutlineText } from "./src/components/react/base/outlinetext/OutlineText";
|
|
10
|
-
export { Logger } from "./src/components/tools/Logger";
|
|
11
|
-
export { makeImages } from "./src/components/tools/makeImage";
|
|
12
10
|
export { Slider, SliderProps } from "./src/components/react/app/slider/Slider";
|
|
13
11
|
export { ImgPreLoader, PreLoadPic } from "./src/components/tools/ImgPreLoader";
|
package/index.js
CHANGED
|
@@ -10,5 +10,3 @@ export { GradientText } from './src/components/react/base/gradient/GradientText'
|
|
|
10
10
|
export { PVideo } from './src/components/react/base/pixVideo/PixVideo';
|
|
11
11
|
export { OutlineText } from './src/components/react/base/outlinetext/OutlineText';
|
|
12
12
|
export { ImgPreLoader, PreLoadPic } from './src/components/tools/ImgPreLoader';
|
|
13
|
-
export { Logger } from './src/components/tools/Logger';
|
|
14
|
-
export { makeImages } from './src/components/tools/makeImage';
|
package/package.json
CHANGED
|
@@ -16,7 +16,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
/* eslint-disable linebreak-style */
|
|
17
17
|
import { Component, h } from 'preact';
|
|
18
18
|
import { BulletInfo, BulletConfig, BulletItemAnimation } from './BulletItemAnimation';
|
|
19
|
-
import { Logger } from '../../../tools/Logger';
|
|
20
19
|
// item数据类型
|
|
21
20
|
// {
|
|
22
21
|
// key : number,
|
|
@@ -195,7 +194,7 @@ var BulletScreenAnimation = /** @class */ (function (_super) {
|
|
|
195
194
|
if (this.isScreenSizeSame(this.props, nextProps))
|
|
196
195
|
return;
|
|
197
196
|
console.log('ScreenSizeChanged, generate new Animation!!!============');
|
|
198
|
-
Logger.ObjectPrinter(nextProps, '# nextProps #');
|
|
197
|
+
// Logger.ObjectPrinter(nextProps, '# nextProps #');
|
|
199
198
|
this.generateTargetAnimation(nextProps);
|
|
200
199
|
this.initChannels(nextProps);
|
|
201
200
|
this.setScreenSizeChanged();
|
|
@@ -3,8 +3,8 @@ export declare let FrameAnimation: (props: {
|
|
|
3
3
|
rootId?: string | undefined;
|
|
4
4
|
rootClassName?: string | undefined;
|
|
5
5
|
totalTime: number;
|
|
6
|
-
width
|
|
7
|
-
height
|
|
6
|
+
width: string;
|
|
7
|
+
height: string;
|
|
8
8
|
srcArr: string[];
|
|
9
9
|
onShow?: Function | undefined;
|
|
10
10
|
onFinish?: Function | undefined;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'preact/hooks';
|
|
2
2
|
import { createRef, h } from 'preact';
|
|
3
|
+
// let requestAnimationFrame = (f) => {
|
|
4
|
+
// return setTimeout(f, 300);
|
|
5
|
+
// };
|
|
3
6
|
export var FrameAnimation = function (props) {
|
|
4
7
|
var _a, _b;
|
|
5
8
|
props.preloadCount = Math.max(props.preloadCount || 5, 5);
|
|
@@ -12,26 +15,28 @@ export var FrameAnimation = function (props) {
|
|
|
12
15
|
var startTime = Date.now();
|
|
13
16
|
var onrFrameTime = totalTime / srcArr.length;
|
|
14
17
|
//设置第一帧
|
|
15
|
-
cRefArr[0].current.src = srcArr[0];
|
|
16
18
|
cRefArr[0].current.style.visibility = 'visible';
|
|
17
19
|
nextFrame(startTime, onrFrameTime, 0);
|
|
18
20
|
}, []);
|
|
19
21
|
//循环修改imgEleArr的src和visibility实现帧动画,,记录上一帧的序号防止跳帧
|
|
20
22
|
var nextFrame = function (startTime, v, showedFrame) {
|
|
21
23
|
var nowTime = Date.now();
|
|
22
|
-
// console.log('nextFrame', 'nowTime', nowTime, 'startTime', startTime, 'nowArrIndex', nowArrIndex, 'nowFrame', nowFrame);
|
|
23
24
|
//该显示第几帧
|
|
24
25
|
var nowFrame = Math.floor((nowTime - startTime) / v);
|
|
25
26
|
//使用第几个img元素
|
|
26
27
|
var nowArrIndex = nowFrame % preloadCount;
|
|
27
28
|
var showedArrIndex = showedFrame % preloadCount;
|
|
29
|
+
// console.log('nextFrame', nowFrame, 'nowArrIndex', nowArrIndex, 'nowFrame', nowFrame);
|
|
28
30
|
if (nowFrame >= srcArr.length) {
|
|
29
31
|
onFinish && onFinish();
|
|
30
32
|
if (!loop) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
cRefArr.forEach(function (ref, i) {
|
|
34
|
+
ref.current.style.visibility = 'hidden';
|
|
35
|
+
});
|
|
36
|
+
if (showLastFrame) {
|
|
37
|
+
//跳帧的话,最后一帧可能不是最后一张图片,设为最后一张图片
|
|
38
|
+
cRefArr[0].current.src = srcArr[srcArr.length - 1];
|
|
39
|
+
cRefArr[0].current.style.visibility = 'visible';
|
|
35
40
|
}
|
|
36
41
|
return;
|
|
37
42
|
}
|
|
@@ -41,6 +46,7 @@ export var FrameAnimation = function (props) {
|
|
|
41
46
|
ref.current.src = srcArr[i];
|
|
42
47
|
});
|
|
43
48
|
startTime = Date.now();
|
|
49
|
+
cRefArr[0].current.style.visibility = 'visible';
|
|
44
50
|
requestAnimationFrame(function () {
|
|
45
51
|
nextFrame(startTime, v, 0);
|
|
46
52
|
});
|
|
@@ -50,8 +56,15 @@ export var FrameAnimation = function (props) {
|
|
|
50
56
|
cRefArr[nowArrIndex].current.style.visibility = 'visible';
|
|
51
57
|
//隐藏上一帧
|
|
52
58
|
cRefArr[showedArrIndex].current.style.visibility = 'hidden';
|
|
53
|
-
|
|
54
|
-
cRefArr
|
|
59
|
+
//可能跳帧,在所有其他的元素上预加载
|
|
60
|
+
cRefArr.forEach(function (ref, i) {
|
|
61
|
+
if (i !== nowArrIndex) {
|
|
62
|
+
var offset = (i + cRefArr.length - nowArrIndex) % cRefArr.length;
|
|
63
|
+
if (ref.current.src !== srcArr[(nowFrame + offset) % srcArr.length]) {
|
|
64
|
+
ref.current.src = srcArr[(nowFrame + offset) % srcArr.length];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
55
68
|
showedFrame = nowFrame;
|
|
56
69
|
onShow && onShow(nowFrame);
|
|
57
70
|
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
export function Logger() {
|
|
2
|
-
}
|
|
3
|
-
// 移除最后一个(key, value)后面的 ','
|
|
4
|
-
var regex = new RegExp("(,)(\n$)");
|
|
5
|
-
/**
|
|
6
|
-
* printer1: 完整打印,用4个空格缩进
|
|
7
|
-
* @param object Object
|
|
8
|
-
* @param name string
|
|
9
|
-
*/
|
|
10
|
-
Logger.ObjectPrinter = function (object, name) {
|
|
11
|
-
var strResult = "";
|
|
12
|
-
strResult += name + " = ";
|
|
13
|
-
strResult += getTreeStyleStr(object, 1);
|
|
14
|
-
strResult = strResult.replace(regex, "$2");
|
|
15
|
-
console.warn(strResult);
|
|
16
|
-
};
|
|
17
|
-
function getTreeStyleStr(object, level) {
|
|
18
|
-
var isArray = object instanceof Array;
|
|
19
|
-
var str = isArray ? "[\n" : "{\n";
|
|
20
|
-
for (var key in object) {
|
|
21
|
-
var value = object[key];
|
|
22
|
-
var curSeparation = getSeparation1(level);
|
|
23
|
-
if (typeof (value) != 'object') {
|
|
24
|
-
str += curSeparation + key + " : " + value + ",\n";
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
str += curSeparation + key + " : " + getTreeStyleStr(value, level + 1);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
str = str.replace(regex, "$2");
|
|
31
|
-
str += getSeparation1(level - 1) + (isArray ? "],\n" : "},\n");
|
|
32
|
-
return str;
|
|
33
|
-
}
|
|
34
|
-
var SEPARARION1 = " ";
|
|
35
|
-
function getSeparation1(level) {
|
|
36
|
-
var totalSeparation = "";
|
|
37
|
-
while (level > 0) {
|
|
38
|
-
totalSeparation += SEPARARION1;
|
|
39
|
-
level--;
|
|
40
|
-
}
|
|
41
|
-
return totalSeparation;
|
|
42
|
-
}
|
|
43
|
-
var regexForLine = new RegExp(",$");
|
|
44
|
-
/**
|
|
45
|
-
* printer2: 完整打印,用\t
|
|
46
|
-
* @param object Object
|
|
47
|
-
* @param name sring
|
|
48
|
-
*/
|
|
49
|
-
Logger.ObjectPrinter2 = function (object, name) {
|
|
50
|
-
var lines = [];
|
|
51
|
-
lines.push("".concat(name, " = "));
|
|
52
|
-
getTreeStyleLines(object, 1, lines);
|
|
53
|
-
console.warn(lines.join("\n"));
|
|
54
|
-
};
|
|
55
|
-
function getTreeStyleLines(object, level, lines) {
|
|
56
|
-
var isArray = object instanceof Array;
|
|
57
|
-
var linePostFix = isArray ? "[" : "{";
|
|
58
|
-
var lastLine = lines.pop();
|
|
59
|
-
lines.push(lastLine + linePostFix);
|
|
60
|
-
for (var key in object) {
|
|
61
|
-
var value = object[key];
|
|
62
|
-
var curSeparation = getSeparation2(level);
|
|
63
|
-
if (typeof (value) != 'object') {
|
|
64
|
-
var curLine = curSeparation + key + " : " + value + ",";
|
|
65
|
-
lines.push(curLine);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
var curLinePreFix = curSeparation + key + " : ";
|
|
69
|
-
lines.push(curLinePreFix);
|
|
70
|
-
getTreeStyleLines(value, level + 1, lines);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
lastLine = lines.pop();
|
|
74
|
-
if (lastLine)
|
|
75
|
-
lines.push(lastLine.replace(regexForLine, "")); // 一定执行
|
|
76
|
-
lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
|
|
77
|
-
}
|
|
78
|
-
var SEPARARION2 = "\t";
|
|
79
|
-
function getSeparation2(level) {
|
|
80
|
-
var totalSeparation = "";
|
|
81
|
-
while (level > 0) {
|
|
82
|
-
totalSeparation += SEPARARION2;
|
|
83
|
-
level--;
|
|
84
|
-
}
|
|
85
|
-
return totalSeparation;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
printer3: 打印关键层级信息,如果是数组,只打印第一个,后续用 ...len 代替(PS: 假定数组中每个元素都是一样的格式)
|
|
90
|
-
* @param object Object
|
|
91
|
-
* @param name string
|
|
92
|
-
*/
|
|
93
|
-
Logger.HierarchyPrinter = function (object, name) {
|
|
94
|
-
var lines = [];
|
|
95
|
-
lines.push("".concat(name, " = "));
|
|
96
|
-
getTreeStyleHierarchyLines(object, 1, lines);
|
|
97
|
-
console.warn(lines.join("\n"));
|
|
98
|
-
};
|
|
99
|
-
function getTreeStyleHierarchyLines(object, level, lines) {
|
|
100
|
-
var isArray = object instanceof Array;
|
|
101
|
-
var linePostFix = isArray ? "[" : "{";
|
|
102
|
-
var lastLine = lines.pop();
|
|
103
|
-
lines.push(lastLine + linePostFix);
|
|
104
|
-
if (isArray) {
|
|
105
|
-
var key = 0;
|
|
106
|
-
var value = object[key];
|
|
107
|
-
var curSeparation = getSeparation2(level);
|
|
108
|
-
if (typeof (value) != 'object') {
|
|
109
|
-
var curLine = curSeparation + key + " : " + value + ",";
|
|
110
|
-
lines.push(curLine);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
var curLinePreFix = curSeparation + key + " : ";
|
|
114
|
-
lines.push(curLinePreFix);
|
|
115
|
-
getTreeStyleHierarchyLines(value, level + 1, lines);
|
|
116
|
-
}
|
|
117
|
-
lines.push(curSeparation + "...len=" + object.length);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
for (var key in object) {
|
|
121
|
-
var value = object[key];
|
|
122
|
-
var curSeparation = getSeparation2(level);
|
|
123
|
-
if (typeof (value) != 'object') {
|
|
124
|
-
var curLine = curSeparation + key + " : " + value + ",";
|
|
125
|
-
lines.push(curLine);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
var curLinePreFix = curSeparation + key + " : ";
|
|
129
|
-
lines.push(curLinePreFix);
|
|
130
|
-
getTreeStyleHierarchyLines(value, level + 1, lines);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
lastLine = lines.pop();
|
|
134
|
-
if (lastLine)
|
|
135
|
-
lines.push(lastLine.replace(regexForLine, "")); // 一定执行
|
|
136
|
-
}
|
|
137
|
-
lines.push(getSeparation2(level - 1) + (isArray ? "]" : "}"));
|
|
138
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function makeImages(_inputPath: any, _outputPath: any): void;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
// 自动生成图集, 生成一个Images.ts文件,引用目标目录下的所有图片, 方便直接使用
|
|
3
|
-
/*
|
|
4
|
-
commands:
|
|
5
|
-
create imgDirectoryPath
|
|
6
|
-
update imgDirectoryPath
|
|
7
|
-
*/
|
|
8
|
-
var path = require('path');
|
|
9
|
-
var inputPath = '';
|
|
10
|
-
var outputPath = '';
|
|
11
|
-
var getfs = function () {
|
|
12
|
-
return require('fs');
|
|
13
|
-
};
|
|
14
|
-
export var makeImages = function (_inputPath, _outputPath) {
|
|
15
|
-
if (!getfs()) {
|
|
16
|
-
return; //不在node环境中
|
|
17
|
-
}
|
|
18
|
-
if (!isDirectoryExist(_inputPath)) {
|
|
19
|
-
console.warn('inputPath is not a directory!');
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (!isDirectoryExist(_outputPath)) {
|
|
23
|
-
console.warn('outputPath is not a directory!');
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
var imgUrls = [];
|
|
27
|
-
inputPath = _inputPath;
|
|
28
|
-
outputPath = _outputPath;
|
|
29
|
-
collectImageUrls(inputPath, imgUrls, true);
|
|
30
|
-
imgUrls.sort();
|
|
31
|
-
generateImage(inputPath, imgUrls);
|
|
32
|
-
};
|
|
33
|
-
function isDirectoryExist(directory) {
|
|
34
|
-
var stat;
|
|
35
|
-
try {
|
|
36
|
-
stat = getfs.lstatSync(directory);
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
return stat.isDirectory();
|
|
42
|
-
}
|
|
43
|
-
function collectImageUrls(inputPath, imgUrls, isFirst) {
|
|
44
|
-
var files = getfs.readdirSync(inputPath);
|
|
45
|
-
for (var i = 0; i < files.length; i++) {
|
|
46
|
-
var current = path.join(inputPath, files[i]).replaceAll('\\', '/');
|
|
47
|
-
if (isDirectoryExist(current)) {
|
|
48
|
-
// if it's a directory ,recursive
|
|
49
|
-
collectImageUrls(current, imgUrls, false);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
if (current.endsWith('.png') || current.endsWith('.jpg') || current.endsWith('.jpeg') || current.endsWith('.gif')) {
|
|
53
|
-
imgUrls.push(current);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function generateImage(inputPath, imgUrls, keyMap) {
|
|
59
|
-
var out = path.resolve(outputPath, 'Images.ts');
|
|
60
|
-
getfs.writeFileSync(out, '');
|
|
61
|
-
// write import
|
|
62
|
-
for (var i = 0; i < imgUrls.length; i++) {
|
|
63
|
-
var current = imgUrls[i];
|
|
64
|
-
var imgKey = generateImgKey(inputPath, current);
|
|
65
|
-
if (current.startsWith('../'))
|
|
66
|
-
current = './' + current;
|
|
67
|
-
// console.warn(inputPath, current, imgKey)
|
|
68
|
-
getfs.writeFileSync(out, 'import '.concat(imgKey, ' from "').concat(current, '";\n'), { flag: 'a+' });
|
|
69
|
-
}
|
|
70
|
-
getfs.writeFileSync(out, '\n\n', { flag: 'a+' });
|
|
71
|
-
//write export
|
|
72
|
-
getfs.writeFileSync(out, '\nexport const Images = {\n', { flag: 'a+' });
|
|
73
|
-
for (var i = 0; i < imgUrls.length; i++) {
|
|
74
|
-
var current = imgUrls[i];
|
|
75
|
-
var imgKey = generateImgKey(inputPath, current);
|
|
76
|
-
var imgNewname = keyMap == null || keyMap.get(imgKey) == undefined ? imgKey : keyMap.get(imgKey);
|
|
77
|
-
getfs.writeFileSync(out, ' '.concat(imgNewname, ': ').concat(imgKey, ',\n'), { flag: 'a+' });
|
|
78
|
-
}
|
|
79
|
-
getfs.writeFileSync(out, '}\n\n', { flag: 'a+' });
|
|
80
|
-
console.log(keyMap == null ? 'generate' : 'update', ' Images.ts successfully!');
|
|
81
|
-
}
|
|
82
|
-
function generateImgKey(inputPath, imgUrl) {
|
|
83
|
-
var key = imgUrl.substring(inputPath.length);
|
|
84
|
-
key = key.replace(/\//g, '_');
|
|
85
|
-
if (key.startsWith('_'))
|
|
86
|
-
key = key.substring(1);
|
|
87
|
-
var extname = path.extname(key);
|
|
88
|
-
key = key.substring(0, key.length - extname.length);
|
|
89
|
-
return key;
|
|
90
|
-
}
|