@vidispine/vdt-react-timeline 22.4.0 → 23.1.0-pre.2
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/Timeline/Timeline.js +10 -0
- package/dist/TimelineContext.js +8 -0
- package/dist/TimelineEvent/TimelineEvent.js +13 -0
- package/dist/TimelinePlayhead/TimelinePlayhead.js +14 -0
- package/dist/TimelinePlayheadTrack/TimelinePlayheadTrack.js +19 -0
- package/dist/TimelineRow/TimelineRow.js +8 -0
- package/dist/TimelineScroll/TimelineScroll.js +16 -0
- package/dist/TimelineScrollContainer/TimelineScrollContainer.js +11 -0
- package/dist/TimelineTrack/TimelineTrack.js +17 -0
- package/dist/TimelineWaveform/TimelineWaveform.js +15 -0
- package/dist/_consts.js +3 -0
- package/dist/_utils.js +4 -0
- package/dist/index.js +10 -0
- package/dist/useHover.js +6 -0
- package/dist/useOptionallyControlledState.js +7 -0
- package/dist/useResizeObserver.js +6 -0
- package/dist/useTimelinePerspective.js +7 -0
- package/package.json +11 -9
- package/dist/index.es.js +0 -1857
package/dist/index.es.js
DELETED
|
@@ -1,1857 +0,0 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
-
import { useState, useRef, createContext, useMemo, useContext, useEffect, memo, Children, cloneElement } from 'react';
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
7
|
-
import clamp from 'lodash.clamp';
|
|
8
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
|
-
import { Stage, Layer, Rect, Group, Text, Line } from 'react-konva';
|
|
10
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
11
|
-
import sortBy from 'lodash.sortby';
|
|
12
|
-
import uniq from 'lodash.uniq';
|
|
13
|
-
|
|
14
|
-
var interpolate = function interpolate(y0, y1, x0, x1, x) {
|
|
15
|
-
return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
|
|
16
|
-
};
|
|
17
|
-
var vLogImpl = function vLogImpl(component, msg, level) {
|
|
18
|
-
if (process.env.NODE_ENV === 'development') {
|
|
19
|
-
// eslint-disable-next-line no-console
|
|
20
|
-
console[level]("".concat(component ? "".concat(component, ": ") : '').concat(msg));
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
var vLog = {
|
|
24
|
-
error: function error() {
|
|
25
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
-
args[_key] = arguments[_key];
|
|
27
|
-
}
|
|
28
|
-
return vLogImpl.apply(void 0, args.concat(['error']));
|
|
29
|
-
},
|
|
30
|
-
warn: function warn() {
|
|
31
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
32
|
-
args[_key2] = arguments[_key2];
|
|
33
|
-
}
|
|
34
|
-
return vLogImpl.apply(void 0, args.concat(['warn']));
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
function mapPairs(arr, func) {
|
|
38
|
-
var result = [];
|
|
39
|
-
for (var i = 0; i < arr.length - 1; i += 1) {
|
|
40
|
-
result.push(func(arr[i], arr[i + 1]));
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
function getStyleProperties() {
|
|
45
|
-
var style = getComputedStyle(document.body);
|
|
46
|
-
for (var _len3 = arguments.length, properties = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
47
|
-
properties[_key3] = arguments[_key3];
|
|
48
|
-
}
|
|
49
|
-
return properties.map(function (prop) {
|
|
50
|
-
return style.getPropertyValue(prop);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function useOptionallyControlledState(_ref) {
|
|
55
|
-
var _ref$uncontrolledDefa = _ref.uncontrolledDefaultState,
|
|
56
|
-
uncontrolledDefaultState = _ref$uncontrolledDefa === void 0 ? undefined : _ref$uncontrolledDefa,
|
|
57
|
-
_ref$uncontrolledOnCh = _ref.uncontrolledOnChange,
|
|
58
|
-
uncontrolledOnChange = _ref$uncontrolledOnCh === void 0 ? undefined : _ref$uncontrolledOnCh,
|
|
59
|
-
_ref$controlledState = _ref.controlledState,
|
|
60
|
-
controlledState = _ref$controlledState === void 0 ? undefined : _ref$controlledState,
|
|
61
|
-
_ref$controlledOnChan = _ref.controlledOnChange,
|
|
62
|
-
controlledOnChange = _ref$controlledOnChan === void 0 ? undefined : _ref$controlledOnChan,
|
|
63
|
-
componentName = _ref.componentName,
|
|
64
|
-
stateName = _ref.stateName;
|
|
65
|
-
var _useState = useState(uncontrolledDefaultState),
|
|
66
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
67
|
-
uncontrolledState = _useState2[0],
|
|
68
|
-
setUncontrolledState = _useState2[1];
|
|
69
|
-
var isControlled = useRef(null);
|
|
70
|
-
var setIsControlled = function setIsControlled(newValue) {
|
|
71
|
-
if (isControlled.current !== null && isControlled.current !== newValue) {
|
|
72
|
-
if (newValue) {
|
|
73
|
-
vLog.warn(componentName, "".concat(stateName, " changed from uncontrolled to controlled"));
|
|
74
|
-
} else {
|
|
75
|
-
vLog.warn(componentName, "".concat(stateName, " changed from controlled to uncontrolled"));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
isControlled.current = newValue;
|
|
79
|
-
};
|
|
80
|
-
if (controlledState !== undefined) {
|
|
81
|
-
setIsControlled(true);
|
|
82
|
-
return [controlledState, controlledOnChange];
|
|
83
|
-
}
|
|
84
|
-
setIsControlled(false);
|
|
85
|
-
return [uncontrolledState, controlledOnChange ? function () {
|
|
86
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
87
|
-
args[_key] = arguments[_key];
|
|
88
|
-
}
|
|
89
|
-
if (uncontrolledOnChange) {
|
|
90
|
-
uncontrolledOnChange.apply(void 0, [setUncontrolledState].concat(args));
|
|
91
|
-
} else {
|
|
92
|
-
setUncontrolledState.apply(void 0, args);
|
|
93
|
-
}
|
|
94
|
-
controlledOnChange.apply(void 0, args);
|
|
95
|
-
} : uncontrolledOnChange || setUncontrolledState];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function defaultGetZoomMultiplier(direction, time, perspective) {
|
|
99
|
-
var multiplier = perspective.end - perspective.start < 100 && direction === 'in' ? 1 : 2;
|
|
100
|
-
return direction === 'in' ? 1 / multiplier : multiplier;
|
|
101
|
-
}
|
|
102
|
-
function useTimelinePerspective(_ref) {
|
|
103
|
-
var start = _ref.start,
|
|
104
|
-
end = _ref.end,
|
|
105
|
-
propDefaultPerspective = _ref.defaultPerspective,
|
|
106
|
-
propPerspective = _ref.perspective,
|
|
107
|
-
propOnChangePerspective = _ref.onChangePerspective,
|
|
108
|
-
_ref$zoomMultiplier = _ref.zoomMultiplier,
|
|
109
|
-
zoomMultiplier = _ref$zoomMultiplier === void 0 ? defaultGetZoomMultiplier : _ref$zoomMultiplier;
|
|
110
|
-
var _useOptionallyControl = useOptionallyControlledState({
|
|
111
|
-
uncontrolledDefaultState: propDefaultPerspective || {
|
|
112
|
-
start: start,
|
|
113
|
-
end: end
|
|
114
|
-
},
|
|
115
|
-
controlledState: propPerspective,
|
|
116
|
-
controlledOnChange: propOnChangePerspective,
|
|
117
|
-
componentName: 'VdtTimeline',
|
|
118
|
-
stateName: 'perspective'
|
|
119
|
-
}),
|
|
120
|
-
_useOptionallyControl2 = _slicedToArray(_useOptionallyControl, 2),
|
|
121
|
-
perspective = _useOptionallyControl2[0],
|
|
122
|
-
setPerspective = _useOptionallyControl2[1];
|
|
123
|
-
var getZoomMultiplier = typeof zoomMultiplier === 'function' ? zoomMultiplier : function (direction) {
|
|
124
|
-
return direction === 'in' ? 1 / zoomMultiplier : zoomMultiplier;
|
|
125
|
-
};
|
|
126
|
-
var checkedSetPerspective = function checkedSetPerspective(perspectiveStart, perspectiveEnd) {
|
|
127
|
-
setPerspective({
|
|
128
|
-
start: clamp(Number(perspectiveStart), start, end),
|
|
129
|
-
end: clamp(Number(perspectiveEnd), start, end)
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
var zoom = function zoom(direction, time) {
|
|
133
|
-
var perspectiveDuration = perspective.end - perspective.start;
|
|
134
|
-
var normalizedTimeOffset = (time - perspective.start) / perspectiveDuration;
|
|
135
|
-
var currZoomMultiplier = getZoomMultiplier(direction, time, perspective);
|
|
136
|
-
if (currZoomMultiplier === 1) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
var newPerspectiveDuration = (perspective.end - perspective.start) * currZoomMultiplier;
|
|
140
|
-
var newPerspectiveStart = time - normalizedTimeOffset * newPerspectiveDuration;
|
|
141
|
-
var newPerspectiveEnd = time + (1 - normalizedTimeOffset) * newPerspectiveDuration;
|
|
142
|
-
var perspectiveMisalignmentCorrection = function () {
|
|
143
|
-
if (start > newPerspectiveStart) {
|
|
144
|
-
return start - newPerspectiveStart;
|
|
145
|
-
}
|
|
146
|
-
if (newPerspectiveEnd > end) {
|
|
147
|
-
return end - newPerspectiveEnd;
|
|
148
|
-
}
|
|
149
|
-
return 0;
|
|
150
|
-
}();
|
|
151
|
-
checkedSetPerspective(newPerspectiveStart + perspectiveMisalignmentCorrection, newPerspectiveEnd + perspectiveMisalignmentCorrection);
|
|
152
|
-
};
|
|
153
|
-
return {
|
|
154
|
-
perspective: perspective,
|
|
155
|
-
setPerspective: checkedSetPerspective,
|
|
156
|
-
zoom: zoom
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
161
|
-
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$a(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
162
|
-
var TimelineContext = /*#__PURE__*/createContext();
|
|
163
|
-
function TimelineProvider(_ref) {
|
|
164
|
-
var start = _ref.start,
|
|
165
|
-
end = _ref.end,
|
|
166
|
-
time = _ref.time,
|
|
167
|
-
onChangeTime = _ref.onChangeTime,
|
|
168
|
-
timelineRef = _ref.timelineRef,
|
|
169
|
-
children = _ref.children,
|
|
170
|
-
perspective = _ref.perspective,
|
|
171
|
-
onChangePerspective = _ref.onChangePerspective,
|
|
172
|
-
defaultPerspective = _ref.defaultPerspective;
|
|
173
|
-
var timelinePerspective = useTimelinePerspective({
|
|
174
|
-
start: start,
|
|
175
|
-
end: end,
|
|
176
|
-
perspective: perspective,
|
|
177
|
-
onChangePerspective: onChangePerspective,
|
|
178
|
-
defaultPerspective: defaultPerspective
|
|
179
|
-
});
|
|
180
|
-
var contextValue = useMemo(function () {
|
|
181
|
-
return _objectSpread$a(_objectSpread$a({}, timelinePerspective), {}, {
|
|
182
|
-
start: start,
|
|
183
|
-
end: end,
|
|
184
|
-
time: time,
|
|
185
|
-
onChangeTime: onChangeTime,
|
|
186
|
-
timelineRef: timelineRef
|
|
187
|
-
});
|
|
188
|
-
}, [end, onChangeTime, start, time, timelinePerspective, timelineRef]);
|
|
189
|
-
return /*#__PURE__*/jsx(TimelineContext.Provider, {
|
|
190
|
-
value: contextValue,
|
|
191
|
-
children: children
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
function useTimeline() {
|
|
195
|
-
return useContext(TimelineContext);
|
|
196
|
-
}
|
|
197
|
-
TimelineContext.propTypes = {
|
|
198
|
-
start: PropTypes.number.isRequired,
|
|
199
|
-
end: PropTypes.number.isRequired,
|
|
200
|
-
time: PropTypes.number,
|
|
201
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element]),
|
|
202
|
-
onChangeTime: PropTypes.func,
|
|
203
|
-
timelineRef: PropTypes.shape({
|
|
204
|
-
current: PropTypes.instanceOf(Element)
|
|
205
|
-
}),
|
|
206
|
-
perspective: PropTypes.shape({
|
|
207
|
-
start: PropTypes.number,
|
|
208
|
-
end: PropTypes.number
|
|
209
|
-
}),
|
|
210
|
-
onChangePerspective: PropTypes.func,
|
|
211
|
-
defaultPerspective: PropTypes.shape({
|
|
212
|
-
start: PropTypes.number,
|
|
213
|
-
end: PropTypes.number
|
|
214
|
-
}),
|
|
215
|
-
zoomMultiplier: PropTypes.oneOfType([PropTypes.number, PropTypes.func])
|
|
216
|
-
};
|
|
217
|
-
TimelineContext.defaultProps = {
|
|
218
|
-
children: undefined,
|
|
219
|
-
time: undefined,
|
|
220
|
-
onChangeTime: undefined,
|
|
221
|
-
timelineRef: undefined,
|
|
222
|
-
perspective: undefined,
|
|
223
|
-
onChangePerspective: undefined,
|
|
224
|
-
defaultPerspective: undefined,
|
|
225
|
-
zoomMultiplier: undefined
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
229
|
-
|
|
230
|
-
var css$7 = ":root {\n --vdt-timeline-palette-primary:#49a6dd;\n --vdt-timeline-palette-primary-dark: #3c8bb8;\n --vdt-timeline-palette-secondary:#f50057;\n --vdt-timeline-palette-background-primary:#20232a;\n --vdt-timeline-palette-background-secondary:#282c34;\n --vdt-timeline-palette-background-hover: rgba(255, 255, 255, 0.08);\n --vdt-timeline-palette-text-primary:#fff;\n --vdt-timeline-palette-text-secondary:rgba(255, 255, 255, 0.7);\n}\n\n.VdtTimeline-root {\n display: flex;\n flex-direction: column;\n padding: 0 8px 8px 8px;\n background-color: var(--vdt-timeline-palette-background-primary);\n}";
|
|
231
|
-
n(css$7,{});
|
|
232
|
-
|
|
233
|
-
var _excluded$9 = ["start", "end", "time", "onChangeTime", "children", "className", "perspective", "onChangePerspective", "defaultPerspective", "zoomMultiplier"];
|
|
234
|
-
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
235
|
-
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
236
|
-
function Timeline(_ref) {
|
|
237
|
-
var start = _ref.start,
|
|
238
|
-
end = _ref.end,
|
|
239
|
-
time = _ref.time,
|
|
240
|
-
onChangeTime = _ref.onChangeTime,
|
|
241
|
-
children = _ref.children,
|
|
242
|
-
className = _ref.className,
|
|
243
|
-
perspective = _ref.perspective,
|
|
244
|
-
onChangePerspective = _ref.onChangePerspective,
|
|
245
|
-
defaultPerspective = _ref.defaultPerspective,
|
|
246
|
-
zoomMultiplier = _ref.zoomMultiplier,
|
|
247
|
-
props = _objectWithoutProperties(_ref, _excluded$9);
|
|
248
|
-
var timelineRef = useRef();
|
|
249
|
-
return /*#__PURE__*/jsx(TimelineProvider, {
|
|
250
|
-
start: start,
|
|
251
|
-
end: end,
|
|
252
|
-
time: time,
|
|
253
|
-
onChangeTime: onChangeTime,
|
|
254
|
-
timelineRef: timelineRef,
|
|
255
|
-
perspective: perspective,
|
|
256
|
-
onChangePerspective: onChangePerspective,
|
|
257
|
-
defaultPerspective: defaultPerspective,
|
|
258
|
-
zoomMultiplier: zoomMultiplier,
|
|
259
|
-
children: /*#__PURE__*/jsx("div", _objectSpread$9(_objectSpread$9({
|
|
260
|
-
ref: timelineRef,
|
|
261
|
-
className: clsx('VdtTimeline-root', className)
|
|
262
|
-
}, props), {}, {
|
|
263
|
-
children: children
|
|
264
|
-
}))
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
Timeline.propTypes = {
|
|
268
|
-
/**
|
|
269
|
-
* Start of timeline.
|
|
270
|
-
*/
|
|
271
|
-
start: PropTypes.number.isRequired,
|
|
272
|
-
/**
|
|
273
|
-
* End of timeline.
|
|
274
|
-
*/
|
|
275
|
-
end: PropTypes.number.isRequired,
|
|
276
|
-
/**
|
|
277
|
-
* Place of timeline marker.
|
|
278
|
-
*/
|
|
279
|
-
time: PropTypes.number,
|
|
280
|
-
/**
|
|
281
|
-
* Children components to render inside timeline.
|
|
282
|
-
*/
|
|
283
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
284
|
-
/**
|
|
285
|
-
* Callback to trigger when changing the value of time prop.
|
|
286
|
-
*/
|
|
287
|
-
onChangeTime: PropTypes.func,
|
|
288
|
-
/**
|
|
289
|
-
* Zoom level of timeline: shows ticks between start and end values (if start and end of timeline are within this range).
|
|
290
|
-
*/
|
|
291
|
-
perspective: PropTypes.shape({
|
|
292
|
-
start: PropTypes.number,
|
|
293
|
-
end: PropTypes.number
|
|
294
|
-
}),
|
|
295
|
-
/**
|
|
296
|
-
* Callback to trigger when changing the value of perspective prop.
|
|
297
|
-
*/
|
|
298
|
-
onChangePerspective: PropTypes.func,
|
|
299
|
-
/**
|
|
300
|
-
* Set default value for perspective when rendering component.
|
|
301
|
-
*/
|
|
302
|
-
defaultPerspective: PropTypes.shape({
|
|
303
|
-
start: PropTypes.number,
|
|
304
|
-
end: PropTypes.number
|
|
305
|
-
}),
|
|
306
|
-
/**
|
|
307
|
-
* Multiply by value when zooming in.
|
|
308
|
-
*/
|
|
309
|
-
zoomMultiplier: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
310
|
-
/**
|
|
311
|
-
* Override styles with className.
|
|
312
|
-
*/
|
|
313
|
-
className: PropTypes.string
|
|
314
|
-
};
|
|
315
|
-
Timeline.defaultProps = {
|
|
316
|
-
time: undefined,
|
|
317
|
-
children: undefined,
|
|
318
|
-
onChangeTime: undefined,
|
|
319
|
-
perspective: undefined,
|
|
320
|
-
onChangePerspective: undefined,
|
|
321
|
-
defaultPerspective: undefined,
|
|
322
|
-
zoomMultiplier: undefined,
|
|
323
|
-
className: undefined
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
var DEFAULT_EVENT_HEIGHT = 15;
|
|
327
|
-
var DEFAULT_PLAYHEAD_ZINDEX = 100;
|
|
328
|
-
|
|
329
|
-
var css$6 = ":root {\n --vdt-timeline-palette-primary:#49a6dd;\n --vdt-timeline-palette-primary-dark: #3c8bb8;\n --vdt-timeline-palette-secondary:#f50057;\n --vdt-timeline-palette-background-primary:#20232a;\n --vdt-timeline-palette-background-secondary:#282c34;\n --vdt-timeline-palette-background-hover: rgba(255, 255, 255, 0.08);\n --vdt-timeline-palette-text-primary:#fff;\n --vdt-timeline-palette-text-secondary:rgba(255, 255, 255, 0.7);\n}\n\n.VdtTimelinePlayhead-root {\n background-color: var(--vdt-timeline-palette-secondary);\n position: absolute;\n}\n\n\n.VdtTimelinePlayhead-root:hover {\n cursor: ew-resize;\n}";
|
|
330
|
-
n(css$6,{});
|
|
331
|
-
|
|
332
|
-
var _excluded$8 = ["className", "perspective", "time", "lineWidth", "headWidth", "headHeight", "style", "onDrag", "HeadProps"];
|
|
333
|
-
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
334
|
-
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
335
|
-
var _getStyleProperties$4 = getStyleProperties('--vdt-timeline-palette-secondary'),
|
|
336
|
-
_getStyleProperties2$4 = _slicedToArray(_getStyleProperties$4, 1),
|
|
337
|
-
paletteSecondary$1 = _getStyleProperties2$4[0];
|
|
338
|
-
var EmptyImage = document.createElement('img');
|
|
339
|
-
EmptyImage.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
|
340
|
-
function TimelinePlayhead(_ref) {
|
|
341
|
-
var _ref$current;
|
|
342
|
-
var className = _ref.className,
|
|
343
|
-
propPerspective = _ref.perspective,
|
|
344
|
-
propTime = _ref.time,
|
|
345
|
-
lineWidth = _ref.lineWidth,
|
|
346
|
-
headWidth = _ref.headWidth,
|
|
347
|
-
headHeight = _ref.headHeight,
|
|
348
|
-
style = _ref.style,
|
|
349
|
-
onDrag = _ref.onDrag,
|
|
350
|
-
HeadProps = _ref.HeadProps,
|
|
351
|
-
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
352
|
-
var _ref2 = useTimeline() || {
|
|
353
|
-
perspective: propPerspective,
|
|
354
|
-
time: propTime
|
|
355
|
-
},
|
|
356
|
-
perspective = _ref2.perspective,
|
|
357
|
-
time = _ref2.time,
|
|
358
|
-
onChangeTime = _ref2.onChangeTime;
|
|
359
|
-
if (perspective === undefined) {
|
|
360
|
-
vLog.error('VdtTimelinePlayhead', "missing 'perspective' prop. If the component is used outside a VdtTimelineContext, 'perspective' must be passed explicitly");
|
|
361
|
-
}
|
|
362
|
-
var ref = useRef();
|
|
363
|
-
var containerEl = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.parentElement;
|
|
364
|
-
var containerWidth = (containerEl === null || containerEl === void 0 ? void 0 : containerEl.clientWidth) || 0;
|
|
365
|
-
var _useState = useState(false),
|
|
366
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
367
|
-
isDragging = _useState2[0],
|
|
368
|
-
setIsDragging = _useState2[1];
|
|
369
|
-
var _useState3 = useState(time),
|
|
370
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
371
|
-
localTime = _useState4[0],
|
|
372
|
-
setLocalTime = _useState4[1];
|
|
373
|
-
var markerLeft = interpolate(0, containerWidth, perspective.start, perspective.end, localTime);
|
|
374
|
-
var isValidTime = function isValidTime(f) {
|
|
375
|
-
return f <= perspective.end && f >= perspective.start;
|
|
376
|
-
};
|
|
377
|
-
var hide = !isValidTime(localTime);
|
|
378
|
-
useEffect(function () {
|
|
379
|
-
if (time !== undefined && !isDragging) {
|
|
380
|
-
setLocalTime(time);
|
|
381
|
-
}
|
|
382
|
-
}, [time, isDragging]);
|
|
383
|
-
var handleDrag = onDrag || onChangeTime && function (e) {
|
|
384
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
385
|
-
args[_key - 1] = arguments[_key];
|
|
386
|
-
}
|
|
387
|
-
return onChangeTime.apply(void 0, args);
|
|
388
|
-
};
|
|
389
|
-
return /*#__PURE__*/jsx("div", _objectSpread$8(_objectSpread$8({
|
|
390
|
-
ref: ref,
|
|
391
|
-
className: clsx('VdtTimelinePlayhead-root', className),
|
|
392
|
-
style: _objectSpread$8({
|
|
393
|
-
width: lineWidth,
|
|
394
|
-
left: markerLeft,
|
|
395
|
-
display: hide && 'none',
|
|
396
|
-
zIndex: DEFAULT_PLAYHEAD_ZINDEX
|
|
397
|
-
}, style),
|
|
398
|
-
draggable: true,
|
|
399
|
-
onDragStart: function onDragStart(e) {
|
|
400
|
-
setIsDragging(true);
|
|
401
|
-
e.dataTransfer.setDragImage(EmptyImage, 0, 0);
|
|
402
|
-
return false;
|
|
403
|
-
},
|
|
404
|
-
onDragEnd: function onDragEnd() {
|
|
405
|
-
setIsDragging(false);
|
|
406
|
-
if (handleDrag !== null && handleDrag !== void 0 && handleDrag.flush) {
|
|
407
|
-
handleDrag.flush();
|
|
408
|
-
}
|
|
409
|
-
},
|
|
410
|
-
onDrag: function onDrag(e) {
|
|
411
|
-
if (handleDrag) {
|
|
412
|
-
var _ref$current$parentEl = ref.current.parentElement.getBoundingClientRect(),
|
|
413
|
-
containerX = _ref$current$parentEl.x;
|
|
414
|
-
var newTime = interpolate(perspective.start, perspective.end, 0, containerWidth, e.clientX - containerX);
|
|
415
|
-
if (isValidTime(newTime)) {
|
|
416
|
-
var clampedNewTime = clamp(newTime, perspective.start, perspective.end);
|
|
417
|
-
handleDrag(e, clampedNewTime);
|
|
418
|
-
setLocalTime(clampedNewTime);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}, props), {}, {
|
|
423
|
-
children: /*#__PURE__*/jsx("div", _objectSpread$8({
|
|
424
|
-
className: "VdtTimelinePlayhead-head",
|
|
425
|
-
style: {
|
|
426
|
-
position: 'absolute',
|
|
427
|
-
height: headHeight,
|
|
428
|
-
width: headWidth,
|
|
429
|
-
backgroundColor: paletteSecondary$1,
|
|
430
|
-
left: -(headWidth / 2 - lineWidth / 2),
|
|
431
|
-
top: -headHeight + 1,
|
|
432
|
-
clipPath: 'polygon(0% 0%, 0% 70%, 50% 100%, 100% 70%, 100% 0%)'
|
|
433
|
-
}
|
|
434
|
-
}, HeadProps))
|
|
435
|
-
}));
|
|
436
|
-
}
|
|
437
|
-
TimelinePlayhead.propTypes = {
|
|
438
|
-
/**
|
|
439
|
-
* Apply inline CSS styling
|
|
440
|
-
*/
|
|
441
|
-
style: PropTypes.instanceOf(Object),
|
|
442
|
-
/**
|
|
443
|
-
* Height of marker head in px
|
|
444
|
-
*/
|
|
445
|
-
headHeight: PropTypes.number,
|
|
446
|
-
/**
|
|
447
|
-
* Width of marker head in px
|
|
448
|
-
*/
|
|
449
|
-
headWidth: PropTypes.number,
|
|
450
|
-
/**
|
|
451
|
-
* Width/thickness of marker line in px
|
|
452
|
-
*/
|
|
453
|
-
lineWidth: PropTypes.number,
|
|
454
|
-
/**
|
|
455
|
-
* Zoom level when looking at playhead.
|
|
456
|
-
*/
|
|
457
|
-
perspective: PropTypes.shape({
|
|
458
|
-
start: PropTypes.number,
|
|
459
|
-
end: PropTypes.number
|
|
460
|
-
}),
|
|
461
|
-
/**
|
|
462
|
-
* Timeline placement of marker
|
|
463
|
-
*/
|
|
464
|
-
time: PropTypes.number,
|
|
465
|
-
onDrag: PropTypes.func,
|
|
466
|
-
/**
|
|
467
|
-
* Additional props for marker head
|
|
468
|
-
*/
|
|
469
|
-
HeadProps: PropTypes.instanceOf(Object),
|
|
470
|
-
/**
|
|
471
|
-
* Override styles with className
|
|
472
|
-
*/
|
|
473
|
-
className: PropTypes.string
|
|
474
|
-
};
|
|
475
|
-
TimelinePlayhead.defaultProps = {
|
|
476
|
-
style: {},
|
|
477
|
-
headHeight: 16,
|
|
478
|
-
headWidth: 12,
|
|
479
|
-
lineWidth: 2,
|
|
480
|
-
perspective: undefined,
|
|
481
|
-
time: 0,
|
|
482
|
-
onDrag: undefined,
|
|
483
|
-
HeadProps: {},
|
|
484
|
-
className: undefined
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
function useResizeObserver(ref) {
|
|
488
|
-
var _useState = useState({}),
|
|
489
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
490
|
-
rect = _useState2[0],
|
|
491
|
-
setRect = _useState2[1];
|
|
492
|
-
var observerRef = useRef(new ResizeObserver(function (entries) {
|
|
493
|
-
var _entries$;
|
|
494
|
-
var contentRect = (_entries$ = entries[0]) === null || _entries$ === void 0 ? void 0 : _entries$.contentRect;
|
|
495
|
-
if (contentRect) {
|
|
496
|
-
setRect(contentRect);
|
|
497
|
-
}
|
|
498
|
-
}));
|
|
499
|
-
useEffect(function () {
|
|
500
|
-
var observer = observerRef === null || observerRef === void 0 ? void 0 : observerRef.current;
|
|
501
|
-
var el = ref === null || ref === void 0 ? void 0 : ref.current;
|
|
502
|
-
if (el) {
|
|
503
|
-
observer.observe(el);
|
|
504
|
-
}
|
|
505
|
-
return function () {
|
|
506
|
-
if (el) {
|
|
507
|
-
observer.unobserve(el);
|
|
508
|
-
}
|
|
509
|
-
};
|
|
510
|
-
}, [ref]);
|
|
511
|
-
return rect;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
var css$5 = ":root {\n --vdt-timeline-palette-primary:#49a6dd;\n --vdt-timeline-palette-primary-dark: #3c8bb8;\n --vdt-timeline-palette-secondary:#f50057;\n --vdt-timeline-palette-background-primary:#20232a;\n --vdt-timeline-palette-background-secondary:#282c34;\n --vdt-timeline-palette-background-hover: rgba(255, 255, 255, 0.08);\n --vdt-timeline-palette-text-primary:#fff;\n --vdt-timeline-palette-text-secondary:rgba(255, 255, 255, 0.7);\n}";
|
|
515
|
-
n(css$5,{});
|
|
516
|
-
|
|
517
|
-
var css$4 = ".VdtTimelineWaveform-root {\n height: 40px;\n}";
|
|
518
|
-
n(css$4,{});
|
|
519
|
-
|
|
520
|
-
var _excluded$7 = ["amplitudeSegments", "pxPerTimeUnit", "start", "height"],
|
|
521
|
-
_excluded2$3 = ["className", "waveform", "start", "end", "perspective", "StageProps", "LayerProps", "RectProps", "WaveRectProps"];
|
|
522
|
-
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
523
|
-
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
524
|
-
var _getStyleProperties$3 = getStyleProperties('--vdt-timeline-palette-primary'),
|
|
525
|
-
_getStyleProperties2$3 = _slicedToArray(_getStyleProperties$3, 1),
|
|
526
|
-
palettePrimary$1 = _getStyleProperties2$3[0];
|
|
527
|
-
var TimelineWaveFormRects = /*#__PURE__*/memo(function (_ref) {
|
|
528
|
-
var amplitudeSegments = _ref.amplitudeSegments,
|
|
529
|
-
pxPerTimeUnit = _ref.pxPerTimeUnit,
|
|
530
|
-
start = _ref.start,
|
|
531
|
-
height = _ref.height,
|
|
532
|
-
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
533
|
-
return amplitudeSegments.map(function (_ref2, i) {
|
|
534
|
-
var amplitude = _ref2.amplitude,
|
|
535
|
-
segmentStart = _ref2.start,
|
|
536
|
-
segmentEnd = _ref2.end;
|
|
537
|
-
var rectWidth = pxPerTimeUnit * (segmentEnd - segmentStart);
|
|
538
|
-
var rectX = (segmentStart - start) * pxPerTimeUnit;
|
|
539
|
-
var rectHeight = height * amplitude;
|
|
540
|
-
var centeredY = (height - rectHeight) / 2;
|
|
541
|
-
return /*#__PURE__*/jsx(Rect
|
|
542
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
543
|
-
, _objectSpread$7({
|
|
544
|
-
x: rectX,
|
|
545
|
-
y: centeredY,
|
|
546
|
-
height: rectHeight,
|
|
547
|
-
width: rectWidth,
|
|
548
|
-
fill: palettePrimary$1
|
|
549
|
-
}, props), i);
|
|
550
|
-
});
|
|
551
|
-
});
|
|
552
|
-
function TimelineWaveform(_ref3) {
|
|
553
|
-
var className = _ref3.className,
|
|
554
|
-
waveform = _ref3.waveform,
|
|
555
|
-
propStart = _ref3.start,
|
|
556
|
-
propEnd = _ref3.end,
|
|
557
|
-
propPerspective = _ref3.perspective,
|
|
558
|
-
StageProps = _ref3.StageProps,
|
|
559
|
-
LayerProps = _ref3.LayerProps,
|
|
560
|
-
RectProps = _ref3.RectProps,
|
|
561
|
-
WaveRectProps = _ref3.WaveRectProps,
|
|
562
|
-
props = _objectWithoutProperties(_ref3, _excluded2$3);
|
|
563
|
-
var _ref4 = useTimeline() || {
|
|
564
|
-
start: propStart,
|
|
565
|
-
end: propEnd,
|
|
566
|
-
perspective: propPerspective
|
|
567
|
-
},
|
|
568
|
-
start = _ref4.start,
|
|
569
|
-
end = _ref4.end,
|
|
570
|
-
perspective = _ref4.perspective;
|
|
571
|
-
if (start === undefined || end === undefined || perspective === undefined) {
|
|
572
|
-
vLog.error('VdtTimelineWaveform', "missing 'start', 'end' or 'perspective' props. If the component is used outside a VdtTimelineContext, 'start', 'end' or 'perspective' must be passed explicitly");
|
|
573
|
-
}
|
|
574
|
-
var ref = useRef();
|
|
575
|
-
var _useResizeObserver = useResizeObserver(ref),
|
|
576
|
-
_useResizeObserver$wi = _useResizeObserver.width,
|
|
577
|
-
width = _useResizeObserver$wi === void 0 ? 0 : _useResizeObserver$wi,
|
|
578
|
-
_useResizeObserver$he = _useResizeObserver.height,
|
|
579
|
-
height = _useResizeObserver$he === void 0 ? 0 : _useResizeObserver$he;
|
|
580
|
-
var amplitudeSegments = useMemo(function () {
|
|
581
|
-
return waveform.map(function (amplitude, i) {
|
|
582
|
-
return {
|
|
583
|
-
amplitude: amplitude,
|
|
584
|
-
start: interpolate(start, end, 0, waveform.length - 1, i),
|
|
585
|
-
end: interpolate(start, end, 0, waveform.length - 1, i + 1)
|
|
586
|
-
};
|
|
587
|
-
});
|
|
588
|
-
}, [waveform, start, end]);
|
|
589
|
-
var pxPerTimeUnit = width / (end - start);
|
|
590
|
-
var scaleX = (end - start) / (perspective.end - perspective.start);
|
|
591
|
-
var offsetX = interpolate(0, scaleX * width, start, end, perspective.start);
|
|
592
|
-
return /*#__PURE__*/jsx("div", _objectSpread$7(_objectSpread$7({
|
|
593
|
-
ref: ref,
|
|
594
|
-
className: clsx('VdtTimelineWaveform-root', className)
|
|
595
|
-
}, props), {}, {
|
|
596
|
-
children: /*#__PURE__*/jsx(Stage, _objectSpread$7(_objectSpread$7({
|
|
597
|
-
height: height,
|
|
598
|
-
width: width,
|
|
599
|
-
x: -offsetX,
|
|
600
|
-
scaleX: scaleX
|
|
601
|
-
}, StageProps), {}, {
|
|
602
|
-
children: /*#__PURE__*/jsxs(Layer, _objectSpread$7(_objectSpread$7({
|
|
603
|
-
listening: false
|
|
604
|
-
}, LayerProps), {}, {
|
|
605
|
-
children: [/*#__PURE__*/jsx(Rect, _objectSpread$7({
|
|
606
|
-
x: 0,
|
|
607
|
-
y: 0,
|
|
608
|
-
width: width,
|
|
609
|
-
height: height
|
|
610
|
-
}, RectProps)), /*#__PURE__*/jsx(TimelineWaveFormRects, _objectSpread$7({
|
|
611
|
-
amplitudeSegments: amplitudeSegments,
|
|
612
|
-
pxPerTimeUnit: pxPerTimeUnit,
|
|
613
|
-
start: start,
|
|
614
|
-
height: height
|
|
615
|
-
}, WaveRectProps))]
|
|
616
|
-
}))
|
|
617
|
-
}))
|
|
618
|
-
}));
|
|
619
|
-
}
|
|
620
|
-
TimelineWaveform.propTypes = {
|
|
621
|
-
/**
|
|
622
|
-
* Array of integers to form the wave.
|
|
623
|
-
*/
|
|
624
|
-
waveform: PropTypes.arrayOf(PropTypes.number),
|
|
625
|
-
/**
|
|
626
|
-
* Set starting point of the waveform. The value provided is the value of the respective data point in passed data.
|
|
627
|
-
*/
|
|
628
|
-
start: PropTypes.number,
|
|
629
|
-
/**
|
|
630
|
-
* Set ending point of the waveform. The value provided is the value of the respective data point in passed data.
|
|
631
|
-
*/
|
|
632
|
-
end: PropTypes.number,
|
|
633
|
-
/**
|
|
634
|
-
* Zoom level when looking at waveform.
|
|
635
|
-
*/
|
|
636
|
-
perspective: PropTypes.shape({
|
|
637
|
-
start: PropTypes.number,
|
|
638
|
-
end: PropTypes.number
|
|
639
|
-
}),
|
|
640
|
-
/**
|
|
641
|
-
* Props for Stage component. For more information: https://konvajs.org/api/Konva.Stage.html
|
|
642
|
-
*/
|
|
643
|
-
StageProps: PropTypes.instanceOf(Object),
|
|
644
|
-
/**
|
|
645
|
-
* Props for Stage component. For more information: https://konvajs.org/api/Konva.Layer.html
|
|
646
|
-
*/
|
|
647
|
-
LayerProps: PropTypes.instanceOf(Object),
|
|
648
|
-
/**
|
|
649
|
-
* Props for Stage component. For more information: https://konvajs.org/api/Konva.Rect.html
|
|
650
|
-
*/
|
|
651
|
-
RectProps: PropTypes.instanceOf(Object),
|
|
652
|
-
/**
|
|
653
|
-
* Props for Stage component. For more information: https://konvajs.org/api/Konva.Rect.html
|
|
654
|
-
*/
|
|
655
|
-
WaveRectProps: PropTypes.instanceOf(Object),
|
|
656
|
-
/**
|
|
657
|
-
* Override styles with className
|
|
658
|
-
*/
|
|
659
|
-
className: PropTypes.string
|
|
660
|
-
};
|
|
661
|
-
TimelineWaveform.defaultProps = {
|
|
662
|
-
waveform: [],
|
|
663
|
-
start: undefined,
|
|
664
|
-
end: undefined,
|
|
665
|
-
perspective: undefined,
|
|
666
|
-
StageProps: {},
|
|
667
|
-
LayerProps: {},
|
|
668
|
-
RectProps: {},
|
|
669
|
-
WaveRectProps: {},
|
|
670
|
-
className: undefined
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
function useHover() {
|
|
674
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
675
|
-
_ref$hoverEffect = _ref.hoverEffect,
|
|
676
|
-
hoverEffect = _ref$hoverEffect === void 0 ? function () {} : _ref$hoverEffect;
|
|
677
|
-
var _useState = useState(false),
|
|
678
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
679
|
-
isHovering = _useState2[0],
|
|
680
|
-
setIsHovering = _useState2[1];
|
|
681
|
-
var cleanupHover = useRef(null);
|
|
682
|
-
return {
|
|
683
|
-
isHovering: isHovering,
|
|
684
|
-
onMouseEnter: function onMouseEnter(e) {
|
|
685
|
-
setIsHovering(true);
|
|
686
|
-
cleanupHover.current = hoverEffect(e);
|
|
687
|
-
},
|
|
688
|
-
onMouseLeave: function onMouseLeave() {
|
|
689
|
-
setIsHovering(false);
|
|
690
|
-
if (cleanupHover.current) {
|
|
691
|
-
cleanupHover.current();
|
|
692
|
-
}
|
|
693
|
-
cleanupHover.current = null;
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
var _excluded$6 = ["onClick", "x", "width", "y", "height", "padding", "start", "end", "onHover", "onMove", "onMoveStart", "onMoveEnd", "onResize", "onResizeStart", "onResizeEnd"],
|
|
699
|
-
_excluded2$2 = ["isHovering"],
|
|
700
|
-
_excluded3 = ["isHovering"];
|
|
701
|
-
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
702
|
-
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
703
|
-
var _getStyleProperties$2 = getStyleProperties('--vdt-timeline-palette-primary', '--vdt-timeline-palette-primary-dark'),
|
|
704
|
-
_getStyleProperties2$2 = _slicedToArray(_getStyleProperties$2, 2),
|
|
705
|
-
palettePrimary = _getStyleProperties2$2[0],
|
|
706
|
-
palettePrimaryDark = _getStyleProperties2$2[1];
|
|
707
|
-
var EVENT_RESIZER_THUMB_WIDTH = 5;
|
|
708
|
-
function TimelineEvent(_ref) {
|
|
709
|
-
var onClick = _ref.onClick,
|
|
710
|
-
x = _ref.x,
|
|
711
|
-
width = _ref.width,
|
|
712
|
-
y = _ref.y,
|
|
713
|
-
height = _ref.height,
|
|
714
|
-
padding = _ref.padding,
|
|
715
|
-
start = _ref.start,
|
|
716
|
-
end = _ref.end,
|
|
717
|
-
onHover = _ref.onHover,
|
|
718
|
-
onMove = _ref.onMove,
|
|
719
|
-
onMoveStart = _ref.onMoveStart,
|
|
720
|
-
onMoveEnd = _ref.onMoveEnd,
|
|
721
|
-
onResize = _ref.onResize,
|
|
722
|
-
onResizeStart = _ref.onResizeStart,
|
|
723
|
-
onResizeEnd = _ref.onResizeEnd,
|
|
724
|
-
props = _objectWithoutProperties(_ref, _excluded$6);
|
|
725
|
-
if ([x, width, y, height].some(function (v) {
|
|
726
|
-
return v === undefined;
|
|
727
|
-
})) {
|
|
728
|
-
vLog.error('VdtTimelineEvent', "missing 'x', 'width', 'y', or 'height' props. If the component is not used as a direct child of VdtTimelineTrack, 'x', 'width', 'y', or 'height' must be passed explicitly");
|
|
729
|
-
}
|
|
730
|
-
var eventRef = useRef();
|
|
731
|
-
var _useHover = useHover({
|
|
732
|
-
hoverEffect: function hoverEffect(e) {
|
|
733
|
-
if (onHover) onHover(e, true);
|
|
734
|
-
return function () {
|
|
735
|
-
if (onHover) onHover(e, false);
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
}),
|
|
739
|
-
isHovering = _useHover.isHovering,
|
|
740
|
-
hoverProps = _objectWithoutProperties(_useHover, _excluded2$2);
|
|
741
|
-
var _useHover2 = useHover({
|
|
742
|
-
hoverEffect: function hoverEffect(e) {
|
|
743
|
-
if (onResize) {
|
|
744
|
-
e.target.getStage().container().style.cursor = 'col-resize';
|
|
745
|
-
}
|
|
746
|
-
return function () {
|
|
747
|
-
if (onResize) {
|
|
748
|
-
e.target.getStage().container().style.cursor = 'default';
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
}),
|
|
753
|
-
isHoveringResize = _useHover2.isHovering,
|
|
754
|
-
resizeHoverProps = _objectWithoutProperties(_useHover2, _excluded3);
|
|
755
|
-
var _useState = useState(false),
|
|
756
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
757
|
-
isMoving = _useState2[0],
|
|
758
|
-
setIsMoving = _useState2[1];
|
|
759
|
-
var hasOnClick = !!onClick;
|
|
760
|
-
useEffect(function () {
|
|
761
|
-
if (eventRef.current) {
|
|
762
|
-
var cursor = function () {
|
|
763
|
-
if (isMoving) return 'grabbing';
|
|
764
|
-
if (isHovering && hasOnClick) return 'pointer';
|
|
765
|
-
return 'default';
|
|
766
|
-
}();
|
|
767
|
-
eventRef.current.getStage().container().style.cursor = cursor;
|
|
768
|
-
}
|
|
769
|
-
}, [isMoving, isHovering, hasOnClick]);
|
|
770
|
-
var paddedY = y + padding;
|
|
771
|
-
var paddedHeight = height - 2 * padding;
|
|
772
|
-
var posProps = {
|
|
773
|
-
y: paddedY,
|
|
774
|
-
height: paddedHeight,
|
|
775
|
-
x: x,
|
|
776
|
-
width: width
|
|
777
|
-
};
|
|
778
|
-
var defaultHoverProps = isHovering || isHoveringResize ? {
|
|
779
|
-
fill: palettePrimaryDark
|
|
780
|
-
} : {};
|
|
781
|
-
var resizerProps = function resizerProps(which) {
|
|
782
|
-
var resizerX = which === 'start' ? x : x + width - EVENT_RESIZER_THUMB_WIDTH;
|
|
783
|
-
return {
|
|
784
|
-
onDragStart: function onDragStart() {
|
|
785
|
-
if (!onResizeStart) return;
|
|
786
|
-
onResizeStart(which);
|
|
787
|
-
},
|
|
788
|
-
draggable: !!onResize,
|
|
789
|
-
dragBoundFunc: function dragBoundFunc(pos) {
|
|
790
|
-
return {
|
|
791
|
-
x: pos.x,
|
|
792
|
-
y: paddedY
|
|
793
|
-
};
|
|
794
|
-
},
|
|
795
|
-
onDragEnd: function onDragEnd() {
|
|
796
|
-
if (!onResizeEnd) return;
|
|
797
|
-
onResizeEnd(which);
|
|
798
|
-
},
|
|
799
|
-
width: EVENT_RESIZER_THUMB_WIDTH,
|
|
800
|
-
x: resizerX,
|
|
801
|
-
onDragMove: function onDragMove(e) {
|
|
802
|
-
if (!onResize) return;
|
|
803
|
-
var _e$target$position = e.target.position(),
|
|
804
|
-
newX = _e$target$position.x;
|
|
805
|
-
e.target.x(resizerX);
|
|
806
|
-
var newPos = Math.floor(interpolate(start, end, x, x + width, newX + (which === 'start' ? 0 : EVENT_RESIZER_THUMB_WIDTH)));
|
|
807
|
-
onResize(e, which, newPos);
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
|
-
};
|
|
811
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
812
|
-
children: [/*#__PURE__*/jsx(Rect, _objectSpread$6(_objectSpread$6(_objectSpread$6(_objectSpread$6({
|
|
813
|
-
ref: eventRef,
|
|
814
|
-
draggable: !!onMove,
|
|
815
|
-
dragBoundFunc: function dragBoundFunc(pos) {
|
|
816
|
-
return {
|
|
817
|
-
x: pos.x,
|
|
818
|
-
y: paddedY
|
|
819
|
-
};
|
|
820
|
-
},
|
|
821
|
-
onDragStart: function onDragStart(e) {
|
|
822
|
-
if (!onMove) return;
|
|
823
|
-
setIsMoving(true);
|
|
824
|
-
if (onMoveStart) {
|
|
825
|
-
onMoveStart(e);
|
|
826
|
-
}
|
|
827
|
-
},
|
|
828
|
-
onDragEnd: function onDragEnd(e) {
|
|
829
|
-
if (!onMove) return;
|
|
830
|
-
setIsMoving(false);
|
|
831
|
-
if (onMoveEnd) {
|
|
832
|
-
onMoveEnd(e);
|
|
833
|
-
}
|
|
834
|
-
},
|
|
835
|
-
onDragMove: function onDragMove(e) {
|
|
836
|
-
if (!onMove) return;
|
|
837
|
-
var _e$target$position2 = e.target.position(),
|
|
838
|
-
newX = _e$target$position2.x;
|
|
839
|
-
e.target.x(x);
|
|
840
|
-
var newStart = Math.floor(interpolate(start, end, x, x + width, newX));
|
|
841
|
-
onMove(e, newStart);
|
|
842
|
-
},
|
|
843
|
-
fill: palettePrimary,
|
|
844
|
-
onClick: onClick
|
|
845
|
-
}, posProps), defaultHoverProps), hoverProps), props)), /*#__PURE__*/jsx(Rect, _objectSpread$6(_objectSpread$6(_objectSpread$6({}, posProps), resizeHoverProps), resizerProps('start'))), /*#__PURE__*/jsx(Rect, _objectSpread$6(_objectSpread$6(_objectSpread$6({}, posProps), resizeHoverProps), resizerProps('end')))]
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
TimelineEvent.propTypes = {
|
|
849
|
-
/**
|
|
850
|
-
* Callback to trigger on clicking on timeline event component.
|
|
851
|
-
*/
|
|
852
|
-
onClick: PropTypes.func,
|
|
853
|
-
/**
|
|
854
|
-
* Callback to trigger on hovering over timeline event component.
|
|
855
|
-
*/
|
|
856
|
-
onHover: PropTypes.func,
|
|
857
|
-
/**
|
|
858
|
-
* Callback to trigger on moving a timeline event component (when mousedown and dragging).
|
|
859
|
-
*/
|
|
860
|
-
onMove: PropTypes.func,
|
|
861
|
-
/**
|
|
862
|
-
* Callback to trigger on moving a timeline event component only when mousedown and dragging.
|
|
863
|
-
*/
|
|
864
|
-
onMoveStart: PropTypes.func,
|
|
865
|
-
/**
|
|
866
|
-
* Callback to trigger on moving a timeline event component only when mouseup and not dragging.
|
|
867
|
-
*/
|
|
868
|
-
onMoveEnd: PropTypes.func,
|
|
869
|
-
/**
|
|
870
|
-
* Callback to trigger on resizing a timeline event component.
|
|
871
|
-
*/
|
|
872
|
-
onResize: PropTypes.func,
|
|
873
|
-
/**
|
|
874
|
-
* Callback to trigger on resizing a timeline event component only when mousedown and dragging.
|
|
875
|
-
*/
|
|
876
|
-
onResizeStart: PropTypes.func,
|
|
877
|
-
/**
|
|
878
|
-
* Callback to trigger on resizing a timeline event component only when mouseup and not dragging.
|
|
879
|
-
*/
|
|
880
|
-
onResizeEnd: PropTypes.func,
|
|
881
|
-
/**
|
|
882
|
-
* Position of event bar in x-axis (px)
|
|
883
|
-
*/
|
|
884
|
-
x: PropTypes.number,
|
|
885
|
-
/**
|
|
886
|
-
* Width of event bar in px
|
|
887
|
-
*/
|
|
888
|
-
width: PropTypes.number,
|
|
889
|
-
/**
|
|
890
|
-
* Position of event bar in y-axis (px)
|
|
891
|
-
*/
|
|
892
|
-
y: PropTypes.number,
|
|
893
|
-
/**
|
|
894
|
-
* Height of event bar in px
|
|
895
|
-
*/
|
|
896
|
-
height: PropTypes.number,
|
|
897
|
-
/**
|
|
898
|
-
* Padding of event bar in px
|
|
899
|
-
*/
|
|
900
|
-
padding: PropTypes.number,
|
|
901
|
-
/**
|
|
902
|
-
* Start of timeline event
|
|
903
|
-
*/
|
|
904
|
-
start: PropTypes.number.isRequired,
|
|
905
|
-
/**
|
|
906
|
-
* End of timeline event
|
|
907
|
-
*/
|
|
908
|
-
end: PropTypes.number.isRequired,
|
|
909
|
-
/**
|
|
910
|
-
* Override styles with className
|
|
911
|
-
*/
|
|
912
|
-
className: PropTypes.string
|
|
913
|
-
};
|
|
914
|
-
TimelineEvent.defaultProps = {
|
|
915
|
-
onClick: undefined,
|
|
916
|
-
onHover: undefined,
|
|
917
|
-
onMove: undefined,
|
|
918
|
-
onMoveStart: undefined,
|
|
919
|
-
onMoveEnd: undefined,
|
|
920
|
-
onResize: undefined,
|
|
921
|
-
onResizeStart: undefined,
|
|
922
|
-
onResizeEnd: undefined,
|
|
923
|
-
x: undefined,
|
|
924
|
-
width: undefined,
|
|
925
|
-
y: 0,
|
|
926
|
-
height: DEFAULT_EVENT_HEIGHT,
|
|
927
|
-
padding: 1,
|
|
928
|
-
className: undefined
|
|
929
|
-
};
|
|
930
|
-
|
|
931
|
-
var _excluded$5 = ["className", "children", "perspective", "onClick", "style", "onHover", "StageProps", "LayerProps", "GroupProps", "RectProps"],
|
|
932
|
-
_excluded2$1 = ["isHovering"];
|
|
933
|
-
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
934
|
-
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
935
|
-
function TimelineTrack(_ref) {
|
|
936
|
-
var className = _ref.className,
|
|
937
|
-
children = _ref.children,
|
|
938
|
-
propPerspective = _ref.perspective,
|
|
939
|
-
onClick = _ref.onClick,
|
|
940
|
-
style = _ref.style,
|
|
941
|
-
onHover = _ref.onHover,
|
|
942
|
-
StageProps = _ref.StageProps,
|
|
943
|
-
LayerProps = _ref.LayerProps,
|
|
944
|
-
GroupProps = _ref.GroupProps,
|
|
945
|
-
RectProps = _ref.RectProps,
|
|
946
|
-
props = _objectWithoutProperties(_ref, _excluded$5);
|
|
947
|
-
var _ref2 = useTimeline() || {
|
|
948
|
-
perspective: propPerspective
|
|
949
|
-
},
|
|
950
|
-
perspective = _ref2.perspective;
|
|
951
|
-
if (perspective === undefined) {
|
|
952
|
-
vLog.error('VdtTimelineTrack', "missing 'perspective' prop. If the component is used outside a VdtTimelineContext, 'perspective' must be passed explicitly");
|
|
953
|
-
}
|
|
954
|
-
var visibleChildren = Children.toArray(children).filter(function (_ref3) {
|
|
955
|
-
var _ref3$props = _ref3.props,
|
|
956
|
-
childProps = _ref3$props === void 0 ? {} : _ref3$props;
|
|
957
|
-
var isOutsidePerspective = childProps.start > perspective.end || childProps.end < perspective.start;
|
|
958
|
-
return !isOutsidePerspective;
|
|
959
|
-
});
|
|
960
|
-
var eventsContainerRef = useRef();
|
|
961
|
-
var _useResizeObserver = useResizeObserver(eventsContainerRef),
|
|
962
|
-
_useResizeObserver$wi = _useResizeObserver.width,
|
|
963
|
-
eventContainerWidth = _useResizeObserver$wi === void 0 ? 0 : _useResizeObserver$wi,
|
|
964
|
-
_useResizeObserver$he = _useResizeObserver.height,
|
|
965
|
-
eventContainerHeight = _useResizeObserver$he === void 0 ? 0 : _useResizeObserver$he;
|
|
966
|
-
|
|
967
|
-
// expect children to be passed 'y' and 'height' props so that we can calculate the track height
|
|
968
|
-
var eventsContainerHeight = Math.max.apply(Math, _toConsumableArray(Children.map(children, function (_ref4) {
|
|
969
|
-
var _ref4$props = _ref4.props;
|
|
970
|
-
_ref4$props = _ref4$props === void 0 ? {} : _ref4$props;
|
|
971
|
-
var _ref4$props$y = _ref4$props.y,
|
|
972
|
-
y = _ref4$props$y === void 0 ? 0 : _ref4$props$y,
|
|
973
|
-
_ref4$props$height = _ref4$props.height,
|
|
974
|
-
height = _ref4$props$height === void 0 ? 0 : _ref4$props$height;
|
|
975
|
-
return y + height;
|
|
976
|
-
}))) || DEFAULT_EVENT_HEIGHT;
|
|
977
|
-
var cloneChild = function cloneChild(child) {
|
|
978
|
-
var _ref5 = child.props || {},
|
|
979
|
-
childStart = _ref5.start,
|
|
980
|
-
childEnd = _ref5.end;
|
|
981
|
-
var xProps = function () {
|
|
982
|
-
if (childStart !== undefined && childEnd !== undefined) {
|
|
983
|
-
var childX = interpolate(0, eventContainerWidth, perspective.start, perspective.end, childStart);
|
|
984
|
-
var childWidth = interpolate(0, eventContainerWidth, perspective.start, perspective.end, childEnd) - childX;
|
|
985
|
-
return {
|
|
986
|
-
x: childX,
|
|
987
|
-
width: childWidth
|
|
988
|
-
};
|
|
989
|
-
}
|
|
990
|
-
return {};
|
|
991
|
-
}();
|
|
992
|
-
return /*#__PURE__*/cloneElement(child, _objectSpread$5(_objectSpread$5({}, child.props), xProps));
|
|
993
|
-
};
|
|
994
|
-
var _useHover = useHover({
|
|
995
|
-
hoverEffect: function hoverEffect(e) {
|
|
996
|
-
if (onHover) onHover(e, true);
|
|
997
|
-
var container = e.target.getStage().container();
|
|
998
|
-
if (onClick) {
|
|
999
|
-
container.style.cursor = 'pointer';
|
|
1000
|
-
}
|
|
1001
|
-
return function () {
|
|
1002
|
-
if (onHover) onHover(e, false);
|
|
1003
|
-
if (onClick) {
|
|
1004
|
-
container.style.cursor = 'default';
|
|
1005
|
-
}
|
|
1006
|
-
};
|
|
1007
|
-
}
|
|
1008
|
-
});
|
|
1009
|
-
_useHover.isHovering;
|
|
1010
|
-
var hoverProps = _objectWithoutProperties(_useHover, _excluded2$1);
|
|
1011
|
-
return /*#__PURE__*/jsx("div", _objectSpread$5(_objectSpread$5({
|
|
1012
|
-
ref: eventsContainerRef,
|
|
1013
|
-
className: clsx('VdtTimelineTrack-root', className),
|
|
1014
|
-
style: _objectSpread$5({
|
|
1015
|
-
height: eventsContainerHeight
|
|
1016
|
-
}, style)
|
|
1017
|
-
}, props), {}, {
|
|
1018
|
-
children: /*#__PURE__*/jsx(Stage, _objectSpread$5(_objectSpread$5({
|
|
1019
|
-
height: eventContainerHeight,
|
|
1020
|
-
width: eventContainerWidth
|
|
1021
|
-
}, StageProps), {}, {
|
|
1022
|
-
children: /*#__PURE__*/jsx(Layer, _objectSpread$5(_objectSpread$5({}, LayerProps), {}, {
|
|
1023
|
-
children: /*#__PURE__*/jsxs(Group, _objectSpread$5(_objectSpread$5({}, GroupProps), {}, {
|
|
1024
|
-
children: [/*#__PURE__*/jsx(Rect, _objectSpread$5(_objectSpread$5({
|
|
1025
|
-
x: 0,
|
|
1026
|
-
y: 0,
|
|
1027
|
-
width: eventContainerWidth,
|
|
1028
|
-
height: eventContainerHeight,
|
|
1029
|
-
onClick: onClick
|
|
1030
|
-
}, hoverProps), RectProps)), Children.map(visibleChildren, cloneChild)]
|
|
1031
|
-
}))
|
|
1032
|
-
}))
|
|
1033
|
-
}))
|
|
1034
|
-
}));
|
|
1035
|
-
}
|
|
1036
|
-
TimelineTrack.propTypes = {
|
|
1037
|
-
/**
|
|
1038
|
-
* children are positioned within the track according to 'start' and 'end' props passed to them
|
|
1039
|
-
*/
|
|
1040
|
-
// children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
1041
|
-
children: function children(props, propName, componentName) {
|
|
1042
|
-
var prop = props[propName];
|
|
1043
|
-
var err;
|
|
1044
|
-
Children.forEach(prop, function (child) {
|
|
1045
|
-
var _child$props = child.props;
|
|
1046
|
-
_child$props = _child$props === void 0 ? {} : _child$props;
|
|
1047
|
-
var start = _child$props.start,
|
|
1048
|
-
end = _child$props.end;
|
|
1049
|
-
if (start === undefined || end === undefined) {
|
|
1050
|
-
err = new Error("children of ".concat(componentName, " must be passed a 'start' and 'end' prop. These props are used to position the child within the track."));
|
|
1051
|
-
}
|
|
1052
|
-
});
|
|
1053
|
-
return err;
|
|
1054
|
-
},
|
|
1055
|
-
/**
|
|
1056
|
-
* Start and end of timeline scroll, unzoomed
|
|
1057
|
-
*/
|
|
1058
|
-
perspective: PropTypes.shape({
|
|
1059
|
-
start: PropTypes.number,
|
|
1060
|
-
end: PropTypes.number
|
|
1061
|
-
}),
|
|
1062
|
-
/**
|
|
1063
|
-
* Callback to trigger on timeline track component click.
|
|
1064
|
-
*/
|
|
1065
|
-
onClick: PropTypes.func,
|
|
1066
|
-
/**
|
|
1067
|
-
* Callback to trigger on mouse hover over timeline track component.
|
|
1068
|
-
*/
|
|
1069
|
-
onHover: PropTypes.func,
|
|
1070
|
-
/**
|
|
1071
|
-
* Props for Stage component. For more information: https://konvajs.org/api/Konva.Stage.html
|
|
1072
|
-
*/
|
|
1073
|
-
StageProps: PropTypes.instanceOf(Object),
|
|
1074
|
-
/**
|
|
1075
|
-
* Props for Layer component. For more information: https://konvajs.org/api/Konva.Layer.html
|
|
1076
|
-
*/
|
|
1077
|
-
LayerProps: PropTypes.instanceOf(Object),
|
|
1078
|
-
/**
|
|
1079
|
-
* Props for Group component. For more information: https://konvajs.org/api/Konva.Group.html
|
|
1080
|
-
*/
|
|
1081
|
-
GroupProps: PropTypes.instanceOf(Object),
|
|
1082
|
-
/**
|
|
1083
|
-
* Props for Rect component. For more information: https://konvajs.org/api/Konva.Rect.html
|
|
1084
|
-
*/
|
|
1085
|
-
RectProps: PropTypes.instanceOf(Object),
|
|
1086
|
-
/**
|
|
1087
|
-
* Override styles with className
|
|
1088
|
-
*/
|
|
1089
|
-
className: PropTypes.string,
|
|
1090
|
-
/**
|
|
1091
|
-
* Apply inline CSS styling
|
|
1092
|
-
*/
|
|
1093
|
-
style: PropTypes.instanceOf(Object)
|
|
1094
|
-
};
|
|
1095
|
-
TimelineTrack.defaultProps = {
|
|
1096
|
-
style: {},
|
|
1097
|
-
children: undefined,
|
|
1098
|
-
perspective: undefined,
|
|
1099
|
-
onClick: undefined,
|
|
1100
|
-
onHover: undefined,
|
|
1101
|
-
StageProps: {},
|
|
1102
|
-
LayerProps: {},
|
|
1103
|
-
GroupProps: {},
|
|
1104
|
-
RectProps: {},
|
|
1105
|
-
className: undefined
|
|
1106
|
-
};
|
|
1107
|
-
|
|
1108
|
-
var css$3 = ":root {\n --vdt-timeline-palette-primary:#49a6dd;\n --vdt-timeline-palette-primary-dark: #3c8bb8;\n --vdt-timeline-palette-secondary:#f50057;\n --vdt-timeline-palette-background-primary:#20232a;\n --vdt-timeline-palette-background-secondary:#282c34;\n --vdt-timeline-palette-background-hover: rgba(255, 255, 255, 0.08);\n --vdt-timeline-palette-text-primary:#fff;\n --vdt-timeline-palette-text-secondary:rgba(255, 255, 255, 0.7);\n}\n\n.VdtTimelineRow-root {\n display: flex;\n}\n\n.VdtTimelineRow-root.VdtTimelineRow-hasLabel:hover {\n background-color: var(--vdt-timeline-palette-background-hover);\n}\n\n.VdtTimelineRow-root.VdtTimelineRow-hasLabel {\n border-width: 2px 0 0 0;\n border-style: solid;\n border-color: var(--vdt-timeline-palette-background-secondary);\n}\n\n.VdtTimelineRow-root.VdtTimelineRow-hasLabel > :first-child {\n width: 98px;\n border-width: 0 2px 0 0;\n border-style: solid;\n border-color: var(--vdt-timeline-palette-background-secondary);\n}\n\n.VdtTimelineRow-root > :not(.VdtTimelineRow-label) {\n flex-grow: 1;\n margin: 4px 0;\n}\n\n.VdtTimelineRow-root:not(.VdtTimelineRow-hasLabel) > :first-child {\n margin-left: 100px;\n}\n\n.VdtTimelineRow-label {\n display: flex;\n align-items: center;\n flex-basis: 98px;\n}\n\n.VdtTimelineRow-labelText {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n text-align: center;\n padding: 0 8px;\n}";
|
|
1109
|
-
n(css$3,{});
|
|
1110
|
-
|
|
1111
|
-
var _excluded$4 = ["className", "children", "label", "LabelProps", "LabelTextProps"];
|
|
1112
|
-
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1113
|
-
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1114
|
-
function TimelineRow(_ref) {
|
|
1115
|
-
var className = _ref.className,
|
|
1116
|
-
children = _ref.children,
|
|
1117
|
-
label = _ref.label,
|
|
1118
|
-
LabelProps = _ref.LabelProps,
|
|
1119
|
-
LabelTextProps = _ref.LabelTextProps,
|
|
1120
|
-
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
1121
|
-
return /*#__PURE__*/jsxs("div", _objectSpread$4(_objectSpread$4({
|
|
1122
|
-
className: clsx('VdtTimelineRow-root', className, {
|
|
1123
|
-
'VdtTimelineRow-hasLabel': !!label
|
|
1124
|
-
})
|
|
1125
|
-
}, props), {}, {
|
|
1126
|
-
children: [label && /*#__PURE__*/jsx("div", _objectSpread$4(_objectSpread$4({
|
|
1127
|
-
className: "VdtTimelineRow-label"
|
|
1128
|
-
}, LabelProps), {}, {
|
|
1129
|
-
children: /*#__PURE__*/jsx("span", _objectSpread$4(_objectSpread$4({
|
|
1130
|
-
className: "VdtTimelineRow-labelText"
|
|
1131
|
-
}, LabelTextProps), {}, {
|
|
1132
|
-
children: label
|
|
1133
|
-
}))
|
|
1134
|
-
})), children]
|
|
1135
|
-
}));
|
|
1136
|
-
}
|
|
1137
|
-
TimelineRow.propTypes = {
|
|
1138
|
-
/**
|
|
1139
|
-
* Children components to render inside row content container.
|
|
1140
|
-
*/
|
|
1141
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
1142
|
-
/**
|
|
1143
|
-
* Custom row label
|
|
1144
|
-
*/
|
|
1145
|
-
label: PropTypes.node,
|
|
1146
|
-
/**
|
|
1147
|
-
* Props for Layer component. For more information: https://konvajs.org/api/Konva.Label.html
|
|
1148
|
-
*/
|
|
1149
|
-
LabelProps: PropTypes.instanceOf(Object),
|
|
1150
|
-
/**
|
|
1151
|
-
* Props for Layer component. For more information: https://konvajs.org/api/Konva.Label.html
|
|
1152
|
-
*/
|
|
1153
|
-
LabelTextProps: PropTypes.instanceOf(Object),
|
|
1154
|
-
/**
|
|
1155
|
-
* Override styles with className
|
|
1156
|
-
*/
|
|
1157
|
-
className: PropTypes.string,
|
|
1158
|
-
/**
|
|
1159
|
-
* Apply inline CSS styling
|
|
1160
|
-
*/
|
|
1161
|
-
style: PropTypes.instanceOf(Object)
|
|
1162
|
-
};
|
|
1163
|
-
TimelineRow.defaultProps = {
|
|
1164
|
-
children: undefined,
|
|
1165
|
-
label: undefined,
|
|
1166
|
-
LabelProps: {},
|
|
1167
|
-
LabelTextProps: {},
|
|
1168
|
-
className: undefined,
|
|
1169
|
-
style: {}
|
|
1170
|
-
};
|
|
1171
|
-
|
|
1172
|
-
var css$2 = "\n.VdtTimelinePlayheadTrack-root {\n height: 40px;\n position: relative;\n}";
|
|
1173
|
-
n(css$2,{});
|
|
1174
|
-
|
|
1175
|
-
var _excluded$3 = ["className", "children", "ticks", "onClick", "onHover", "onWheel", "onDrag", "start", "end", "perspective", "timelineRef", "StageProps", "LayerProps", "GroupProps", "RectProps", "TickGroupProps", "TickTextProps", "TickLineProps"],
|
|
1176
|
-
_excluded2 = ["isHovering"];
|
|
1177
|
-
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1178
|
-
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1179
|
-
var LABEL_EDGE_MARGIN = 2;
|
|
1180
|
-
var _getStyleProperties$1 = getStyleProperties('--vdt-timeline-palette-text-primary', '--vdt-timeline-palette-text-secondary'),
|
|
1181
|
-
_getStyleProperties2$1 = _slicedToArray(_getStyleProperties$1, 2),
|
|
1182
|
-
paletteTextPrimary = _getStyleProperties2$1[0],
|
|
1183
|
-
paletteTextSecondary = _getStyleProperties2$1[1];
|
|
1184
|
-
function TimelineTick(_ref) {
|
|
1185
|
-
var x = _ref.x,
|
|
1186
|
-
y = _ref.y,
|
|
1187
|
-
minX = _ref.minX,
|
|
1188
|
-
maxX = _ref.maxX,
|
|
1189
|
-
label = _ref.label,
|
|
1190
|
-
TickGroupProps = _ref.TickGroupProps,
|
|
1191
|
-
TickTextProps = _ref.TickTextProps,
|
|
1192
|
-
TickLineProps = _ref.TickLineProps;
|
|
1193
|
-
var hasLabel = label !== undefined;
|
|
1194
|
-
var _ref2 = hasLabel ? {
|
|
1195
|
-
color: paletteTextPrimary,
|
|
1196
|
-
tickWidth: 2,
|
|
1197
|
-
tickSize: 8
|
|
1198
|
-
} : {
|
|
1199
|
-
color: paletteTextSecondary,
|
|
1200
|
-
tickWidth: 1,
|
|
1201
|
-
tickSize: 4
|
|
1202
|
-
},
|
|
1203
|
-
color = _ref2.color,
|
|
1204
|
-
tickWidth = _ref2.tickWidth,
|
|
1205
|
-
tickSize = _ref2.tickSize;
|
|
1206
|
-
var _useState = useState(),
|
|
1207
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1208
|
-
labelWidth = _useState2[0],
|
|
1209
|
-
setLabelWidth = _useState2[1];
|
|
1210
|
-
var textRef = useRef();
|
|
1211
|
-
useEffect(function () {
|
|
1212
|
-
if (textRef.current) {
|
|
1213
|
-
setLabelWidth(textRef.current.getTextWidth());
|
|
1214
|
-
}
|
|
1215
|
-
}, []);
|
|
1216
|
-
var textX = clamp(x - labelWidth / 2, minX + LABEL_EDGE_MARGIN, maxX - labelWidth - LABEL_EDGE_MARGIN) || undefined;
|
|
1217
|
-
if (x < minX || x > maxX) {
|
|
1218
|
-
return null;
|
|
1219
|
-
}
|
|
1220
|
-
return /*#__PURE__*/jsxs(Group, _objectSpread$3(_objectSpread$3({}, TickGroupProps), {}, {
|
|
1221
|
-
children: [/*#__PURE__*/jsx(Text, _objectSpread$3({
|
|
1222
|
-
ref: textRef,
|
|
1223
|
-
x: textX,
|
|
1224
|
-
y: y - tickSize - 20,
|
|
1225
|
-
fontFamily: "Helvetica",
|
|
1226
|
-
text: label,
|
|
1227
|
-
fontStyle: "bold",
|
|
1228
|
-
fontSize: 10,
|
|
1229
|
-
fill: color
|
|
1230
|
-
}, TickTextProps)), /*#__PURE__*/jsx(Line, _objectSpread$3({
|
|
1231
|
-
points: [x, y - tickSize, x, y],
|
|
1232
|
-
stroke: color,
|
|
1233
|
-
strokeWidth: tickWidth
|
|
1234
|
-
}, TickLineProps))]
|
|
1235
|
-
}));
|
|
1236
|
-
}
|
|
1237
|
-
function defaultTicks(_ref3) {
|
|
1238
|
-
var width = _ref3.width,
|
|
1239
|
-
perspective = _ref3.perspective;
|
|
1240
|
-
var numTicks = Math.max(Math.floor(width / 90), 2);
|
|
1241
|
-
var labeledTicks = uniq(_toConsumableArray(Array(numTicks).keys()).map(function (i) {
|
|
1242
|
-
return interpolate(perspective.start, perspective.end, 0, numTicks - 1, i);
|
|
1243
|
-
})).map(function (time) {
|
|
1244
|
-
return {
|
|
1245
|
-
time: time,
|
|
1246
|
-
label: String(Math.round(time))
|
|
1247
|
-
};
|
|
1248
|
-
});
|
|
1249
|
-
var unlabeledTicks = mapPairs(labeledTicks, function (curr, next) {
|
|
1250
|
-
var tickDelta = (next.time - curr.time) / 10;
|
|
1251
|
-
return _toConsumableArray(Array(9).keys()).map(function (i) {
|
|
1252
|
-
return {
|
|
1253
|
-
time: curr.time + (i + 1) * tickDelta
|
|
1254
|
-
};
|
|
1255
|
-
});
|
|
1256
|
-
}).flat();
|
|
1257
|
-
return sortBy([].concat(_toConsumableArray(labeledTicks), _toConsumableArray(unlabeledTicks)), ['time']);
|
|
1258
|
-
}
|
|
1259
|
-
function TimelinePlayheadTrack(_ref4) {
|
|
1260
|
-
var _trackContainerRef$cu, _timelineRef$current;
|
|
1261
|
-
var className = _ref4.className,
|
|
1262
|
-
children = _ref4.children,
|
|
1263
|
-
propTicks = _ref4.ticks,
|
|
1264
|
-
onClick = _ref4.onClick,
|
|
1265
|
-
onHover = _ref4.onHover,
|
|
1266
|
-
onWheel = _ref4.onWheel,
|
|
1267
|
-
onDrag = _ref4.onDrag,
|
|
1268
|
-
propStart = _ref4.start,
|
|
1269
|
-
propEnd = _ref4.end,
|
|
1270
|
-
propPerspective = _ref4.perspective,
|
|
1271
|
-
propTimelineRef = _ref4.timelineRef,
|
|
1272
|
-
StageProps = _ref4.StageProps,
|
|
1273
|
-
LayerProps = _ref4.LayerProps,
|
|
1274
|
-
GroupProps = _ref4.GroupProps,
|
|
1275
|
-
RectProps = _ref4.RectProps,
|
|
1276
|
-
TickGroupProps = _ref4.TickGroupProps,
|
|
1277
|
-
TickTextProps = _ref4.TickTextProps,
|
|
1278
|
-
TickLineProps = _ref4.TickLineProps,
|
|
1279
|
-
props = _objectWithoutProperties(_ref4, _excluded$3);
|
|
1280
|
-
var _ref5 = useTimeline() || {
|
|
1281
|
-
start: propStart,
|
|
1282
|
-
end: propEnd,
|
|
1283
|
-
perspective: propPerspective,
|
|
1284
|
-
timelineRef: propTimelineRef
|
|
1285
|
-
},
|
|
1286
|
-
start = _ref5.start,
|
|
1287
|
-
end = _ref5.end,
|
|
1288
|
-
perspective = _ref5.perspective,
|
|
1289
|
-
setPerspective = _ref5.setPerspective,
|
|
1290
|
-
zoom = _ref5.zoom,
|
|
1291
|
-
onChangeTime = _ref5.onChangeTime,
|
|
1292
|
-
timelineRef = _ref5.timelineRef;
|
|
1293
|
-
if (start === undefined || end === undefined || perspective === undefined) {
|
|
1294
|
-
vLog.error('VdtTimelinePlayheadTrack', "missing 'start', 'end' or 'perspective' props. If the component is used outside a VdtTimelineContext, 'start', 'end' and 'perspective' must be passed explicitly");
|
|
1295
|
-
}
|
|
1296
|
-
if (timelineRef === undefined && (children === null || children === void 0 ? void 0 : children.length) > 0) {
|
|
1297
|
-
vLog.warn('VdtTimelinePlayheadTrack', "missing 'timelineRef' prop. This ref is used to set the height of the playhead within the timeline.");
|
|
1298
|
-
}
|
|
1299
|
-
var handleWheel = onWheel || zoom && function (e) {
|
|
1300
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1301
|
-
args[_key - 1] = arguments[_key];
|
|
1302
|
-
}
|
|
1303
|
-
return zoom.apply(void 0, args);
|
|
1304
|
-
};
|
|
1305
|
-
var handleClick = onClick || onChangeTime && function (e) {
|
|
1306
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1307
|
-
args[_key2 - 1] = arguments[_key2];
|
|
1308
|
-
}
|
|
1309
|
-
return onChangeTime.apply(void 0, args);
|
|
1310
|
-
};
|
|
1311
|
-
var handleDrag = onDrag || setPerspective && function (e) {
|
|
1312
|
-
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
1313
|
-
args[_key3 - 1] = arguments[_key3];
|
|
1314
|
-
}
|
|
1315
|
-
return setPerspective.apply(void 0, args);
|
|
1316
|
-
};
|
|
1317
|
-
var trackContainerRef = useRef();
|
|
1318
|
-
var _useResizeObserver = useResizeObserver(trackContainerRef),
|
|
1319
|
-
_useResizeObserver$wi = _useResizeObserver.width,
|
|
1320
|
-
width = _useResizeObserver$wi === void 0 ? 0 : _useResizeObserver$wi,
|
|
1321
|
-
_useResizeObserver$he = _useResizeObserver.height,
|
|
1322
|
-
height = _useResizeObserver$he === void 0 ? 0 : _useResizeObserver$he;
|
|
1323
|
-
var getTicks = propTicks || defaultTicks;
|
|
1324
|
-
var timeTicks = typeof getTicks === 'function' ? getTicks({
|
|
1325
|
-
start: start,
|
|
1326
|
-
end: end,
|
|
1327
|
-
width: width,
|
|
1328
|
-
perspective: perspective
|
|
1329
|
-
}) : getTicks;
|
|
1330
|
-
var ticks = timeTicks.map(function (_ref6) {
|
|
1331
|
-
var label = _ref6.label,
|
|
1332
|
-
time = _ref6.time;
|
|
1333
|
-
return {
|
|
1334
|
-
x: interpolate(0, width, perspective.start, perspective.end, time),
|
|
1335
|
-
label: label,
|
|
1336
|
-
time: time
|
|
1337
|
-
};
|
|
1338
|
-
});
|
|
1339
|
-
var _useResizeObserver2 = useResizeObserver(timelineRef),
|
|
1340
|
-
timelineHeight = _useResizeObserver2.height;
|
|
1341
|
-
var timelineOffsetTop = ((trackContainerRef === null || trackContainerRef === void 0 ? void 0 : (_trackContainerRef$cu = trackContainerRef.current) === null || _trackContainerRef$cu === void 0 ? void 0 : _trackContainerRef$cu.offsetTop) || 0) - ((timelineRef === null || timelineRef === void 0 ? void 0 : (_timelineRef$current = timelineRef.current) === null || _timelineRef$current === void 0 ? void 0 : _timelineRef$current.offsetTop) || 0);
|
|
1342
|
-
var playheadTop = height;
|
|
1343
|
-
var playheadHeight = timelineHeight - height - timelineOffsetTop || undefined;
|
|
1344
|
-
var trackRectRef = useRef();
|
|
1345
|
-
var _useHover = useHover({
|
|
1346
|
-
hoverEffect: function hoverEffect(e) {
|
|
1347
|
-
if (onHover) onHover(e, true);
|
|
1348
|
-
var container = e.target.getStage().container();
|
|
1349
|
-
if (handleClick) {
|
|
1350
|
-
container.style.cursor = 'pointer';
|
|
1351
|
-
}
|
|
1352
|
-
return function () {
|
|
1353
|
-
if (onHover) onHover(e, false);
|
|
1354
|
-
if (handleClick) {
|
|
1355
|
-
container.style.cursor = 'default';
|
|
1356
|
-
}
|
|
1357
|
-
};
|
|
1358
|
-
}
|
|
1359
|
-
});
|
|
1360
|
-
_useHover.isHovering;
|
|
1361
|
-
var hoverProps = _objectWithoutProperties(_useHover, _excluded2);
|
|
1362
|
-
return /*#__PURE__*/jsxs("div", _objectSpread$3(_objectSpread$3({
|
|
1363
|
-
ref: trackContainerRef,
|
|
1364
|
-
className: clsx('VdtTimelinePlayheadTrack-root', className)
|
|
1365
|
-
}, props), {}, {
|
|
1366
|
-
children: [Children.map(children, function (child) {
|
|
1367
|
-
return /*#__PURE__*/cloneElement(child, {
|
|
1368
|
-
style: {
|
|
1369
|
-
top: playheadTop,
|
|
1370
|
-
height: playheadHeight
|
|
1371
|
-
}
|
|
1372
|
-
});
|
|
1373
|
-
}), /*#__PURE__*/jsx(Stage, _objectSpread$3(_objectSpread$3({
|
|
1374
|
-
height: height,
|
|
1375
|
-
width: width
|
|
1376
|
-
}, StageProps), {}, {
|
|
1377
|
-
children: /*#__PURE__*/jsx(Layer, _objectSpread$3(_objectSpread$3({}, LayerProps), {}, {
|
|
1378
|
-
children: /*#__PURE__*/jsxs(Group, _objectSpread$3(_objectSpread$3(_objectSpread$3({
|
|
1379
|
-
onClick: function onClick(e) {
|
|
1380
|
-
if (trackRectRef.current && handleClick) {
|
|
1381
|
-
var _trackRectRef$current = trackRectRef.current.getRelativePointerPosition(),
|
|
1382
|
-
x = _trackRectRef$current.x;
|
|
1383
|
-
handleClick(e, interpolate(perspective.start, perspective.end, 0, width, x));
|
|
1384
|
-
}
|
|
1385
|
-
},
|
|
1386
|
-
onWheel: function onWheel(e) {
|
|
1387
|
-
if (trackRectRef.current && handleWheel) {
|
|
1388
|
-
var _trackRectRef$current2 = trackRectRef.current.getRelativePointerPosition(),
|
|
1389
|
-
x = _trackRectRef$current2.x;
|
|
1390
|
-
handleWheel(e, e.evt.deltaY < 0 ? 'in' : 'out', interpolate(perspective.start, perspective.end, 0, width, x));
|
|
1391
|
-
}
|
|
1392
|
-
},
|
|
1393
|
-
draggable: true,
|
|
1394
|
-
dragBoundFunc: function dragBoundFunc() {
|
|
1395
|
-
return {
|
|
1396
|
-
x: 0,
|
|
1397
|
-
y: 0
|
|
1398
|
-
};
|
|
1399
|
-
},
|
|
1400
|
-
onDragStart: function onDragStart(e) {
|
|
1401
|
-
var container = e.target.getStage().container();
|
|
1402
|
-
container.style.cursor = 'grabbing';
|
|
1403
|
-
},
|
|
1404
|
-
onDragEnd: function onDragEnd(e) {
|
|
1405
|
-
var container = e.target.getStage().container();
|
|
1406
|
-
container.style.cursor = 'pointer';
|
|
1407
|
-
},
|
|
1408
|
-
onDragMove: function onDragMove(e) {
|
|
1409
|
-
if (handleDrag) {
|
|
1410
|
-
var movementX = e.evt.movementX;
|
|
1411
|
-
if (movementX === 0) return;
|
|
1412
|
-
var newStart = interpolate(perspective.start, perspective.end, 0, width, -movementX);
|
|
1413
|
-
var perspectiveDuration = perspective.end - perspective.start;
|
|
1414
|
-
var clampedNewStart = clamp(newStart, start, end - perspectiveDuration);
|
|
1415
|
-
var newEnd = clampedNewStart + perspectiveDuration;
|
|
1416
|
-
handleDrag(e, clampedNewStart, newEnd);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
}, hoverProps), GroupProps), {}, {
|
|
1420
|
-
children: [/*#__PURE__*/jsx(Rect, _objectSpread$3({
|
|
1421
|
-
ref: trackRectRef,
|
|
1422
|
-
x: 0,
|
|
1423
|
-
y: 0,
|
|
1424
|
-
width: width,
|
|
1425
|
-
height: height
|
|
1426
|
-
}, RectProps)), ticks.map(function (_ref7) {
|
|
1427
|
-
var x = _ref7.x,
|
|
1428
|
-
label = _ref7.label,
|
|
1429
|
-
time = _ref7.time;
|
|
1430
|
-
return /*#__PURE__*/jsx(TimelineTick, {
|
|
1431
|
-
minX: 0,
|
|
1432
|
-
maxX: width,
|
|
1433
|
-
x: x,
|
|
1434
|
-
label: label,
|
|
1435
|
-
y: height,
|
|
1436
|
-
TickGroupProps: TickGroupProps,
|
|
1437
|
-
TickLineProps: TickLineProps,
|
|
1438
|
-
TickTextProps: TickTextProps
|
|
1439
|
-
}, time);
|
|
1440
|
-
})]
|
|
1441
|
-
}))
|
|
1442
|
-
}))
|
|
1443
|
-
}))]
|
|
1444
|
-
}));
|
|
1445
|
-
}
|
|
1446
|
-
TimelinePlayheadTrack.propTypes = {
|
|
1447
|
-
/**
|
|
1448
|
-
* Callback to trigger on clicking on playhead track component.
|
|
1449
|
-
*/
|
|
1450
|
-
onClick: PropTypes.func,
|
|
1451
|
-
/**
|
|
1452
|
-
* Callback to trigger on mouse hover over playhead track component.
|
|
1453
|
-
*/
|
|
1454
|
-
onHover: PropTypes.func,
|
|
1455
|
-
/**
|
|
1456
|
-
* Array of (large) timeline tick objects. Set time and label.
|
|
1457
|
-
*/
|
|
1458
|
-
ticks: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.shape({
|
|
1459
|
-
time: PropTypes.number,
|
|
1460
|
-
label: PropTypes.string
|
|
1461
|
-
})), PropTypes.func]),
|
|
1462
|
-
/**
|
|
1463
|
-
* Callback to trigger on using the mouse wheel.
|
|
1464
|
-
*/
|
|
1465
|
-
onWheel: PropTypes.func,
|
|
1466
|
-
/**
|
|
1467
|
-
* Callback to trigger on dragging playhead track component
|
|
1468
|
-
*/
|
|
1469
|
-
onDrag: PropTypes.func,
|
|
1470
|
-
/**
|
|
1471
|
-
* Children components to render before/above the playhead track, according to top and height props passed to playhead track.
|
|
1472
|
-
*/
|
|
1473
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
1474
|
-
/**
|
|
1475
|
-
* Start of playhead track.
|
|
1476
|
-
*/
|
|
1477
|
-
start: PropTypes.number,
|
|
1478
|
-
/**
|
|
1479
|
-
* End of playhead track.
|
|
1480
|
-
*/
|
|
1481
|
-
end: PropTypes.number,
|
|
1482
|
-
/**
|
|
1483
|
-
* Zoom level when looking at track.
|
|
1484
|
-
*/
|
|
1485
|
-
perspective: PropTypes.shape({
|
|
1486
|
-
start: PropTypes.number,
|
|
1487
|
-
end: PropTypes.number
|
|
1488
|
-
}),
|
|
1489
|
-
/**
|
|
1490
|
-
* Ref object to track timeline events.
|
|
1491
|
-
*/
|
|
1492
|
-
timelineRef: PropTypes.shape({
|
|
1493
|
-
current: PropTypes.instanceOf(Element)
|
|
1494
|
-
}),
|
|
1495
|
-
/**
|
|
1496
|
-
* Props for Stage component. For more information: https://konvajs.org/api/Konva.Stage.html
|
|
1497
|
-
*/
|
|
1498
|
-
StageProps: PropTypes.instanceOf(Object),
|
|
1499
|
-
/**
|
|
1500
|
-
* Props for Layer component. For more information: https://konvajs.org/api/Konva.Layer.html
|
|
1501
|
-
*/
|
|
1502
|
-
LayerProps: PropTypes.instanceOf(Object),
|
|
1503
|
-
/**
|
|
1504
|
-
* Props for Group component. For more information: https://konvajs.org/api/Konva.Group.html
|
|
1505
|
-
*/
|
|
1506
|
-
GroupProps: PropTypes.instanceOf(Object),
|
|
1507
|
-
/**
|
|
1508
|
-
* Props for React component. For more information: https://konvajs.org/api/Konva.Rect.html
|
|
1509
|
-
*/
|
|
1510
|
-
RectProps: PropTypes.instanceOf(Object),
|
|
1511
|
-
/**
|
|
1512
|
-
* Props for Group component. For more information: https://konvajs.org/api/Konva.Group.html
|
|
1513
|
-
*/
|
|
1514
|
-
TickGroupProps: PropTypes.instanceOf(Object),
|
|
1515
|
-
/**
|
|
1516
|
-
* Props for Group component. For more information: https://konvajs.org/api/Konva.Text.html
|
|
1517
|
-
*/
|
|
1518
|
-
TickTextProps: PropTypes.instanceOf(Object),
|
|
1519
|
-
/**
|
|
1520
|
-
* Props for Group component. For more information: https://konvajs.org/api/Konva.Line.html
|
|
1521
|
-
*/
|
|
1522
|
-
TickLineProps: PropTypes.instanceOf(Object),
|
|
1523
|
-
/**
|
|
1524
|
-
* Override styles with className
|
|
1525
|
-
*/
|
|
1526
|
-
className: PropTypes.string,
|
|
1527
|
-
/**
|
|
1528
|
-
* Apply inline CSS styling
|
|
1529
|
-
*/
|
|
1530
|
-
style: PropTypes.instanceOf(Object)
|
|
1531
|
-
};
|
|
1532
|
-
TimelinePlayheadTrack.defaultProps = {
|
|
1533
|
-
onClick: undefined,
|
|
1534
|
-
onHover: undefined,
|
|
1535
|
-
ticks: defaultTicks,
|
|
1536
|
-
children: undefined,
|
|
1537
|
-
start: undefined,
|
|
1538
|
-
end: undefined,
|
|
1539
|
-
perspective: undefined,
|
|
1540
|
-
onWheel: undefined,
|
|
1541
|
-
onDrag: undefined,
|
|
1542
|
-
timelineRef: undefined,
|
|
1543
|
-
StageProps: {},
|
|
1544
|
-
LayerProps: {},
|
|
1545
|
-
GroupProps: {},
|
|
1546
|
-
RectProps: {},
|
|
1547
|
-
TickGroupProps: {},
|
|
1548
|
-
TickTextProps: {},
|
|
1549
|
-
TickLineProps: {},
|
|
1550
|
-
className: undefined,
|
|
1551
|
-
style: {}
|
|
1552
|
-
};
|
|
1553
|
-
|
|
1554
|
-
var _excluded$2 = ["index"];
|
|
1555
|
-
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1556
|
-
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1557
|
-
|
|
1558
|
-
// NOTE: options.height default is hardcoded to what is set for DEFAULT_EVENT_HEIGHT
|
|
1559
|
-
|
|
1560
|
-
/**
|
|
1561
|
-
* Extends events with height and y props to display them if they are overlapping
|
|
1562
|
-
* @param {Object[]} events - events to add overlapping info for
|
|
1563
|
-
* @param {Object} options - options for how to extend events
|
|
1564
|
-
* @param {number} options.height=15 - height of events
|
|
1565
|
-
* @returns {Array} events with height and y position added
|
|
1566
|
-
*/
|
|
1567
|
-
var getStackOverlappingEventProps = function getStackOverlappingEventProps(events) {
|
|
1568
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1569
|
-
var _ref = options || {},
|
|
1570
|
-
_ref$height = _ref.height,
|
|
1571
|
-
height = _ref$height === void 0 ? DEFAULT_EVENT_HEIGHT : _ref$height;
|
|
1572
|
-
var sortedEvents = sortBy(events.map(function (e, index) {
|
|
1573
|
-
return _objectSpread$2(_objectSpread$2({}, e), {}, {
|
|
1574
|
-
index: index
|
|
1575
|
-
});
|
|
1576
|
-
}), ['start', 'end']);
|
|
1577
|
-
var tracks = [0];
|
|
1578
|
-
var eventTracks = [];
|
|
1579
|
-
var _loop = function _loop(i) {
|
|
1580
|
-
var event = sortedEvents[i];
|
|
1581
|
-
var trackIndex = function () {
|
|
1582
|
-
for (var j = 0; j < tracks.length; j += 1) {
|
|
1583
|
-
var firstVacantFrame = tracks[j];
|
|
1584
|
-
if (event.start >= firstVacantFrame) {
|
|
1585
|
-
return j;
|
|
1586
|
-
}
|
|
1587
|
-
}
|
|
1588
|
-
tracks.push(0);
|
|
1589
|
-
return tracks.length - 1;
|
|
1590
|
-
}();
|
|
1591
|
-
tracks[trackIndex] = event.end;
|
|
1592
|
-
eventTracks.push(_objectSpread$2(_objectSpread$2({}, event), {}, {
|
|
1593
|
-
height: height,
|
|
1594
|
-
y: trackIndex * height
|
|
1595
|
-
}));
|
|
1596
|
-
};
|
|
1597
|
-
for (var i = 0; i < sortedEvents.length; i += 1) {
|
|
1598
|
-
_loop(i);
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
// retain the original order of the events
|
|
1602
|
-
return sortBy(eventTracks, 'index').map(function (_ref2) {
|
|
1603
|
-
_ref2.index;
|
|
1604
|
-
var event = _objectWithoutProperties(_ref2, _excluded$2);
|
|
1605
|
-
return event;
|
|
1606
|
-
});
|
|
1607
|
-
};
|
|
1608
|
-
|
|
1609
|
-
var css$1 = ":root {\n --vdt-timeline-palette-primary:#49a6dd;\n --vdt-timeline-palette-primary-dark: #3c8bb8;\n --vdt-timeline-palette-secondary:#f50057;\n --vdt-timeline-palette-background-primary:#20232a;\n --vdt-timeline-palette-background-secondary:#282c34;\n --vdt-timeline-palette-background-hover: rgba(255, 255, 255, 0.08);\n --vdt-timeline-palette-text-primary:#fff;\n --vdt-timeline-palette-text-secondary:rgba(255, 255, 255, 0.7);\n}\n\n.VdtTimelineScroll-root {\n height: 4px;\n background-color: var(--vdt-timeline-palette-background-secondary);\n}";
|
|
1610
|
-
n(css$1,{});
|
|
1611
|
-
|
|
1612
|
-
var _excluded$1 = ["className", "onScroll", "onClick", "start", "end", "perspective", "style", "StageProps", "LayerProps", "RectProps"];
|
|
1613
|
-
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1614
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1615
|
-
var _getStyleProperties = getStyleProperties('--vdt-timeline-palette-secondary'),
|
|
1616
|
-
_getStyleProperties2 = _slicedToArray(_getStyleProperties, 1),
|
|
1617
|
-
paletteSecondary = _getStyleProperties2[0];
|
|
1618
|
-
function TimelineScroll(_ref) {
|
|
1619
|
-
var className = _ref.className,
|
|
1620
|
-
onScroll = _ref.onScroll,
|
|
1621
|
-
onClick = _ref.onClick,
|
|
1622
|
-
propStart = _ref.start,
|
|
1623
|
-
propEnd = _ref.end,
|
|
1624
|
-
propPerspective = _ref.perspective,
|
|
1625
|
-
style = _ref.style,
|
|
1626
|
-
StageProps = _ref.StageProps,
|
|
1627
|
-
LayerProps = _ref.LayerProps,
|
|
1628
|
-
RectProps = _ref.RectProps,
|
|
1629
|
-
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
1630
|
-
var _ref2 = useTimeline() || {
|
|
1631
|
-
start: propStart,
|
|
1632
|
-
end: propEnd,
|
|
1633
|
-
perspective: propPerspective
|
|
1634
|
-
},
|
|
1635
|
-
start = _ref2.start,
|
|
1636
|
-
end = _ref2.end,
|
|
1637
|
-
perspective = _ref2.perspective,
|
|
1638
|
-
setPerspective = _ref2.setPerspective;
|
|
1639
|
-
if (start === undefined || end === undefined || perspective === undefined) {
|
|
1640
|
-
vLog.error('VdtTimelineScroll', "missing 'start', 'end' or 'perspective' props. If the component is used outside a VdtTimelineContext, 'start', 'end' and 'perspective' must be passed explicitly");
|
|
1641
|
-
}
|
|
1642
|
-
var ref = useRef();
|
|
1643
|
-
var _useResizeObserver = useResizeObserver(ref),
|
|
1644
|
-
_useResizeObserver$wi = _useResizeObserver.width,
|
|
1645
|
-
scrollTrackWidth = _useResizeObserver$wi === void 0 ? 0 : _useResizeObserver$wi,
|
|
1646
|
-
_useResizeObserver$he = _useResizeObserver.height,
|
|
1647
|
-
height = _useResizeObserver$he === void 0 ? 0 : _useResizeObserver$he;
|
|
1648
|
-
var scrollLeft = interpolate(0, scrollTrackWidth, start, end, perspective.start);
|
|
1649
|
-
var perspectiveDuration = perspective.end - perspective.start;
|
|
1650
|
-
var scrollWidth = interpolate(0, scrollTrackWidth, 0, end - start, perspectiveDuration);
|
|
1651
|
-
var handleScroll = onScroll || setPerspective && function (e) {
|
|
1652
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1653
|
-
args[_key - 1] = arguments[_key];
|
|
1654
|
-
}
|
|
1655
|
-
return setPerspective.apply(void 0, args);
|
|
1656
|
-
};
|
|
1657
|
-
var handleClick = onClick || setPerspective && function (e) {
|
|
1658
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1659
|
-
args[_key2 - 1] = arguments[_key2];
|
|
1660
|
-
}
|
|
1661
|
-
return setPerspective.apply(void 0, args);
|
|
1662
|
-
};
|
|
1663
|
-
var isZoomed = start !== perspective.start || end !== perspective.end;
|
|
1664
|
-
return /*#__PURE__*/jsx("div", _objectSpread$1(_objectSpread$1({
|
|
1665
|
-
className: clsx('VdtTimelineScroll-root', className),
|
|
1666
|
-
style: _objectSpread$1({
|
|
1667
|
-
display: !isZoomed && 'none',
|
|
1668
|
-
zIndex: DEFAULT_PLAYHEAD_ZINDEX + 1
|
|
1669
|
-
}, style),
|
|
1670
|
-
ref: ref
|
|
1671
|
-
}, props), {}, {
|
|
1672
|
-
children: /*#__PURE__*/jsx(Stage, _objectSpread$1(_objectSpread$1({
|
|
1673
|
-
height: height,
|
|
1674
|
-
width: scrollTrackWidth,
|
|
1675
|
-
onClick: function onClick(e) {
|
|
1676
|
-
if (!handleClick) return;
|
|
1677
|
-
var _e$currentTarget$getR = e.currentTarget.getRelativePointerPosition(),
|
|
1678
|
-
x = _e$currentTarget$getR.x;
|
|
1679
|
-
var newStart;
|
|
1680
|
-
if (x > scrollLeft + scrollWidth) {
|
|
1681
|
-
newStart = Math.floor(interpolate(start, end, 0, scrollTrackWidth, x - scrollWidth));
|
|
1682
|
-
} else if (x < scrollLeft) {
|
|
1683
|
-
newStart = Math.floor(interpolate(start, end, 0, scrollTrackWidth, x));
|
|
1684
|
-
}
|
|
1685
|
-
if (newStart !== undefined && newStart !== perspective.start) {
|
|
1686
|
-
handleClick(e, newStart, newStart + perspectiveDuration);
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
}, StageProps), {}, {
|
|
1690
|
-
children: /*#__PURE__*/jsx(Layer, _objectSpread$1(_objectSpread$1({}, LayerProps), {}, {
|
|
1691
|
-
children: /*#__PURE__*/jsx(Rect, _objectSpread$1({
|
|
1692
|
-
x: scrollLeft,
|
|
1693
|
-
y: 0,
|
|
1694
|
-
width: scrollWidth,
|
|
1695
|
-
height: height,
|
|
1696
|
-
fill: paletteSecondary,
|
|
1697
|
-
draggable: true,
|
|
1698
|
-
dragBoundFunc: function dragBoundFunc(pos) {
|
|
1699
|
-
return {
|
|
1700
|
-
x: clamp(pos.x, 0, scrollTrackWidth - scrollWidth),
|
|
1701
|
-
y: 0
|
|
1702
|
-
};
|
|
1703
|
-
},
|
|
1704
|
-
onDragMove: function onDragMove(e) {
|
|
1705
|
-
if (!handleScroll) return;
|
|
1706
|
-
var _e$target$position = e.target.position(),
|
|
1707
|
-
x = _e$target$position.x;
|
|
1708
|
-
e.target.x(scrollLeft);
|
|
1709
|
-
var newStart = Math.floor(interpolate(start, end, 0, scrollTrackWidth, x));
|
|
1710
|
-
handleScroll(e, newStart, newStart + perspectiveDuration);
|
|
1711
|
-
}
|
|
1712
|
-
}, RectProps))
|
|
1713
|
-
}))
|
|
1714
|
-
}))
|
|
1715
|
-
}));
|
|
1716
|
-
}
|
|
1717
|
-
TimelineScroll.propTypes = {
|
|
1718
|
-
/**
|
|
1719
|
-
* Callback to trigger on timeline component scroll.
|
|
1720
|
-
*/
|
|
1721
|
-
onScroll: PropTypes.func,
|
|
1722
|
-
/**
|
|
1723
|
-
* Callback to trigger on timeline component click.
|
|
1724
|
-
*/
|
|
1725
|
-
onClick: PropTypes.func,
|
|
1726
|
-
/**
|
|
1727
|
-
* Start time of timeline scroll.
|
|
1728
|
-
*/
|
|
1729
|
-
start: PropTypes.number,
|
|
1730
|
-
/**
|
|
1731
|
-
* End time of timeline scroll
|
|
1732
|
-
*/
|
|
1733
|
-
end: PropTypes.number,
|
|
1734
|
-
/**
|
|
1735
|
-
* Zoom level of timeline scroll.
|
|
1736
|
-
*/
|
|
1737
|
-
perspective: PropTypes.shape({
|
|
1738
|
-
start: PropTypes.number,
|
|
1739
|
-
end: PropTypes.number
|
|
1740
|
-
}),
|
|
1741
|
-
/**
|
|
1742
|
-
* Apply inline CSS styling
|
|
1743
|
-
*/
|
|
1744
|
-
style: PropTypes.instanceOf(Object),
|
|
1745
|
-
/**
|
|
1746
|
-
* Props for Stage component. For more information: https://konvajs.org/api/Konva.Stage.html
|
|
1747
|
-
*/
|
|
1748
|
-
StageProps: PropTypes.instanceOf(Object),
|
|
1749
|
-
/**
|
|
1750
|
-
* Props for Stage component. For more information: https://konvajs.org/api/Konva.Layer.html
|
|
1751
|
-
*/
|
|
1752
|
-
LayerProps: PropTypes.instanceOf(Object),
|
|
1753
|
-
/**
|
|
1754
|
-
* Props for Stage component. For more information: https://konvajs.org/api/Konva.Rect.html
|
|
1755
|
-
*/
|
|
1756
|
-
RectProps: PropTypes.instanceOf(Object),
|
|
1757
|
-
/**
|
|
1758
|
-
* Override styles with className
|
|
1759
|
-
*/
|
|
1760
|
-
className: PropTypes.string
|
|
1761
|
-
};
|
|
1762
|
-
TimelineScroll.defaultProps = {
|
|
1763
|
-
onScroll: undefined,
|
|
1764
|
-
onClick: undefined,
|
|
1765
|
-
start: undefined,
|
|
1766
|
-
end: undefined,
|
|
1767
|
-
perspective: undefined,
|
|
1768
|
-
style: {},
|
|
1769
|
-
StageProps: {},
|
|
1770
|
-
LayerProps: {},
|
|
1771
|
-
RectProps: {},
|
|
1772
|
-
className: undefined
|
|
1773
|
-
};
|
|
1774
|
-
|
|
1775
|
-
var css = "\n\n.VdtTimelineScrollContainer-timelineRow > :not(.VdtTimelineRow-label) {\n /* margin messes with the playhead line alignment */\n margin: 0;\n}";
|
|
1776
|
-
n(css,{});
|
|
1777
|
-
|
|
1778
|
-
var _excluded = ["className", "children", "getScrollDistance", "RowProps", "ScrollProps"];
|
|
1779
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1780
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1781
|
-
function defaultGetScrollDistance(e, _ref) {
|
|
1782
|
-
var start = _ref.start,
|
|
1783
|
-
end = _ref.end;
|
|
1784
|
-
return Math.floor(0.02 * (start - end));
|
|
1785
|
-
}
|
|
1786
|
-
function TimelineScrollContainer(_ref2) {
|
|
1787
|
-
var className = _ref2.className,
|
|
1788
|
-
children = _ref2.children,
|
|
1789
|
-
getScrollDistance = _ref2.getScrollDistance,
|
|
1790
|
-
RowProps = _ref2.RowProps,
|
|
1791
|
-
ScrollProps = _ref2.ScrollProps,
|
|
1792
|
-
props = _objectWithoutProperties(_ref2, _excluded);
|
|
1793
|
-
var _useTimeline = useTimeline(),
|
|
1794
|
-
start = _useTimeline.start,
|
|
1795
|
-
end = _useTimeline.end,
|
|
1796
|
-
perspective = _useTimeline.perspective,
|
|
1797
|
-
setPerspective = _useTimeline.setPerspective;
|
|
1798
|
-
return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
|
|
1799
|
-
className: clsx('VdtTimelineScrollContainer-root', className),
|
|
1800
|
-
onWheel: function onWheel(e) {
|
|
1801
|
-
if (e.shiftKey) {
|
|
1802
|
-
var delta = getScrollDistance(e, {
|
|
1803
|
-
start: start,
|
|
1804
|
-
end: end,
|
|
1805
|
-
perspective: perspective
|
|
1806
|
-
});
|
|
1807
|
-
var newPerspectiveStart = perspective.start + (e.deltaY > 0 ? -delta : delta);
|
|
1808
|
-
var perspectiveDuration = perspective.end - perspective.start;
|
|
1809
|
-
var newPerspectiveEnd = newPerspectiveStart + perspectiveDuration;
|
|
1810
|
-
if (newPerspectiveEnd > end) {
|
|
1811
|
-
setPerspective(end - perspectiveDuration, end);
|
|
1812
|
-
} else if (newPerspectiveStart < start) {
|
|
1813
|
-
setPerspective(start, perspectiveDuration);
|
|
1814
|
-
} else {
|
|
1815
|
-
setPerspective(newPerspectiveStart, newPerspectiveEnd);
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
}, props), {}, {
|
|
1820
|
-
children: [children, /*#__PURE__*/jsx(TimelineRow, _objectSpread(_objectSpread({
|
|
1821
|
-
className: clsx('VdtTimelineScrollContainer-timelineRow')
|
|
1822
|
-
}, RowProps), {}, {
|
|
1823
|
-
children: /*#__PURE__*/jsx(TimelineScroll, _objectSpread({}, ScrollProps))
|
|
1824
|
-
}))]
|
|
1825
|
-
}));
|
|
1826
|
-
}
|
|
1827
|
-
TimelineScrollContainer.propTypes = {
|
|
1828
|
-
/**
|
|
1829
|
-
* Override styles with className
|
|
1830
|
-
*/
|
|
1831
|
-
className: PropTypes.string,
|
|
1832
|
-
/**
|
|
1833
|
-
* Children components to render
|
|
1834
|
-
*/
|
|
1835
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
1836
|
-
/**
|
|
1837
|
-
* Get distance of scrolling
|
|
1838
|
-
*/
|
|
1839
|
-
getScrollDistance: PropTypes.func,
|
|
1840
|
-
/**
|
|
1841
|
-
* Additional props for row component
|
|
1842
|
-
*/
|
|
1843
|
-
RowProps: PropTypes.instanceOf(Object),
|
|
1844
|
-
/**
|
|
1845
|
-
* Additional props for scroll component
|
|
1846
|
-
*/
|
|
1847
|
-
ScrollProps: PropTypes.instanceOf(Object)
|
|
1848
|
-
};
|
|
1849
|
-
TimelineScrollContainer.defaultProps = {
|
|
1850
|
-
children: undefined,
|
|
1851
|
-
getScrollDistance: defaultGetScrollDistance,
|
|
1852
|
-
RowProps: {},
|
|
1853
|
-
ScrollProps: {},
|
|
1854
|
-
className: undefined
|
|
1855
|
-
};
|
|
1856
|
-
|
|
1857
|
-
export { Timeline, TimelineContext, TimelineEvent, TimelinePlayhead, TimelinePlayheadTrack, TimelineProvider, TimelineRow, TimelineScroll, TimelineScrollContainer, TimelineTrack, TimelineWaveform, getStackOverlappingEventProps, useTimeline };
|