sense-react-timeline-editor 1.1.8 → 1.1.9
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { ScrollSync } from 'react-virtualized';
|
|
3
3
|
import { CommonProp } from '../../interface/common_prop';
|
|
4
4
|
import './cursor.less';
|
|
@@ -12,11 +12,29 @@ export declare type CursorProps = CommonProp & {
|
|
|
12
12
|
left?: number;
|
|
13
13
|
time?: number;
|
|
14
14
|
}) => boolean;
|
|
15
|
-
/** 时间轴区域dom ref */
|
|
15
|
+
/** 时间轴区域 dom ref */
|
|
16
16
|
areaRef: React.MutableRefObject<HTMLDivElement>;
|
|
17
|
-
/** 设置scroll left */
|
|
17
|
+
/** 设置 scroll left */
|
|
18
18
|
deltaScrollLeft: (delta: number) => void;
|
|
19
|
-
/** 滚动同步ref(TODO: 该数据用于临时解决scrollLeft拖住时不同步问题) */
|
|
19
|
+
/** 滚动同步 ref(TODO: 该数据用于临时解决 scrollLeft 拖住时不同步问题) */
|
|
20
20
|
scrollSync: React.MutableRefObject<ScrollSync>;
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export interface CursorApi {
|
|
23
|
+
updateLeft: (left: number) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const Cursor: React.ForwardRefExoticComponent<CommonProp & {
|
|
26
|
+
theme?: string;
|
|
27
|
+
/** 距离左侧滚动距离 */
|
|
28
|
+
scrollLeft: number;
|
|
29
|
+
/** 设置光标位置 */
|
|
30
|
+
setCursor: (param: {
|
|
31
|
+
left?: number;
|
|
32
|
+
time?: number;
|
|
33
|
+
}) => boolean;
|
|
34
|
+
/** 时间轴区域 dom ref */
|
|
35
|
+
areaRef: React.MutableRefObject<HTMLDivElement>;
|
|
36
|
+
/** 设置 scroll left */
|
|
37
|
+
deltaScrollLeft: (delta: number) => void;
|
|
38
|
+
/** 滚动同步 ref(TODO: 该数据用于临时解决 scrollLeft 拖住时不同步问题) */
|
|
39
|
+
scrollSync: React.MutableRefObject<ScrollSync>;
|
|
40
|
+
} & React.RefAttributes<CursorApi>>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
2
|
import { OnScrollParams } from 'react-virtualized';
|
|
3
3
|
import { CommonProp } from '../../interface/common_prop';
|
|
4
4
|
import './time_area.less';
|
|
5
|
+
import { CursorApi } from '../cursor/cursor';
|
|
5
6
|
/** 动画时间轴组件参数 */
|
|
6
7
|
export declare type TimeAreaProps = CommonProp & {
|
|
7
8
|
/** 左侧滚动距离 */
|
|
@@ -13,6 +14,7 @@ export declare type TimeAreaProps = CommonProp & {
|
|
|
13
14
|
left?: number;
|
|
14
15
|
time?: number;
|
|
15
16
|
}) => void;
|
|
17
|
+
cursorRef: React.RefObject<CursorApi>;
|
|
16
18
|
};
|
|
17
19
|
/** 动画时间轴组件 */
|
|
18
20
|
export declare const TimeArea: FC<TimeAreaProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TimelineEditor, TimelineState } from '../interface/timeline';
|
|
3
3
|
import './timeline.less';
|
|
4
|
-
export declare const Timeline: React.ForwardRefExoticComponent<TimelineEditor & React.RefAttributes<TimelineState
|
|
4
|
+
export declare const Timeline: React.MemoExoticComponent<React.ForwardRefExoticComponent<TimelineEditor & React.RefAttributes<TimelineState>>>;
|
package/dist/index.esm.js
CHANGED
|
@@ -1973,26 +1973,38 @@ function styleInject(css, ref) {
|
|
|
1973
1973
|
var css_248z = ".timeline-editor-cursor {\n cursor: ew-resize;\n position: absolute;\n top: 32px;\n height: calc(100% - 32px);\n box-sizing: border-box;\n border-left: 1px solid #5297ff;\n border-right: 1px solid #5297ff;\n transform: translateX(-25%) scaleX(0.5);\n transition: transform 0.2s ease-in-out;\n}\n.timeline-editor-cursor-top {\n position: absolute;\n top: 0;\n left: 50%;\n transform: translate(-50%, 0) scaleX(2);\n margin: auto;\n}\n.timeline-editor-cursor-area {\n width: 16px;\n height: 100%;\n cursor: ew-resize;\n position: absolute;\n top: 0;\n left: 50%;\n transform: translateX(-50%);\n}\n.timeline-editor.light .timeline-editor-cursor-top {\n transform: unset;\n position: relative;\n left: 0;\n}\n.timeline-editor.light .timeline-editor-cursor {\n transform: unset;\n display: flex;\n flex-direction: column;\n gap: 2px;\n align-items: center;\n border: none;\n transform: translate(-50%, 0);\n}\n.timeline-editor.light .timeline-editor-cursor-area {\n position: relative;\n border: none;\n width: 10px;\n background-color: transparent;\n transform: unset;\n left: 0;\n transform: translateX(-5px);\n border-right: 1px solid #111;\n}\n";
|
|
1974
1974
|
styleInject(css_248z);
|
|
1975
1975
|
|
|
1976
|
-
var Cursor = function
|
|
1976
|
+
var Cursor = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
1977
1977
|
var _document$querySelect;
|
|
1978
|
-
var theme =
|
|
1979
|
-
disableDrag =
|
|
1980
|
-
cursorTime =
|
|
1981
|
-
setCursor =
|
|
1982
|
-
startLeft =
|
|
1983
|
-
timelineWidth =
|
|
1984
|
-
scaleWidth =
|
|
1985
|
-
scale =
|
|
1986
|
-
scrollLeft =
|
|
1987
|
-
scrollSync =
|
|
1988
|
-
areaRef =
|
|
1989
|
-
maxScaleCount =
|
|
1990
|
-
deltaScrollLeft =
|
|
1991
|
-
onCursorDragStart =
|
|
1992
|
-
onCursorDrag =
|
|
1993
|
-
onCursorDragEnd =
|
|
1978
|
+
var theme = props.theme,
|
|
1979
|
+
disableDrag = props.disableDrag,
|
|
1980
|
+
cursorTime = props.cursorTime,
|
|
1981
|
+
setCursor = props.setCursor,
|
|
1982
|
+
startLeft = props.startLeft,
|
|
1983
|
+
timelineWidth = props.timelineWidth,
|
|
1984
|
+
scaleWidth = props.scaleWidth,
|
|
1985
|
+
scale = props.scale,
|
|
1986
|
+
scrollLeft = props.scrollLeft,
|
|
1987
|
+
scrollSync = props.scrollSync,
|
|
1988
|
+
areaRef = props.areaRef,
|
|
1989
|
+
maxScaleCount = props.maxScaleCount,
|
|
1990
|
+
deltaScrollLeft = props.deltaScrollLeft,
|
|
1991
|
+
onCursorDragStart = props.onCursorDragStart,
|
|
1992
|
+
onCursorDrag = props.onCursorDrag,
|
|
1993
|
+
onCursorDragEnd = props.onCursorDragEnd;
|
|
1994
|
+
console.log('Cursor cursorTime', cursorTime);
|
|
1994
1995
|
var rowRnd = useRef();
|
|
1995
1996
|
var draggingLeft = useRef();
|
|
1997
|
+
useImperativeHandle(ref, function () {
|
|
1998
|
+
return {
|
|
1999
|
+
updateLeft: function updateLeft(cursorTime) {
|
|
2000
|
+
rowRnd.current.updateLeft(parserTimeToPixel(cursorTime, {
|
|
2001
|
+
startLeft: startLeft,
|
|
2002
|
+
scaleWidth: scaleWidth,
|
|
2003
|
+
scale: scale
|
|
2004
|
+
}) - scrollLeft);
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
});
|
|
1996
2008
|
useThrottleEffect(function () {
|
|
1997
2009
|
if (typeof draggingLeft.current === 'undefined') {
|
|
1998
2010
|
// 非dragging时,根据穿参更新cursor刻度(防抖)
|
|
@@ -2005,7 +2017,7 @@ var Cursor = function Cursor(_ref) {
|
|
|
2005
2017
|
}, [cursorTime, startLeft, scaleWidth, scale, scrollLeft], {
|
|
2006
2018
|
wait: 10
|
|
2007
2019
|
});
|
|
2008
|
-
var clientHeight = ((_document$querySelect = document.querySelector(
|
|
2020
|
+
var clientHeight = ((_document$querySelect = document.querySelector('#time-editor-container')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.clientHeight) || 0;
|
|
2009
2021
|
return /*#__PURE__*/React.createElement(RowDnd, {
|
|
2010
2022
|
top: theme === 'light' ? 26 : 0,
|
|
2011
2023
|
start: startLeft,
|
|
@@ -2040,8 +2052,8 @@ var Cursor = function Cursor(_ref) {
|
|
|
2040
2052
|
onCursorDragEnd && onCursorDragEnd(time);
|
|
2041
2053
|
draggingLeft.current = undefined;
|
|
2042
2054
|
},
|
|
2043
|
-
onDrag: function onDrag(
|
|
2044
|
-
var left =
|
|
2055
|
+
onDrag: function onDrag(_ref) {
|
|
2056
|
+
var left = _ref.left;
|
|
2045
2057
|
var scroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
2046
2058
|
var scrollLeft = scrollSync.current.state.scrollLeft;
|
|
2047
2059
|
if (!scroll || scrollLeft === 0) {
|
|
@@ -2080,12 +2092,12 @@ var Cursor = function Cursor(_ref) {
|
|
|
2080
2092
|
})), /*#__PURE__*/React.createElement("div", {
|
|
2081
2093
|
className: prefix('cursor-area')
|
|
2082
2094
|
})));
|
|
2083
|
-
};
|
|
2095
|
+
});
|
|
2084
2096
|
|
|
2085
2097
|
var css_248z$1 = ".timeline-editor .ant-upload-wrapper .ant-upload-drag {\n border: none !important;\n background: none !important;\n}\n.timeline-editor:hover .timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar {\n height: 4px;\n}\n.timeline-editor-edit-area {\n flex: 1 1 auto;\n margin-top: 10px;\n overflow: hidden;\n position: relative;\n}\n.timeline-editor-edit-area.no-flex {\n flex: 0 0 auto;\n}\n.timeline-editor-edit-area.overflow-hidden {\n overflow: hidden;\n}\n.timeline-editor-edit-area.overflow-hidden .ReactVirtualized__Grid {\n overflow: hidden !important;\n height: initial !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid {\n outline: none !important;\n overflow: overlay !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar {\n width: 0;\n height: 0;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar-track {\n background-color: transparent !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar-thumb {\n background: #666;\n border-radius: 16px;\n}\n.timeline-editor-selection-box {\n position: fixed;\n border: 2px solid #1890ff;\n background-color: rgba(24, 144, 255, 0.1);\n pointer-events: none;\n z-index: 9999;\n box-shadow: 0 0 8px rgba(24, 144, 255, 0.3);\n left: -100px;\n}\n";
|
|
2086
2098
|
styleInject(css_248z$1);
|
|
2087
2099
|
|
|
2088
|
-
var css_248z$2 = ".timeline-editor-action {\n position: absolute;\n left: 0;\n top: 0;\n background-color: #c6cbd2;\n display: flex;\n align-items: center;\n}\n.timeline-editor-action[data-action-drag=\"true\"] {\n box-shadow: 0px 8px 8px rgba(77, 54, 41, 0.08);\n border-radius: 34px;\n cursor: pointer;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch,\n.timeline-editor-action .timeline-editor-action-right-stretch {\n position: absolute;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch {\n left: -3px;\n}\n.timeline-editor-action .timeline-editor-action-right-stretch {\n right: -3px;\n transform: rotate(180deg);\n}\n";
|
|
2100
|
+
var css_248z$2 = ".timeline-editor-action {\n position: absolute;\n left: 0;\n top: 0;\n background-color: #c6cbd2;\n display: flex;\n align-items: center;\n}\n.timeline-editor-action[data-action-drag=\"true\"] {\n box-shadow: 0px 8px 8px rgba(77, 54, 41, 0.08);\n border-radius: 34px;\n cursor: pointer;\n z-index: 100;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch,\n.timeline-editor-action .timeline-editor-action-right-stretch {\n position: absolute;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch {\n left: -3px;\n}\n.timeline-editor-action .timeline-editor-action-right-stretch {\n right: -3px;\n transform: rotate(180deg);\n}\n";
|
|
2089
2101
|
styleInject(css_248z$2);
|
|
2090
2102
|
|
|
2091
2103
|
var stretchIcon = "data:image/svg+xml,%3Csvg%20width%3D%227%22%20height%3D%2216%22%20viewBox%3D%220%200%207%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M7%2015C7%2015.5523%206.55228%2016%206%2016L1%2016C0.447715%2016%201.06779e-08%2015.5523%202.38498e-08%2015L3.57746e-07%201C3.70918e-07%200.447715%200.447716%20-1.5627e-07%201%20-1.43099e-07L6%209.29825e-07C6.55229%209.42996e-07%207%200.447716%207%201L7%2015Z%22%20fill%3D%22%23226EFF%22%2F%3E%3Cpath%20d%3D%22M2%204L2%2012%22%20stroke%3D%22white%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M4%2012.25L5.5%208L4%203.75%22%20fill%3D%22white%22%2F%3E%3Cpath%20d%3D%22M4%2012.25L5.5%208L4%203.75L4%2012.25Z%22%20stroke%3D%22white%22%20stroke-width%3D%220.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E";
|
|
@@ -2603,6 +2615,7 @@ var EditActionO = function EditActionO(_ref) {
|
|
|
2603
2615
|
sourceRowItem.actions = sourceRowItem.actions.filter(function (item) {
|
|
2604
2616
|
return item.id !== id;
|
|
2605
2617
|
});
|
|
2618
|
+
actionItem.order = targetRowItem.order;
|
|
2606
2619
|
// 添加到目标row
|
|
2607
2620
|
targetRowItem.actions.push(actionItem);
|
|
2608
2621
|
console.log('Target row actions after:', targetRowItem.actions.length);
|
|
@@ -2913,12 +2926,12 @@ var EditRow = function EditRow(props) {
|
|
|
2913
2926
|
var classNames = ['edit-row'];
|
|
2914
2927
|
if (rowData === null || rowData === void 0 ? void 0 : rowData.selected) classNames.push('selected');
|
|
2915
2928
|
var clientWidth = document.documentElement.clientWidth;
|
|
2916
|
-
var timeStart = parserPixelToTime(scrollLeft, {
|
|
2929
|
+
var timeStart = parserPixelToTime(scrollLeft - 400, {
|
|
2917
2930
|
startLeft: startLeft,
|
|
2918
2931
|
scale: scale,
|
|
2919
2932
|
scaleWidth: scaleWidth
|
|
2920
2933
|
});
|
|
2921
|
-
var timeEnd = parserPixelToTime(scrollLeft + clientWidth +
|
|
2934
|
+
var timeEnd = parserPixelToTime(scrollLeft + clientWidth + 400, {
|
|
2922
2935
|
startLeft: startLeft,
|
|
2923
2936
|
scale: scale,
|
|
2924
2937
|
scaleWidth: scaleWidth
|
|
@@ -2947,8 +2960,8 @@ var EditRow = function EditRow(props) {
|
|
|
2947
2960
|
}, [visibleCount, visibleActions.length]);
|
|
2948
2961
|
useEffect(function () {
|
|
2949
2962
|
setVisibleCount(20);
|
|
2950
|
-
}, [
|
|
2951
|
-
var handleTime = function
|
|
2963
|
+
}, [rowData === null || rowData === void 0 ? void 0 : rowData.id]);
|
|
2964
|
+
var handleTime = useCallback(function (e) {
|
|
2952
2965
|
if (!areaRef.current) return;
|
|
2953
2966
|
var rect = areaRef.current.getBoundingClientRect();
|
|
2954
2967
|
var position = e.clientX - rect.x;
|
|
@@ -2959,7 +2972,7 @@ var EditRow = function EditRow(props) {
|
|
|
2959
2972
|
scaleWidth: scaleWidth
|
|
2960
2973
|
});
|
|
2961
2974
|
return time;
|
|
2962
|
-
};
|
|
2975
|
+
}, [areaRef, scrollLeft, startLeft, scale, scaleWidth]);
|
|
2963
2976
|
return /*#__PURE__*/React.createElement("div", {
|
|
2964
2977
|
className: "".concat(prefix.apply(void 0, classNames), " ").concat(((rowData === null || rowData === void 0 ? void 0 : rowData.classNames) || []).join(' ')),
|
|
2965
2978
|
style: style,
|
|
@@ -3399,9 +3412,9 @@ var useRowDrag = function useRowDrag(options) {
|
|
|
3399
3412
|
if (up === 0) {
|
|
3400
3413
|
top = 0;
|
|
3401
3414
|
} else if (up === 1) {
|
|
3402
|
-
top =
|
|
3415
|
+
top = 35;
|
|
3403
3416
|
} else if (up === -1) {
|
|
3404
|
-
top =
|
|
3417
|
+
top = -35;
|
|
3405
3418
|
}
|
|
3406
3419
|
// 如果没有初始位置数据,说明不是有效的多选拖拽
|
|
3407
3420
|
if (!setEditorData || initialPositions.size === 0) {
|
|
@@ -3670,7 +3683,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3670
3683
|
return /*#__PURE__*/function () {
|
|
3671
3684
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(info) {
|
|
3672
3685
|
var _info$file$response, _info$file;
|
|
3673
|
-
var hasDefault, totalDuration, _newAction, uid, duration, newAction;
|
|
3686
|
+
var maxSize, hasDefault, totalDuration, _newAction, uid, duration, newAction;
|
|
3674
3687
|
return _regenerator().w(function (_context) {
|
|
3675
3688
|
while (1) switch (_context.n) {
|
|
3676
3689
|
case 0:
|
|
@@ -3681,16 +3694,23 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3681
3694
|
}
|
|
3682
3695
|
return _context.a(2);
|
|
3683
3696
|
case 1:
|
|
3684
|
-
|
|
3697
|
+
maxSize = 100 * 1024 * 1024;
|
|
3698
|
+
if (!(info.file.size > maxSize)) {
|
|
3685
3699
|
_context.n = 2;
|
|
3686
3700
|
break;
|
|
3687
3701
|
}
|
|
3688
3702
|
return _context.a(2, false);
|
|
3689
3703
|
case 2:
|
|
3690
|
-
if (!(info.file.
|
|
3704
|
+
if (!(info.file.type !== 'audio/mp3' && info.file.type !== 'audio/wav' && info.file.type !== 'audio/mpeg')) {
|
|
3691
3705
|
_context.n = 3;
|
|
3692
3706
|
break;
|
|
3693
3707
|
}
|
|
3708
|
+
return _context.a(2, false);
|
|
3709
|
+
case 3:
|
|
3710
|
+
if (!(info.file.status === 'error')) {
|
|
3711
|
+
_context.n = 4;
|
|
3712
|
+
break;
|
|
3713
|
+
}
|
|
3694
3714
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [{
|
|
3695
3715
|
id: info.file.uid,
|
|
3696
3716
|
isUploading: false,
|
|
@@ -3702,9 +3722,9 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3702
3722
|
uid: info.file.uid
|
|
3703
3723
|
}]);
|
|
3704
3724
|
return _context.a(2);
|
|
3705
|
-
case
|
|
3725
|
+
case 4:
|
|
3706
3726
|
if (info.file.response) {
|
|
3707
|
-
_context.n =
|
|
3727
|
+
_context.n = 5;
|
|
3708
3728
|
break;
|
|
3709
3729
|
}
|
|
3710
3730
|
hasDefault = row.actions.some(function (action) {
|
|
@@ -3731,11 +3751,11 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3731
3751
|
};
|
|
3732
3752
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [_newAction]);
|
|
3733
3753
|
return _context.a(2);
|
|
3734
|
-
case
|
|
3754
|
+
case 5:
|
|
3735
3755
|
uid = info.file.uid;
|
|
3736
|
-
_context.n =
|
|
3756
|
+
_context.n = 6;
|
|
3737
3757
|
return getAudioDuration(info.file.response.url);
|
|
3738
|
-
case
|
|
3758
|
+
case 6:
|
|
3739
3759
|
duration = _context.v;
|
|
3740
3760
|
newAction = {
|
|
3741
3761
|
id: ((_info$file$response = info.file.response) === null || _info$file$response === void 0 ? void 0 : _info$file$response.id) || uid,
|
|
@@ -3750,7 +3770,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3750
3770
|
uid: (_info$file = info.file) === null || _info$file === void 0 ? void 0 : _info$file.uid
|
|
3751
3771
|
};
|
|
3752
3772
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
|
|
3753
|
-
case
|
|
3773
|
+
case 7:
|
|
3754
3774
|
return _context.a(2);
|
|
3755
3775
|
}
|
|
3756
3776
|
}, _callee);
|
|
@@ -4087,7 +4107,6 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4087
4107
|
}
|
|
4088
4108
|
}
|
|
4089
4109
|
heightRef.current = height;
|
|
4090
|
-
console.log('Math.max(scaleCount * scaleWidth + startLeft, width)', Math.max(scaleCount * scaleWidth + startLeft, width), ', width', width);
|
|
4091
4110
|
return /*#__PURE__*/React.createElement(Grid, {
|
|
4092
4111
|
columnCount: 1,
|
|
4093
4112
|
rowCount: heights.length,
|
|
@@ -4175,7 +4194,8 @@ var TimeArea = function TimeArea(_ref) {
|
|
|
4175
4194
|
scrollLeft = _ref.scrollLeft,
|
|
4176
4195
|
onClickTimeArea = _ref.onClickTimeArea,
|
|
4177
4196
|
getScaleRender = _ref.getScaleRender,
|
|
4178
|
-
timelineWidth = _ref.timelineWidth
|
|
4197
|
+
timelineWidth = _ref.timelineWidth,
|
|
4198
|
+
cursorRef = _ref.cursorRef;
|
|
4179
4199
|
var gridRef = useRef();
|
|
4180
4200
|
/** 是否显示细分刻度 */
|
|
4181
4201
|
var showUnit = scaleSplitCount > 0;
|
|
@@ -4252,7 +4272,7 @@ var TimeArea = function TimeArea(_ref) {
|
|
|
4252
4272
|
scaleWidth: scaleWidth
|
|
4253
4273
|
});
|
|
4254
4274
|
var result = onClickTimeArea && onClickTimeArea(time, e);
|
|
4255
|
-
if (result === false) return; // 返回false时阻止设置时间
|
|
4275
|
+
if (result === false) return; // 返回 false 时阻止设置时间
|
|
4256
4276
|
setCursor({
|
|
4257
4277
|
time: time
|
|
4258
4278
|
});
|
|
@@ -4446,7 +4466,7 @@ var DragLineController = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function (pro
|
|
|
4446
4466
|
}));
|
|
4447
4467
|
DragLineController.displayName = "DragLineController";
|
|
4448
4468
|
|
|
4449
|
-
var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
4469
|
+
var Timeline = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
4450
4470
|
var checkedProps = checkProps(props);
|
|
4451
4471
|
var style = props.style,
|
|
4452
4472
|
className = props.className,
|
|
@@ -4475,6 +4495,7 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4475
4495
|
var areaRef = useRef();
|
|
4476
4496
|
var scrollSync = useRef();
|
|
4477
4497
|
var containerRef = useRef();
|
|
4498
|
+
var cursorRef = useRef(null);
|
|
4478
4499
|
console.log(' Timeline mounted = ', areaRef);
|
|
4479
4500
|
// 编辑器数据
|
|
4480
4501
|
var _useState = useState(data),
|
|
@@ -4527,11 +4548,11 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4527
4548
|
scrollTop: scrollTop
|
|
4528
4549
|
});
|
|
4529
4550
|
}, [scrollTop]);
|
|
4530
|
-
/** 动态设置scale count */
|
|
4531
|
-
var handleSetScaleCount = function
|
|
4551
|
+
/** 动态设置 scale count */
|
|
4552
|
+
var handleSetScaleCount = useCallback(function (value) {
|
|
4532
4553
|
var data = Math.min(maxScaleCount, Math.max(minScaleCount, value));
|
|
4533
4554
|
setScaleCount(data);
|
|
4534
|
-
};
|
|
4555
|
+
}, [maxScaleCount, minScaleCount]);
|
|
4535
4556
|
/** 处理主动数据变化 */
|
|
4536
4557
|
var handleEditorDataChange = function handleEditorDataChange(updatedData) {
|
|
4537
4558
|
var result = onChange === null || onChange === void 0 ? void 0 : onChange(updatedData);
|
|
@@ -4542,7 +4563,7 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4542
4563
|
}
|
|
4543
4564
|
};
|
|
4544
4565
|
/** 处理光标 */
|
|
4545
|
-
var handleSetCursor = function
|
|
4566
|
+
var handleSetCursor = useCallback(function (param) {
|
|
4546
4567
|
var left = param.left,
|
|
4547
4568
|
time = param.time,
|
|
4548
4569
|
_param$updateTime = param.updateTime,
|
|
@@ -4567,16 +4588,16 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4567
4588
|
}
|
|
4568
4589
|
result && setCursorTime(time);
|
|
4569
4590
|
return result;
|
|
4570
|
-
};
|
|
4571
|
-
/** 设置scrollLeft */
|
|
4572
|
-
var handleDeltaScrollLeft = function
|
|
4591
|
+
}, [startLeft, scale, scaleWidth, autoReRender]);
|
|
4592
|
+
/** 设置 scrollLeft */
|
|
4593
|
+
var handleDeltaScrollLeft = useCallback(function (delta) {
|
|
4573
4594
|
// 当超过最大距离时,禁止自动滚动
|
|
4574
4595
|
var data = scrollSync.current.state.scrollLeft + delta;
|
|
4575
4596
|
if (data > scaleCount * (scaleWidth - 1) + startLeft - width) return;
|
|
4576
4597
|
scrollSync.current && scrollSync.current.setState({
|
|
4577
4598
|
scrollLeft: Math.max(scrollSync.current.state.scrollLeft + delta, 0)
|
|
4578
4599
|
});
|
|
4579
|
-
};
|
|
4600
|
+
}, [scaleCount, scaleWidth, startLeft, width]);
|
|
4580
4601
|
var handleInitDragLine = useCallback(function (data) {
|
|
4581
4602
|
var _checkedProps$onActio, _checkedProps$onActio2, _dragLineControllerRe;
|
|
4582
4603
|
(_checkedProps$onActio = checkedProps.onActionMoveStart) === null || _checkedProps$onActio === void 0 ? void 0 : _checkedProps$onActio.call(checkedProps, data);
|
|
@@ -4595,6 +4616,10 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4595
4616
|
(_checkedProps$onActio6 = checkedProps.onActionResizeEnd) === null || _checkedProps$onActio6 === void 0 ? void 0 : _checkedProps$onActio6.call(checkedProps, data);
|
|
4596
4617
|
(_dragLineControllerRe3 = dragLineControllerRef.current) === null || _dragLineControllerRe3 === void 0 ? void 0 : _dragLineControllerRe3.disposeDragLine();
|
|
4597
4618
|
}, [checkedProps]);
|
|
4619
|
+
/** 处理滚动回调 */
|
|
4620
|
+
var onScroll = useCallback(function (params) {
|
|
4621
|
+
onScrollVertical && onScrollVertical(params);
|
|
4622
|
+
}, [onScrollVertical]);
|
|
4598
4623
|
// 处理运行器相关数据
|
|
4599
4624
|
useEffect(function () {
|
|
4600
4625
|
var handleTime = function handleTime(_ref) {
|
|
@@ -4667,7 +4692,7 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4667
4692
|
}
|
|
4668
4693
|
};
|
|
4669
4694
|
});
|
|
4670
|
-
var onClickTimeline = function
|
|
4695
|
+
var onClickTimeline = useCallback(function (e) {
|
|
4671
4696
|
var _e$target;
|
|
4672
4697
|
if (!domRef.current) return;
|
|
4673
4698
|
var rect = domRef.current.getBoundingClientRect();
|
|
@@ -4684,7 +4709,7 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4684
4709
|
handleSetCursor({
|
|
4685
4710
|
time: time
|
|
4686
4711
|
});
|
|
4687
|
-
};
|
|
4712
|
+
}, [startLeft, scale, scaleWidth, hideCursor, handleSetCursor]);
|
|
4688
4713
|
// 监听timeline区域宽度变化
|
|
4689
4714
|
useEffect(function () {
|
|
4690
4715
|
if (areaRef.current) {
|
|
@@ -4731,7 +4756,8 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4731
4756
|
scaleCount: scaleCount,
|
|
4732
4757
|
setScaleCount: handleSetScaleCount,
|
|
4733
4758
|
onScroll: _onScroll,
|
|
4734
|
-
scrollLeft: scrollLeft
|
|
4759
|
+
scrollLeft: scrollLeft,
|
|
4760
|
+
cursorRef: cursorRef
|
|
4735
4761
|
})), areaCount === 1 ? (/*#__PURE__*/React.createElement(EditArea, _objectSpread2(_objectSpread2({}, checkedProps), {}, {
|
|
4736
4762
|
timelineWidth: width,
|
|
4737
4763
|
ref: function ref(_ref3) {
|
|
@@ -4819,12 +4845,10 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4819
4845
|
onActionResizing: handleUpdateDragLine,
|
|
4820
4846
|
onActionMoveEnd: handleDisposeDragLine,
|
|
4821
4847
|
onActionResizeEnd: handleDisposeDragLine,
|
|
4822
|
-
onScroll:
|
|
4823
|
-
_onScroll(params);
|
|
4824
|
-
onScrollVertical && onScrollVertical(params);
|
|
4825
|
-
}
|
|
4848
|
+
onScroll: _onScroll
|
|
4826
4849
|
}));
|
|
4827
4850
|
}))) : null, !hideCursor && (/*#__PURE__*/React.createElement(Cursor, _objectSpread2(_objectSpread2({}, checkedProps), {}, {
|
|
4851
|
+
ref: cursorRef,
|
|
4828
4852
|
timelineWidth: width,
|
|
4829
4853
|
disableDrag: isPlaying,
|
|
4830
4854
|
scrollLeft: scrollLeft,
|
|
@@ -4849,6 +4873,6 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4849
4873
|
getAssistDragLineActionIds: checkedProps.getAssistDragLineActionIds
|
|
4850
4874
|
}));
|
|
4851
4875
|
}));
|
|
4852
|
-
});
|
|
4876
|
+
}));
|
|
4853
4877
|
|
|
4854
4878
|
export { Timeline, TimelineEngine };
|
package/dist/index.js
CHANGED
|
@@ -1983,26 +1983,38 @@ function styleInject(css, ref) {
|
|
|
1983
1983
|
var css_248z = ".timeline-editor-cursor {\n cursor: ew-resize;\n position: absolute;\n top: 32px;\n height: calc(100% - 32px);\n box-sizing: border-box;\n border-left: 1px solid #5297ff;\n border-right: 1px solid #5297ff;\n transform: translateX(-25%) scaleX(0.5);\n transition: transform 0.2s ease-in-out;\n}\n.timeline-editor-cursor-top {\n position: absolute;\n top: 0;\n left: 50%;\n transform: translate(-50%, 0) scaleX(2);\n margin: auto;\n}\n.timeline-editor-cursor-area {\n width: 16px;\n height: 100%;\n cursor: ew-resize;\n position: absolute;\n top: 0;\n left: 50%;\n transform: translateX(-50%);\n}\n.timeline-editor.light .timeline-editor-cursor-top {\n transform: unset;\n position: relative;\n left: 0;\n}\n.timeline-editor.light .timeline-editor-cursor {\n transform: unset;\n display: flex;\n flex-direction: column;\n gap: 2px;\n align-items: center;\n border: none;\n transform: translate(-50%, 0);\n}\n.timeline-editor.light .timeline-editor-cursor-area {\n position: relative;\n border: none;\n width: 10px;\n background-color: transparent;\n transform: unset;\n left: 0;\n transform: translateX(-5px);\n border-right: 1px solid #111;\n}\n";
|
|
1984
1984
|
styleInject(css_248z);
|
|
1985
1985
|
|
|
1986
|
-
var Cursor = function
|
|
1986
|
+
var Cursor = /*#__PURE__*/React__default['default'].forwardRef(function (props, ref) {
|
|
1987
1987
|
var _document$querySelect;
|
|
1988
|
-
var theme =
|
|
1989
|
-
disableDrag =
|
|
1990
|
-
cursorTime =
|
|
1991
|
-
setCursor =
|
|
1992
|
-
startLeft =
|
|
1993
|
-
timelineWidth =
|
|
1994
|
-
scaleWidth =
|
|
1995
|
-
scale =
|
|
1996
|
-
scrollLeft =
|
|
1997
|
-
scrollSync =
|
|
1998
|
-
areaRef =
|
|
1999
|
-
maxScaleCount =
|
|
2000
|
-
deltaScrollLeft =
|
|
2001
|
-
onCursorDragStart =
|
|
2002
|
-
onCursorDrag =
|
|
2003
|
-
onCursorDragEnd =
|
|
1988
|
+
var theme = props.theme,
|
|
1989
|
+
disableDrag = props.disableDrag,
|
|
1990
|
+
cursorTime = props.cursorTime,
|
|
1991
|
+
setCursor = props.setCursor,
|
|
1992
|
+
startLeft = props.startLeft,
|
|
1993
|
+
timelineWidth = props.timelineWidth,
|
|
1994
|
+
scaleWidth = props.scaleWidth,
|
|
1995
|
+
scale = props.scale,
|
|
1996
|
+
scrollLeft = props.scrollLeft,
|
|
1997
|
+
scrollSync = props.scrollSync,
|
|
1998
|
+
areaRef = props.areaRef,
|
|
1999
|
+
maxScaleCount = props.maxScaleCount,
|
|
2000
|
+
deltaScrollLeft = props.deltaScrollLeft,
|
|
2001
|
+
onCursorDragStart = props.onCursorDragStart,
|
|
2002
|
+
onCursorDrag = props.onCursorDrag,
|
|
2003
|
+
onCursorDragEnd = props.onCursorDragEnd;
|
|
2004
|
+
console.log('Cursor cursorTime', cursorTime);
|
|
2004
2005
|
var rowRnd = React.useRef();
|
|
2005
2006
|
var draggingLeft = React.useRef();
|
|
2007
|
+
React.useImperativeHandle(ref, function () {
|
|
2008
|
+
return {
|
|
2009
|
+
updateLeft: function updateLeft(cursorTime) {
|
|
2010
|
+
rowRnd.current.updateLeft(parserTimeToPixel(cursorTime, {
|
|
2011
|
+
startLeft: startLeft,
|
|
2012
|
+
scaleWidth: scaleWidth,
|
|
2013
|
+
scale: scale
|
|
2014
|
+
}) - scrollLeft);
|
|
2015
|
+
}
|
|
2016
|
+
};
|
|
2017
|
+
});
|
|
2006
2018
|
ahooks.useThrottleEffect(function () {
|
|
2007
2019
|
if (typeof draggingLeft.current === 'undefined') {
|
|
2008
2020
|
// 非dragging时,根据穿参更新cursor刻度(防抖)
|
|
@@ -2015,7 +2027,7 @@ var Cursor = function Cursor(_ref) {
|
|
|
2015
2027
|
}, [cursorTime, startLeft, scaleWidth, scale, scrollLeft], {
|
|
2016
2028
|
wait: 10
|
|
2017
2029
|
});
|
|
2018
|
-
var clientHeight = ((_document$querySelect = document.querySelector(
|
|
2030
|
+
var clientHeight = ((_document$querySelect = document.querySelector('#time-editor-container')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.clientHeight) || 0;
|
|
2019
2031
|
return /*#__PURE__*/React__default['default'].createElement(RowDnd, {
|
|
2020
2032
|
top: theme === 'light' ? 26 : 0,
|
|
2021
2033
|
start: startLeft,
|
|
@@ -2050,8 +2062,8 @@ var Cursor = function Cursor(_ref) {
|
|
|
2050
2062
|
onCursorDragEnd && onCursorDragEnd(time);
|
|
2051
2063
|
draggingLeft.current = undefined;
|
|
2052
2064
|
},
|
|
2053
|
-
onDrag: function onDrag(
|
|
2054
|
-
var left =
|
|
2065
|
+
onDrag: function onDrag(_ref) {
|
|
2066
|
+
var left = _ref.left;
|
|
2055
2067
|
var scroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
2056
2068
|
var scrollLeft = scrollSync.current.state.scrollLeft;
|
|
2057
2069
|
if (!scroll || scrollLeft === 0) {
|
|
@@ -2090,12 +2102,12 @@ var Cursor = function Cursor(_ref) {
|
|
|
2090
2102
|
})), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2091
2103
|
className: prefix('cursor-area')
|
|
2092
2104
|
})));
|
|
2093
|
-
};
|
|
2105
|
+
});
|
|
2094
2106
|
|
|
2095
2107
|
var css_248z$1 = ".timeline-editor .ant-upload-wrapper .ant-upload-drag {\n border: none !important;\n background: none !important;\n}\n.timeline-editor:hover .timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar {\n height: 4px;\n}\n.timeline-editor-edit-area {\n flex: 1 1 auto;\n margin-top: 10px;\n overflow: hidden;\n position: relative;\n}\n.timeline-editor-edit-area.no-flex {\n flex: 0 0 auto;\n}\n.timeline-editor-edit-area.overflow-hidden {\n overflow: hidden;\n}\n.timeline-editor-edit-area.overflow-hidden .ReactVirtualized__Grid {\n overflow: hidden !important;\n height: initial !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid {\n outline: none !important;\n overflow: overlay !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar {\n width: 0;\n height: 0;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar-track {\n background-color: transparent !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar-thumb {\n background: #666;\n border-radius: 16px;\n}\n.timeline-editor-selection-box {\n position: fixed;\n border: 2px solid #1890ff;\n background-color: rgba(24, 144, 255, 0.1);\n pointer-events: none;\n z-index: 9999;\n box-shadow: 0 0 8px rgba(24, 144, 255, 0.3);\n left: -100px;\n}\n";
|
|
2096
2108
|
styleInject(css_248z$1);
|
|
2097
2109
|
|
|
2098
|
-
var css_248z$2 = ".timeline-editor-action {\n position: absolute;\n left: 0;\n top: 0;\n background-color: #c6cbd2;\n display: flex;\n align-items: center;\n}\n.timeline-editor-action[data-action-drag=\"true\"] {\n box-shadow: 0px 8px 8px rgba(77, 54, 41, 0.08);\n border-radius: 34px;\n cursor: pointer;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch,\n.timeline-editor-action .timeline-editor-action-right-stretch {\n position: absolute;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch {\n left: -3px;\n}\n.timeline-editor-action .timeline-editor-action-right-stretch {\n right: -3px;\n transform: rotate(180deg);\n}\n";
|
|
2110
|
+
var css_248z$2 = ".timeline-editor-action {\n position: absolute;\n left: 0;\n top: 0;\n background-color: #c6cbd2;\n display: flex;\n align-items: center;\n}\n.timeline-editor-action[data-action-drag=\"true\"] {\n box-shadow: 0px 8px 8px rgba(77, 54, 41, 0.08);\n border-radius: 34px;\n cursor: pointer;\n z-index: 100;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch,\n.timeline-editor-action .timeline-editor-action-right-stretch {\n position: absolute;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch {\n left: -3px;\n}\n.timeline-editor-action .timeline-editor-action-right-stretch {\n right: -3px;\n transform: rotate(180deg);\n}\n";
|
|
2099
2111
|
styleInject(css_248z$2);
|
|
2100
2112
|
|
|
2101
2113
|
var stretchIcon = "data:image/svg+xml,%3Csvg%20width%3D%227%22%20height%3D%2216%22%20viewBox%3D%220%200%207%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M7%2015C7%2015.5523%206.55228%2016%206%2016L1%2016C0.447715%2016%201.06779e-08%2015.5523%202.38498e-08%2015L3.57746e-07%201C3.70918e-07%200.447715%200.447716%20-1.5627e-07%201%20-1.43099e-07L6%209.29825e-07C6.55229%209.42996e-07%207%200.447716%207%201L7%2015Z%22%20fill%3D%22%23226EFF%22%2F%3E%3Cpath%20d%3D%22M2%204L2%2012%22%20stroke%3D%22white%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M4%2012.25L5.5%208L4%203.75%22%20fill%3D%22white%22%2F%3E%3Cpath%20d%3D%22M4%2012.25L5.5%208L4%203.75L4%2012.25Z%22%20stroke%3D%22white%22%20stroke-width%3D%220.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E";
|
|
@@ -2613,6 +2625,7 @@ var EditActionO = function EditActionO(_ref) {
|
|
|
2613
2625
|
sourceRowItem.actions = sourceRowItem.actions.filter(function (item) {
|
|
2614
2626
|
return item.id !== id;
|
|
2615
2627
|
});
|
|
2628
|
+
actionItem.order = targetRowItem.order;
|
|
2616
2629
|
// 添加到目标row
|
|
2617
2630
|
targetRowItem.actions.push(actionItem);
|
|
2618
2631
|
console.log('Target row actions after:', targetRowItem.actions.length);
|
|
@@ -2923,12 +2936,12 @@ var EditRow = function EditRow(props) {
|
|
|
2923
2936
|
var classNames = ['edit-row'];
|
|
2924
2937
|
if (rowData === null || rowData === void 0 ? void 0 : rowData.selected) classNames.push('selected');
|
|
2925
2938
|
var clientWidth = document.documentElement.clientWidth;
|
|
2926
|
-
var timeStart = parserPixelToTime(scrollLeft, {
|
|
2939
|
+
var timeStart = parserPixelToTime(scrollLeft - 400, {
|
|
2927
2940
|
startLeft: startLeft,
|
|
2928
2941
|
scale: scale,
|
|
2929
2942
|
scaleWidth: scaleWidth
|
|
2930
2943
|
});
|
|
2931
|
-
var timeEnd = parserPixelToTime(scrollLeft + clientWidth +
|
|
2944
|
+
var timeEnd = parserPixelToTime(scrollLeft + clientWidth + 400, {
|
|
2932
2945
|
startLeft: startLeft,
|
|
2933
2946
|
scale: scale,
|
|
2934
2947
|
scaleWidth: scaleWidth
|
|
@@ -2957,8 +2970,8 @@ var EditRow = function EditRow(props) {
|
|
|
2957
2970
|
}, [visibleCount, visibleActions.length]);
|
|
2958
2971
|
React.useEffect(function () {
|
|
2959
2972
|
setVisibleCount(20);
|
|
2960
|
-
}, [
|
|
2961
|
-
var handleTime = function
|
|
2973
|
+
}, [rowData === null || rowData === void 0 ? void 0 : rowData.id]);
|
|
2974
|
+
var handleTime = React.useCallback(function (e) {
|
|
2962
2975
|
if (!areaRef.current) return;
|
|
2963
2976
|
var rect = areaRef.current.getBoundingClientRect();
|
|
2964
2977
|
var position = e.clientX - rect.x;
|
|
@@ -2969,7 +2982,7 @@ var EditRow = function EditRow(props) {
|
|
|
2969
2982
|
scaleWidth: scaleWidth
|
|
2970
2983
|
});
|
|
2971
2984
|
return time;
|
|
2972
|
-
};
|
|
2985
|
+
}, [areaRef, scrollLeft, startLeft, scale, scaleWidth]);
|
|
2973
2986
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2974
2987
|
className: "".concat(prefix.apply(void 0, classNames), " ").concat(((rowData === null || rowData === void 0 ? void 0 : rowData.classNames) || []).join(' ')),
|
|
2975
2988
|
style: style,
|
|
@@ -3409,9 +3422,9 @@ var useRowDrag = function useRowDrag(options) {
|
|
|
3409
3422
|
if (up === 0) {
|
|
3410
3423
|
top = 0;
|
|
3411
3424
|
} else if (up === 1) {
|
|
3412
|
-
top =
|
|
3425
|
+
top = 35;
|
|
3413
3426
|
} else if (up === -1) {
|
|
3414
|
-
top =
|
|
3427
|
+
top = -35;
|
|
3415
3428
|
}
|
|
3416
3429
|
// 如果没有初始位置数据,说明不是有效的多选拖拽
|
|
3417
3430
|
if (!setEditorData || initialPositions.size === 0) {
|
|
@@ -3680,7 +3693,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3680
3693
|
return /*#__PURE__*/function () {
|
|
3681
3694
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(info) {
|
|
3682
3695
|
var _info$file$response, _info$file;
|
|
3683
|
-
var hasDefault, totalDuration, _newAction, uid, duration, newAction;
|
|
3696
|
+
var maxSize, hasDefault, totalDuration, _newAction, uid, duration, newAction;
|
|
3684
3697
|
return _regenerator().w(function (_context) {
|
|
3685
3698
|
while (1) switch (_context.n) {
|
|
3686
3699
|
case 0:
|
|
@@ -3691,16 +3704,23 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3691
3704
|
}
|
|
3692
3705
|
return _context.a(2);
|
|
3693
3706
|
case 1:
|
|
3694
|
-
|
|
3707
|
+
maxSize = 100 * 1024 * 1024;
|
|
3708
|
+
if (!(info.file.size > maxSize)) {
|
|
3695
3709
|
_context.n = 2;
|
|
3696
3710
|
break;
|
|
3697
3711
|
}
|
|
3698
3712
|
return _context.a(2, false);
|
|
3699
3713
|
case 2:
|
|
3700
|
-
if (!(info.file.
|
|
3714
|
+
if (!(info.file.type !== 'audio/mp3' && info.file.type !== 'audio/wav' && info.file.type !== 'audio/mpeg')) {
|
|
3701
3715
|
_context.n = 3;
|
|
3702
3716
|
break;
|
|
3703
3717
|
}
|
|
3718
|
+
return _context.a(2, false);
|
|
3719
|
+
case 3:
|
|
3720
|
+
if (!(info.file.status === 'error')) {
|
|
3721
|
+
_context.n = 4;
|
|
3722
|
+
break;
|
|
3723
|
+
}
|
|
3704
3724
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [{
|
|
3705
3725
|
id: info.file.uid,
|
|
3706
3726
|
isUploading: false,
|
|
@@ -3712,9 +3732,9 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3712
3732
|
uid: info.file.uid
|
|
3713
3733
|
}]);
|
|
3714
3734
|
return _context.a(2);
|
|
3715
|
-
case
|
|
3735
|
+
case 4:
|
|
3716
3736
|
if (info.file.response) {
|
|
3717
|
-
_context.n =
|
|
3737
|
+
_context.n = 5;
|
|
3718
3738
|
break;
|
|
3719
3739
|
}
|
|
3720
3740
|
hasDefault = row.actions.some(function (action) {
|
|
@@ -3741,11 +3761,11 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3741
3761
|
};
|
|
3742
3762
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [_newAction]);
|
|
3743
3763
|
return _context.a(2);
|
|
3744
|
-
case
|
|
3764
|
+
case 5:
|
|
3745
3765
|
uid = info.file.uid;
|
|
3746
|
-
_context.n =
|
|
3766
|
+
_context.n = 6;
|
|
3747
3767
|
return getAudioDuration(info.file.response.url);
|
|
3748
|
-
case
|
|
3768
|
+
case 6:
|
|
3749
3769
|
duration = _context.v;
|
|
3750
3770
|
newAction = {
|
|
3751
3771
|
id: ((_info$file$response = info.file.response) === null || _info$file$response === void 0 ? void 0 : _info$file$response.id) || uid,
|
|
@@ -3760,7 +3780,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3760
3780
|
uid: (_info$file = info.file) === null || _info$file === void 0 ? void 0 : _info$file.uid
|
|
3761
3781
|
};
|
|
3762
3782
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
|
|
3763
|
-
case
|
|
3783
|
+
case 7:
|
|
3764
3784
|
return _context.a(2);
|
|
3765
3785
|
}
|
|
3766
3786
|
}, _callee);
|
|
@@ -4097,7 +4117,6 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
4097
4117
|
}
|
|
4098
4118
|
}
|
|
4099
4119
|
heightRef.current = height;
|
|
4100
|
-
console.log('Math.max(scaleCount * scaleWidth + startLeft, width)', Math.max(scaleCount * scaleWidth + startLeft, width), ', width', width);
|
|
4101
4120
|
return /*#__PURE__*/React__default['default'].createElement(reactVirtualized.Grid, {
|
|
4102
4121
|
columnCount: 1,
|
|
4103
4122
|
rowCount: heights.length,
|
|
@@ -4185,7 +4204,8 @@ var TimeArea = function TimeArea(_ref) {
|
|
|
4185
4204
|
scrollLeft = _ref.scrollLeft,
|
|
4186
4205
|
onClickTimeArea = _ref.onClickTimeArea,
|
|
4187
4206
|
getScaleRender = _ref.getScaleRender,
|
|
4188
|
-
timelineWidth = _ref.timelineWidth
|
|
4207
|
+
timelineWidth = _ref.timelineWidth,
|
|
4208
|
+
cursorRef = _ref.cursorRef;
|
|
4189
4209
|
var gridRef = React.useRef();
|
|
4190
4210
|
/** 是否显示细分刻度 */
|
|
4191
4211
|
var showUnit = scaleSplitCount > 0;
|
|
@@ -4262,7 +4282,7 @@ var TimeArea = function TimeArea(_ref) {
|
|
|
4262
4282
|
scaleWidth: scaleWidth
|
|
4263
4283
|
});
|
|
4264
4284
|
var result = onClickTimeArea && onClickTimeArea(time, e);
|
|
4265
|
-
if (result === false) return; // 返回false时阻止设置时间
|
|
4285
|
+
if (result === false) return; // 返回 false 时阻止设置时间
|
|
4266
4286
|
setCursor({
|
|
4267
4287
|
time: time
|
|
4268
4288
|
});
|
|
@@ -4456,7 +4476,7 @@ var DragLineController = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(f
|
|
|
4456
4476
|
}));
|
|
4457
4477
|
DragLineController.displayName = "DragLineController";
|
|
4458
4478
|
|
|
4459
|
-
var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props, ref) {
|
|
4479
|
+
var Timeline = /*#__PURE__*/React__default['default'].memo(/*#__PURE__*/React__default['default'].forwardRef(function (props, ref) {
|
|
4460
4480
|
var checkedProps = checkProps(props);
|
|
4461
4481
|
var style = props.style,
|
|
4462
4482
|
className = props.className,
|
|
@@ -4485,6 +4505,7 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
|
|
|
4485
4505
|
var areaRef = React.useRef();
|
|
4486
4506
|
var scrollSync = React.useRef();
|
|
4487
4507
|
var containerRef = React.useRef();
|
|
4508
|
+
var cursorRef = React.useRef(null);
|
|
4488
4509
|
console.log(' Timeline mounted = ', areaRef);
|
|
4489
4510
|
// 编辑器数据
|
|
4490
4511
|
var _useState = React.useState(data),
|
|
@@ -4537,11 +4558,11 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
|
|
|
4537
4558
|
scrollTop: scrollTop
|
|
4538
4559
|
});
|
|
4539
4560
|
}, [scrollTop]);
|
|
4540
|
-
/** 动态设置scale count */
|
|
4541
|
-
var handleSetScaleCount = function
|
|
4561
|
+
/** 动态设置 scale count */
|
|
4562
|
+
var handleSetScaleCount = React.useCallback(function (value) {
|
|
4542
4563
|
var data = Math.min(maxScaleCount, Math.max(minScaleCount, value));
|
|
4543
4564
|
setScaleCount(data);
|
|
4544
|
-
};
|
|
4565
|
+
}, [maxScaleCount, minScaleCount]);
|
|
4545
4566
|
/** 处理主动数据变化 */
|
|
4546
4567
|
var handleEditorDataChange = function handleEditorDataChange(updatedData) {
|
|
4547
4568
|
var result = onChange === null || onChange === void 0 ? void 0 : onChange(updatedData);
|
|
@@ -4552,7 +4573,7 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
|
|
|
4552
4573
|
}
|
|
4553
4574
|
};
|
|
4554
4575
|
/** 处理光标 */
|
|
4555
|
-
var handleSetCursor = function
|
|
4576
|
+
var handleSetCursor = React.useCallback(function (param) {
|
|
4556
4577
|
var left = param.left,
|
|
4557
4578
|
time = param.time,
|
|
4558
4579
|
_param$updateTime = param.updateTime,
|
|
@@ -4577,16 +4598,16 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
|
|
|
4577
4598
|
}
|
|
4578
4599
|
result && setCursorTime(time);
|
|
4579
4600
|
return result;
|
|
4580
|
-
};
|
|
4581
|
-
/** 设置scrollLeft */
|
|
4582
|
-
var handleDeltaScrollLeft = function
|
|
4601
|
+
}, [startLeft, scale, scaleWidth, autoReRender]);
|
|
4602
|
+
/** 设置 scrollLeft */
|
|
4603
|
+
var handleDeltaScrollLeft = React.useCallback(function (delta) {
|
|
4583
4604
|
// 当超过最大距离时,禁止自动滚动
|
|
4584
4605
|
var data = scrollSync.current.state.scrollLeft + delta;
|
|
4585
4606
|
if (data > scaleCount * (scaleWidth - 1) + startLeft - width) return;
|
|
4586
4607
|
scrollSync.current && scrollSync.current.setState({
|
|
4587
4608
|
scrollLeft: Math.max(scrollSync.current.state.scrollLeft + delta, 0)
|
|
4588
4609
|
});
|
|
4589
|
-
};
|
|
4610
|
+
}, [scaleCount, scaleWidth, startLeft, width]);
|
|
4590
4611
|
var handleInitDragLine = React.useCallback(function (data) {
|
|
4591
4612
|
var _checkedProps$onActio, _checkedProps$onActio2, _dragLineControllerRe;
|
|
4592
4613
|
(_checkedProps$onActio = checkedProps.onActionMoveStart) === null || _checkedProps$onActio === void 0 ? void 0 : _checkedProps$onActio.call(checkedProps, data);
|
|
@@ -4605,6 +4626,10 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
|
|
|
4605
4626
|
(_checkedProps$onActio6 = checkedProps.onActionResizeEnd) === null || _checkedProps$onActio6 === void 0 ? void 0 : _checkedProps$onActio6.call(checkedProps, data);
|
|
4606
4627
|
(_dragLineControllerRe3 = dragLineControllerRef.current) === null || _dragLineControllerRe3 === void 0 ? void 0 : _dragLineControllerRe3.disposeDragLine();
|
|
4607
4628
|
}, [checkedProps]);
|
|
4629
|
+
/** 处理滚动回调 */
|
|
4630
|
+
var onScroll = React.useCallback(function (params) {
|
|
4631
|
+
onScrollVertical && onScrollVertical(params);
|
|
4632
|
+
}, [onScrollVertical]);
|
|
4608
4633
|
// 处理运行器相关数据
|
|
4609
4634
|
React.useEffect(function () {
|
|
4610
4635
|
var handleTime = function handleTime(_ref) {
|
|
@@ -4677,7 +4702,7 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
|
|
|
4677
4702
|
}
|
|
4678
4703
|
};
|
|
4679
4704
|
});
|
|
4680
|
-
var onClickTimeline = function
|
|
4705
|
+
var onClickTimeline = React.useCallback(function (e) {
|
|
4681
4706
|
var _e$target;
|
|
4682
4707
|
if (!domRef.current) return;
|
|
4683
4708
|
var rect = domRef.current.getBoundingClientRect();
|
|
@@ -4694,7 +4719,7 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
|
|
|
4694
4719
|
handleSetCursor({
|
|
4695
4720
|
time: time
|
|
4696
4721
|
});
|
|
4697
|
-
};
|
|
4722
|
+
}, [startLeft, scale, scaleWidth, hideCursor, handleSetCursor]);
|
|
4698
4723
|
// 监听timeline区域宽度变化
|
|
4699
4724
|
React.useEffect(function () {
|
|
4700
4725
|
if (areaRef.current) {
|
|
@@ -4741,7 +4766,8 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
|
|
|
4741
4766
|
scaleCount: scaleCount,
|
|
4742
4767
|
setScaleCount: handleSetScaleCount,
|
|
4743
4768
|
onScroll: _onScroll,
|
|
4744
|
-
scrollLeft: scrollLeft
|
|
4769
|
+
scrollLeft: scrollLeft,
|
|
4770
|
+
cursorRef: cursorRef
|
|
4745
4771
|
})), areaCount === 1 ? (/*#__PURE__*/React__default['default'].createElement(EditArea, _objectSpread2(_objectSpread2({}, checkedProps), {}, {
|
|
4746
4772
|
timelineWidth: width,
|
|
4747
4773
|
ref: function ref(_ref3) {
|
|
@@ -4829,12 +4855,10 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
|
|
|
4829
4855
|
onActionResizing: handleUpdateDragLine,
|
|
4830
4856
|
onActionMoveEnd: handleDisposeDragLine,
|
|
4831
4857
|
onActionResizeEnd: handleDisposeDragLine,
|
|
4832
|
-
onScroll:
|
|
4833
|
-
_onScroll(params);
|
|
4834
|
-
onScrollVertical && onScrollVertical(params);
|
|
4835
|
-
}
|
|
4858
|
+
onScroll: _onScroll
|
|
4836
4859
|
}));
|
|
4837
4860
|
}))) : null, !hideCursor && (/*#__PURE__*/React__default['default'].createElement(Cursor, _objectSpread2(_objectSpread2({}, checkedProps), {}, {
|
|
4861
|
+
ref: cursorRef,
|
|
4838
4862
|
timelineWidth: width,
|
|
4839
4863
|
disableDrag: isPlaying,
|
|
4840
4864
|
scrollLeft: scrollLeft,
|
|
@@ -4859,7 +4883,7 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
|
|
|
4859
4883
|
getAssistDragLineActionIds: checkedProps.getAssistDragLineActionIds
|
|
4860
4884
|
}));
|
|
4861
4885
|
}));
|
|
4862
|
-
});
|
|
4886
|
+
}));
|
|
4863
4887
|
|
|
4864
4888
|
exports.Timeline = Timeline;
|
|
4865
4889
|
exports.TimelineEngine = TimelineEngine;
|