sense-react-timeline-editor 1.1.7 → 1.1.8
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/dist/index.esm.js +31 -5
- package/dist/index.js +30 -4
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useEffect, cloneElement, useImperativeHandle, useState, useLayoutEffect, useCallback, memo, forwardRef
|
|
1
|
+
import React, { useRef, useEffect, cloneElement, useImperativeHandle, useState, useLayoutEffect, useCallback, useMemo, memo, forwardRef } from 'react';
|
|
2
2
|
import { AutoSizer, Grid, ScrollSync } from 'react-virtualized';
|
|
3
3
|
import { useThrottleEffect, useThrottleFn } from 'ahooks';
|
|
4
4
|
import { prefixNames } from 'framework-utils';
|
|
@@ -2906,6 +2906,10 @@ var EditRow = function EditRow(props) {
|
|
|
2906
2906
|
setCursor = props.setCursor,
|
|
2907
2907
|
hideCursor = props.hideCursor,
|
|
2908
2908
|
uploadBgMusic = props.uploadBgMusic;
|
|
2909
|
+
var _useState = useState(20),
|
|
2910
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2911
|
+
visibleCount = _useState2[0],
|
|
2912
|
+
setVisibleCount = _useState2[1];
|
|
2909
2913
|
var classNames = ['edit-row'];
|
|
2910
2914
|
if (rowData === null || rowData === void 0 ? void 0 : rowData.selected) classNames.push('selected');
|
|
2911
2915
|
var clientWidth = document.documentElement.clientWidth;
|
|
@@ -2919,7 +2923,31 @@ var EditRow = function EditRow(props) {
|
|
|
2919
2923
|
scale: scale,
|
|
2920
2924
|
scaleWidth: scaleWidth
|
|
2921
2925
|
});
|
|
2922
|
-
|
|
2926
|
+
var visibleActions = useMemo(function () {
|
|
2927
|
+
return ((rowData === null || rowData === void 0 ? void 0 : rowData.actions) || []).filter(function (action) {
|
|
2928
|
+
return action.end >= timeStart && action.start <= timeEnd;
|
|
2929
|
+
}).sort(function (a, b) {
|
|
2930
|
+
return a.start - b.start;
|
|
2931
|
+
});
|
|
2932
|
+
}, [rowData === null || rowData === void 0 ? void 0 : rowData.actions, timeStart, timeEnd]);
|
|
2933
|
+
var renderActions = useMemo(function () {
|
|
2934
|
+
return visibleActions.slice(0, visibleCount);
|
|
2935
|
+
}, [visibleActions, visibleCount]);
|
|
2936
|
+
useEffect(function () {
|
|
2937
|
+
if (visibleCount < visibleActions.length) {
|
|
2938
|
+
var timer = requestAnimationFrame(function () {
|
|
2939
|
+
setVisibleCount(function (prev) {
|
|
2940
|
+
return Math.min(prev + 20, visibleActions.length);
|
|
2941
|
+
});
|
|
2942
|
+
});
|
|
2943
|
+
return function () {
|
|
2944
|
+
return cancelAnimationFrame(timer);
|
|
2945
|
+
};
|
|
2946
|
+
}
|
|
2947
|
+
}, [visibleCount, visibleActions.length]);
|
|
2948
|
+
useEffect(function () {
|
|
2949
|
+
setVisibleCount(20);
|
|
2950
|
+
}, [scrollLeft, rowData === null || rowData === void 0 ? void 0 : rowData.id]);
|
|
2923
2951
|
var handleTime = function handleTime(e) {
|
|
2924
2952
|
if (!areaRef.current) return;
|
|
2925
2953
|
var rect = areaRef.current.getBoundingClientRect();
|
|
@@ -2983,9 +3011,7 @@ var EditRow = function EditRow(props) {
|
|
|
2983
3011
|
});
|
|
2984
3012
|
}
|
|
2985
3013
|
}
|
|
2986
|
-
},
|
|
2987
|
-
return action.end >= timeStart && action.start <= timeEnd;
|
|
2988
|
-
}).map(function (action) {
|
|
3014
|
+
}, renderActions.map(function (action) {
|
|
2989
3015
|
return /*#__PURE__*/React.createElement(EditAction, _objectSpread2(_objectSpread2({
|
|
2990
3016
|
key: action.id
|
|
2991
3017
|
}, props), {}, {
|
package/dist/index.js
CHANGED
|
@@ -2916,6 +2916,10 @@ var EditRow = function EditRow(props) {
|
|
|
2916
2916
|
setCursor = props.setCursor,
|
|
2917
2917
|
hideCursor = props.hideCursor,
|
|
2918
2918
|
uploadBgMusic = props.uploadBgMusic;
|
|
2919
|
+
var _useState = React.useState(20),
|
|
2920
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2921
|
+
visibleCount = _useState2[0],
|
|
2922
|
+
setVisibleCount = _useState2[1];
|
|
2919
2923
|
var classNames = ['edit-row'];
|
|
2920
2924
|
if (rowData === null || rowData === void 0 ? void 0 : rowData.selected) classNames.push('selected');
|
|
2921
2925
|
var clientWidth = document.documentElement.clientWidth;
|
|
@@ -2929,7 +2933,31 @@ var EditRow = function EditRow(props) {
|
|
|
2929
2933
|
scale: scale,
|
|
2930
2934
|
scaleWidth: scaleWidth
|
|
2931
2935
|
});
|
|
2932
|
-
|
|
2936
|
+
var visibleActions = React.useMemo(function () {
|
|
2937
|
+
return ((rowData === null || rowData === void 0 ? void 0 : rowData.actions) || []).filter(function (action) {
|
|
2938
|
+
return action.end >= timeStart && action.start <= timeEnd;
|
|
2939
|
+
}).sort(function (a, b) {
|
|
2940
|
+
return a.start - b.start;
|
|
2941
|
+
});
|
|
2942
|
+
}, [rowData === null || rowData === void 0 ? void 0 : rowData.actions, timeStart, timeEnd]);
|
|
2943
|
+
var renderActions = React.useMemo(function () {
|
|
2944
|
+
return visibleActions.slice(0, visibleCount);
|
|
2945
|
+
}, [visibleActions, visibleCount]);
|
|
2946
|
+
React.useEffect(function () {
|
|
2947
|
+
if (visibleCount < visibleActions.length) {
|
|
2948
|
+
var timer = requestAnimationFrame(function () {
|
|
2949
|
+
setVisibleCount(function (prev) {
|
|
2950
|
+
return Math.min(prev + 20, visibleActions.length);
|
|
2951
|
+
});
|
|
2952
|
+
});
|
|
2953
|
+
return function () {
|
|
2954
|
+
return cancelAnimationFrame(timer);
|
|
2955
|
+
};
|
|
2956
|
+
}
|
|
2957
|
+
}, [visibleCount, visibleActions.length]);
|
|
2958
|
+
React.useEffect(function () {
|
|
2959
|
+
setVisibleCount(20);
|
|
2960
|
+
}, [scrollLeft, rowData === null || rowData === void 0 ? void 0 : rowData.id]);
|
|
2933
2961
|
var handleTime = function handleTime(e) {
|
|
2934
2962
|
if (!areaRef.current) return;
|
|
2935
2963
|
var rect = areaRef.current.getBoundingClientRect();
|
|
@@ -2993,9 +3021,7 @@ var EditRow = function EditRow(props) {
|
|
|
2993
3021
|
});
|
|
2994
3022
|
}
|
|
2995
3023
|
}
|
|
2996
|
-
},
|
|
2997
|
-
return action.end >= timeStart && action.start <= timeEnd;
|
|
2998
|
-
}).map(function (action) {
|
|
3024
|
+
}, renderActions.map(function (action) {
|
|
2999
3025
|
return /*#__PURE__*/React__default['default'].createElement(EditAction, _objectSpread2(_objectSpread2({
|
|
3000
3026
|
key: action.id
|
|
3001
3027
|
}, props), {}, {
|