@ldelia/react-media 0.4.1 → 0.4.3
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/components/__tests__/timeline/timeline.test.js +5 -10
- package/dist/components/index.js +2 -17
- package/dist/components/timeline/RangeSelectorCanvas/RangeSelectorCanvas.js +16 -44
- package/dist/components/timeline/Timeline.js +26 -56
- package/dist/components/timeline/TimelineCanvas/TickTime.js +5 -10
- package/dist/components/timeline/TimelineCanvas/TickTimeCollectionDisplay.js +9 -14
- package/dist/components/timeline/TimelineCanvas/TimelineCanvas.js +16 -44
- package/dist/components/timeline/TimelineCanvas/drawTimeBlocksOnCanvas.js +4 -8
- package/dist/components/timeline/TimelineValue/TimelineValue.js +24 -54
- package/dist/components/timeline/ZoomContext/ZoomContext.js +2 -8
- package/dist/components/timeline/constants.js +1 -4
- package/dist/components/timeline/index.js +1 -17
- package/dist/components/timeline/utils/utils.js +6 -15
- package/dist/index.js +1 -17
- package/dist/setupTests.js +1 -3
- package/dist/stories/timeline.stories.js +18 -24
- package/package.json +45 -35
- package/.bitmap +0 -48
- package/.eslintcache +0 -1
- package/.prettierignore +0 -3
- package/.prettierrc +0 -7
- package/.storybook/main.js +0 -38
- package/.storybook/preview.js +0 -4
- package/config/env.js +0 -104
- package/config/getHttpsConfig.js +0 -66
- package/config/jest/babelTransform.js +0 -29
- package/config/jest/cssTransform.js +0 -14
- package/config/jest/fileTransform.js +0 -40
- package/config/modules.js +0 -134
- package/config/paths.js +0 -77
- package/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
- package/config/webpack.config.js +0 -755
- package/config/webpackDevServer.config.js +0 -127
- package/dist/components/__tests__/timeline/timeline.test.d.ts +0 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/timeline/RangeSelectorCanvas/RangeSelectorCanvas.d.ts +0 -8
- package/dist/components/timeline/Timeline.d.ts +0 -12
- package/dist/components/timeline/TimelineCanvas/TickTime.d.ts +0 -7
- package/dist/components/timeline/TimelineCanvas/TickTimeCollectionDisplay.d.ts +0 -6
- package/dist/components/timeline/TimelineCanvas/TimelineCanvas.d.ts +0 -7
- package/dist/components/timeline/TimelineCanvas/drawTimeBlocksOnCanvas.d.ts +0 -2
- package/dist/components/timeline/TimelineValue/TimelineValue.d.ts +0 -7
- package/dist/components/timeline/ZoomContext/ZoomContext.d.ts +0 -7
- package/dist/components/timeline/constants.d.ts +0 -1
- package/dist/components/timeline/index.d.ts +0 -1
- package/dist/components/timeline/utils/utils.d.ts +0 -7
- package/dist/index.d.ts +0 -1
- package/dist/setupTests.d.ts +0 -1
- package/dist/stories/timeline.stories.d.ts +0 -9
- package/scripts/build.js +0 -217
- package/scripts/start.js +0 -154
- package/scripts/test.js +0 -52
- package/src/components/__tests__/timeline/timeline.test.js +0 -22
- package/src/components/__tests__/timeline/timeline.test.tsx +0 -26
- package/src/components/index.js +0 -2
- package/src/components/index.ts +0 -2
- package/src/components/reproduction-widget/README.md +0 -27
- package/src/components/reproduction-widget/ReproductionWidget.tsx +0 -68
- package/src/components/reproduction-widget/index.tsx +0 -1
- package/src/components/reproduction-widget/inner-players/PlayAlongInnerPlayer.tsx +0 -10
- package/src/components/reproduction-widget/inner-players/YouTubeInnerPlayer.tsx +0 -36
- package/src/components/reproduction-widget/models/Player/PlayAlongPlayer.ts +0 -129
- package/src/components/reproduction-widget/models/Player/PlayerEvents.ts +0 -4
- package/src/components/reproduction-widget/models/Player/YouTubePlayer.ts +0 -171
- package/src/components/reproduction-widget/models/Reproduction.ts +0 -272
- package/src/components/reproduction-widget/models/ReproductionBuilder.ts +0 -70
- package/src/components/timeline/README.md +0 -111
- package/src/components/timeline/RangeSelectorCanvas/RangeSelectorCanvas.js +0 -127
- package/src/components/timeline/RangeSelectorCanvas/RangeSelectorCanvas.tsx +0 -166
- package/src/components/timeline/Timeline.js +0 -77
- package/src/components/timeline/Timeline.tsx +0 -139
- package/src/components/timeline/TimelineCanvas/TickTime.js +0 -26
- package/src/components/timeline/TimelineCanvas/TickTime.tsx +0 -45
- package/src/components/timeline/TimelineCanvas/TickTimeCollectionDisplay.js +0 -19
- package/src/components/timeline/TimelineCanvas/TickTimeCollectionDisplay.tsx +0 -42
- package/src/components/timeline/TimelineCanvas/TimelineCanvas.js +0 -44
- package/src/components/timeline/TimelineCanvas/TimelineCanvas.tsx +0 -79
- package/src/components/timeline/TimelineCanvas/drawTimeBlocksOnCanvas.js +0 -28
- package/src/components/timeline/TimelineCanvas/drawTimeBlocksOnCanvas.ts +0 -43
- package/src/components/timeline/TimelineValue/TimelineValue.js +0 -50
- package/src/components/timeline/TimelineValue/TimelineValue.tsx +0 -87
- package/src/components/timeline/ZoomContext/ZoomContext.js +0 -2
- package/src/components/timeline/ZoomContext/ZoomContext.ts +0 -10
- package/src/components/timeline/constants.js +0 -13
- package/src/components/timeline/constants.ts +0 -13
- package/src/components/timeline/index.js +0 -1
- package/src/components/timeline/index.tsx +0 -1
- package/src/components/timeline/utils/utils.js +0 -28
- package/src/components/timeline/utils/utils.ts +0 -49
- package/src/index.js +0 -1
- package/src/index.ts +0 -1
- package/src/modules.d.ts +0 -1
- package/src/react-app-env.d.ts +0 -71
- package/src/react-docgen-types.d.ts +0 -37
- package/src/setupTests.js +0 -5
- package/src/setupTests.ts +0 -5
- package/src/stories/Configure.mdx +0 -364
- package/src/stories/reproduction-widget.stories.tsx +0 -23
- package/src/stories/timeline.stories.custom.css +0 -29
- package/src/stories/timeline.stories.js +0 -54
- package/src/stories/timeline.stories.tsx +0 -66
- package/storybook-static/favicon.svg +0 -1
- package/storybook-static/index.html +0 -173
- package/storybook-static/index.json +0 -1
- package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/project.json +0 -1
- package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +0 -12
- package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +0 -412
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/links-1/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/links-1/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +0 -3
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-common-assets/favicon.svg +0 -1
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/globals-module-info.js +0 -995
- package/storybook-static/sb-manager/globals-runtime.js +0 -53527
- package/storybook-static/sb-manager/globals.js +0 -48
- package/storybook-static/sb-manager/runtime.js +0 -11885
- package/storybook-static/sb-preview/globals.js +0 -33
- package/storybook-static/sb-preview/runtime.js +0 -9483
- package/tsconfig.json +0 -14
- /package/{src → dist}/components/reproduction-widget/ReproductionWidget.js +0 -0
- /package/{src → dist}/components/reproduction-widget/index.js +0 -0
- /package/{src → dist}/components/reproduction-widget/inner-players/PlayAlongInnerPlayer.js +0 -0
- /package/{src → dist}/components/reproduction-widget/inner-players/YouTubeInnerPlayer.js +0 -0
- /package/{src → dist}/components/reproduction-widget/models/Player/PlayAlongPlayer.js +0 -0
- /package/{src → dist}/components/reproduction-widget/models/Player/PlayerEvents.js +0 -0
- /package/{src → dist}/components/reproduction-widget/models/Player/YouTubePlayer.js +0 -0
- /package/{src → dist}/components/reproduction-widget/models/Reproduction.js +0 -0
- /package/{src → dist}/components/reproduction-widget/models/ReproductionBuilder.js +0 -0
- /package/{src → dist}/stories/reproduction-widget.stories.js +0 -0
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 = __importDefault(require("react"));
|
|
7
|
-
const client_1 = require("react-dom/client");
|
|
8
|
-
const timeline_1 = require("../../timeline");
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import { Timeline } from '../../timeline';
|
|
9
4
|
describe('Timeline', () => {
|
|
10
5
|
let props;
|
|
11
6
|
beforeEach(() => {
|
|
@@ -20,8 +15,8 @@ describe('Timeline', () => {
|
|
|
20
15
|
describe('render()', () => {
|
|
21
16
|
it('renders a timeline', () => {
|
|
22
17
|
const rootElement = document.createElement('div');
|
|
23
|
-
const root =
|
|
24
|
-
root.render(
|
|
18
|
+
const root = createRoot(rootElement);
|
|
19
|
+
root.render(React.createElement(Timeline, Object.assign({}, props)));
|
|
25
20
|
});
|
|
26
21
|
});
|
|
27
22
|
});
|
package/dist/components/index.js
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./timeline"), exports);
|
|
1
|
+
export * from './reproduction-widget';
|
|
2
|
+
export * from './timeline';
|
|
@@ -1,36 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const react_1 = __importStar(require("react"));
|
|
30
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
31
|
-
const ZoomContext_1 = require("../ZoomContext/ZoomContext");
|
|
32
|
-
const utils_1 = require("../utils/utils");
|
|
33
|
-
const OverlayCanvas = styled_components_1.default.canvas `
|
|
1
|
+
import React, { useContext, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { ZoomContext } from '../ZoomContext/ZoomContext';
|
|
4
|
+
import { pixelToSeconds, secondsToPixel } from '../utils/utils';
|
|
5
|
+
const OverlayCanvas = styled.canvas `
|
|
34
6
|
position: absolute;
|
|
35
7
|
top: 0;
|
|
36
8
|
left: 0;
|
|
@@ -39,14 +11,14 @@ const OverlayCanvas = styled_components_1.default.canvas `
|
|
|
39
11
|
color: cadetblue;
|
|
40
12
|
`;
|
|
41
13
|
const RangeSelectorCanvas = ({ selectedRange, onChange, onRangeChange, }) => {
|
|
42
|
-
const canvasRef =
|
|
43
|
-
const zoomContextValue =
|
|
14
|
+
const canvasRef = useRef(null);
|
|
15
|
+
const zoomContextValue = useContext(ZoomContext);
|
|
44
16
|
let isSelectingRange = false;
|
|
45
|
-
let selectedRangeInPixels =
|
|
17
|
+
let selectedRangeInPixels = useMemo(() => [], []);
|
|
46
18
|
if (selectedRange.length === 2) {
|
|
47
19
|
selectedRangeInPixels = [
|
|
48
|
-
|
|
49
|
-
|
|
20
|
+
secondsToPixel(zoomContextValue, selectedRange[0]),
|
|
21
|
+
secondsToPixel(zoomContextValue, selectedRange[1]),
|
|
50
22
|
];
|
|
51
23
|
}
|
|
52
24
|
let lastValidSelectedRangeInPixels = [];
|
|
@@ -67,7 +39,7 @@ const RangeSelectorCanvas = ({ selectedRange, onChange, onRangeChange, }) => {
|
|
|
67
39
|
};
|
|
68
40
|
const onCanvasDoubleClick = (e) => {
|
|
69
41
|
const x0 = getMousePointerPixelPosition(e);
|
|
70
|
-
onChange(
|
|
42
|
+
onChange(pixelToSeconds(zoomContextValue, x0));
|
|
71
43
|
selectedRangeInPixels = lastValidSelectedRangeInPixels;
|
|
72
44
|
};
|
|
73
45
|
const isPixelNearSelectedRange = (x0) => {
|
|
@@ -136,12 +108,12 @@ const RangeSelectorCanvas = ({ selectedRange, onChange, onRangeChange, }) => {
|
|
|
136
108
|
else {
|
|
137
109
|
lastValidSelectedRangeInPixels = pixelRange;
|
|
138
110
|
onRangeChange([
|
|
139
|
-
|
|
140
|
-
|
|
111
|
+
pixelToSeconds(zoomContextValue, pixelRange[0]),
|
|
112
|
+
pixelToSeconds(zoomContextValue, pixelRange[1]),
|
|
141
113
|
]);
|
|
142
114
|
}
|
|
143
115
|
};
|
|
144
|
-
|
|
116
|
+
useEffect(() => {
|
|
145
117
|
const canvas = canvasRef.current;
|
|
146
118
|
// https://stackoverflow.com/questions/8696631/canvas-drawings-like-lines-are-blurry
|
|
147
119
|
canvas.width = canvas.offsetWidth;
|
|
@@ -150,6 +122,6 @@ const RangeSelectorCanvas = ({ selectedRange, onChange, onRangeChange, }) => {
|
|
|
150
122
|
return;
|
|
151
123
|
drawRect(selectedRangeInPixels[0], selectedRangeInPixels[1]);
|
|
152
124
|
}, [selectedRangeInPixels]);
|
|
153
|
-
return (
|
|
125
|
+
return (React.createElement(OverlayCanvas, { ref: canvasRef, onDoubleClick: onCanvasDoubleClick, onMouseDown: onCanvasMouseDown, onMouseMove: onCanvasMouseMove, onMouseUp: onCanvasMouseUp, className: 'media-timeline-range-selector-canvas' }));
|
|
154
126
|
};
|
|
155
|
-
|
|
127
|
+
export default React.memo(RangeSelectorCanvas);
|
|
@@ -1,41 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Timeline = void 0;
|
|
30
|
-
const react_1 = __importStar(require("react"));
|
|
31
|
-
const TimelineCanvas_1 = __importDefault(require("./TimelineCanvas/TimelineCanvas"));
|
|
32
|
-
const RangeSelectorCanvas_1 = __importDefault(require("./RangeSelectorCanvas/RangeSelectorCanvas"));
|
|
33
|
-
const constants_1 = require("./constants");
|
|
34
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
35
|
-
const TimelineValue_1 = require("./TimelineValue/TimelineValue");
|
|
36
|
-
const ZoomContext_1 = require("./ZoomContext/ZoomContext");
|
|
37
|
-
const utils_1 = require("./utils/utils");
|
|
38
|
-
const TimelineContainer = styled_components_1.default.div `
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import TimelineCanvas from './TimelineCanvas/TimelineCanvas';
|
|
3
|
+
import RangeSelectorCanvas from './RangeSelectorCanvas/RangeSelectorCanvas';
|
|
4
|
+
import { zoomLevelConfigurations } from './constants';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { TimelineValue } from './TimelineValue/TimelineValue';
|
|
7
|
+
import { ZoomContext } from './ZoomContext/ZoomContext';
|
|
8
|
+
import { getBlockOffsetForZoomLevel, getTimelineWrapperWidth, numberToPxString, } from './utils/utils';
|
|
9
|
+
const TimelineContainer = styled.div `
|
|
39
10
|
background-color: #f0f0f0;
|
|
40
11
|
border: 1px solid #c9c9c9;
|
|
41
12
|
height: 80px;
|
|
@@ -45,7 +16,7 @@ const TimelineContainer = styled_components_1.default.div `
|
|
|
45
16
|
position: relative;
|
|
46
17
|
display: flex;
|
|
47
18
|
`;
|
|
48
|
-
const TimelineWrapper =
|
|
19
|
+
const TimelineWrapper = styled.div `
|
|
49
20
|
position: absolute;
|
|
50
21
|
height: 100%;
|
|
51
22
|
display: flex;
|
|
@@ -53,16 +24,16 @@ const TimelineWrapper = styled_components_1.default.div `
|
|
|
53
24
|
align-items: center;
|
|
54
25
|
overflow: hidden;
|
|
55
26
|
`;
|
|
56
|
-
const Timeline = ({ duration, value, zoomLevel = 0, selectedRange = [], withTimeBlocks = true, onChange = () => { }, onRangeChange = () => { }, className = '', }) => {
|
|
57
|
-
const timeLineContainerRef =
|
|
58
|
-
const canvasRef =
|
|
59
|
-
const [zoomContextValue, setZoomContextValue] =
|
|
27
|
+
export const Timeline = ({ duration, value, zoomLevel = 0, selectedRange = [], withTimeBlocks = true, onChange = () => { }, onRangeChange = () => { }, className = '', }) => {
|
|
28
|
+
const timeLineContainerRef = useRef(null);
|
|
29
|
+
const canvasRef = useRef(null);
|
|
30
|
+
const [zoomContextValue, setZoomContextValue] = useState({
|
|
60
31
|
blockOffset: 0,
|
|
61
32
|
pixelsInSecond: 0,
|
|
62
33
|
timelineWrapperWidth: 0,
|
|
63
34
|
});
|
|
64
35
|
let zoomLevelValue = zoomLevel ? zoomLevel : 0;
|
|
65
|
-
if (zoomLevelValue < 0 || zoomLevelValue >=
|
|
36
|
+
if (zoomLevelValue < 0 || zoomLevelValue >= zoomLevelConfigurations.length) {
|
|
66
37
|
console.warn('Invalid value for property zoomLevel.');
|
|
67
38
|
zoomLevelValue = 0;
|
|
68
39
|
}
|
|
@@ -80,28 +51,27 @@ const Timeline = ({ duration, value, zoomLevel = 0, selectedRange = [], withTime
|
|
|
80
51
|
selectedRange = [];
|
|
81
52
|
console.warn('The selected range is inconsistent.');
|
|
82
53
|
}
|
|
83
|
-
|
|
54
|
+
useEffect(() => {
|
|
84
55
|
if (!timeLineContainerRef.current)
|
|
85
56
|
return;
|
|
86
|
-
const timelineWrapperWidth =
|
|
57
|
+
const timelineWrapperWidth = getTimelineWrapperWidth(timeLineContainerRef.current.offsetWidth, zoomLevelValue);
|
|
87
58
|
setZoomContextValue({
|
|
88
|
-
blockOffset:
|
|
59
|
+
blockOffset: getBlockOffsetForZoomLevel(zoomLevelValue, duration, timelineWrapperWidth),
|
|
89
60
|
pixelsInSecond: timelineWrapperWidth / duration,
|
|
90
61
|
timelineWrapperWidth: timelineWrapperWidth,
|
|
91
62
|
});
|
|
92
63
|
}, [timeLineContainerRef.current, zoomLevelValue, duration]);
|
|
93
|
-
|
|
64
|
+
useEffect(() => {
|
|
94
65
|
const timeLineWrapper = timeLineContainerRef.current;
|
|
95
66
|
const scrollPosition = value * zoomContextValue.pixelsInSecond - 300;
|
|
96
67
|
timeLineWrapper.scrollLeft = Math.max(0, scrollPosition);
|
|
97
68
|
}, [duration, value, zoomContextValue]);
|
|
98
|
-
return (
|
|
99
|
-
|
|
100
|
-
width:
|
|
69
|
+
return (React.createElement(TimelineContainer, { ref: timeLineContainerRef, className: className },
|
|
70
|
+
React.createElement(TimelineWrapper, { style: {
|
|
71
|
+
width: numberToPxString(zoomContextValue.timelineWrapperWidth),
|
|
101
72
|
} },
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
73
|
+
React.createElement(ZoomContext.Provider, { value: zoomContextValue },
|
|
74
|
+
React.createElement(TimelineCanvas, { ref: canvasRef, duration: duration, withTimeBlocks: withTimeBlocks }),
|
|
75
|
+
React.createElement(TimelineValue, { value: value, canvasRef: canvasRef }),
|
|
76
|
+
React.createElement(RangeSelectorCanvas, { selectedRange: selectedRange, onChange: onChange, onRangeChange: onRangeChange })))));
|
|
106
77
|
};
|
|
107
|
-
exports.Timeline = Timeline;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 = __importDefault(require("react"));
|
|
7
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
-
const TickTimeContainer = styled_components_1.default.span.attrs((props) => ({
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
const TickTimeContainer = styled.span.attrs((props) => ({
|
|
9
4
|
style: {
|
|
10
5
|
left: props.left,
|
|
11
6
|
},
|
|
@@ -23,9 +18,9 @@ const TickTime = ({ start, leftPosition }) => {
|
|
|
23
18
|
const minutes = Math.floor(start / 60);
|
|
24
19
|
let seconds = start - minutes * 60;
|
|
25
20
|
let secondsFormatted = seconds < 10 ? '0' + seconds : seconds.toString();
|
|
26
|
-
return (
|
|
21
|
+
return (React.createElement(TickTimeContainer, { left: leftPosition, className: 'media-timeline-tick-time' },
|
|
27
22
|
minutes,
|
|
28
23
|
":",
|
|
29
24
|
secondsFormatted));
|
|
30
25
|
};
|
|
31
|
-
|
|
26
|
+
export default TickTime;
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
const react_1 = __importDefault(require("react"));
|
|
7
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
-
const TickTime_1 = __importDefault(require("./TickTime"));
|
|
9
|
-
const ZoomContext_1 = require("../ZoomContext/ZoomContext");
|
|
10
|
-
const TickTimeCollectionDisplayContainer = styled_components_1.default.div `
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import TickTime from './TickTime';
|
|
4
|
+
import { ZoomContext } from '../ZoomContext/ZoomContext';
|
|
5
|
+
const TickTimeCollectionDisplayContainer = styled.div `
|
|
11
6
|
position: absolute;
|
|
12
7
|
display: flex;
|
|
13
8
|
align-self: flex-end;
|
|
14
9
|
height: 100%;
|
|
15
10
|
`;
|
|
16
11
|
const TickTimeCollectionDisplay = ({ tickTimes = [], }) => {
|
|
17
|
-
return (
|
|
18
|
-
return (
|
|
12
|
+
return (React.createElement(ZoomContext.Consumer, null, (value) => {
|
|
13
|
+
return (React.createElement(TickTimeCollectionDisplayContainer, null, tickTimes.map((tickTimeValue, index) => {
|
|
19
14
|
const leftPosition = tickTimeValue * value.pixelsInSecond + 'px';
|
|
20
|
-
return (
|
|
15
|
+
return (React.createElement(TickTime, { key: index, start: tickTimeValue, leftPosition: leftPosition }));
|
|
21
16
|
})));
|
|
22
17
|
}));
|
|
23
18
|
};
|
|
24
|
-
|
|
19
|
+
export default TickTimeCollectionDisplay;
|
|
@@ -1,37 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const react_1 = __importStar(require("react"));
|
|
30
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
31
|
-
const ZoomContext_1 = require("../ZoomContext/ZoomContext");
|
|
32
|
-
const TickTimeCollectionDisplay_1 = __importDefault(require("./TickTimeCollectionDisplay"));
|
|
33
|
-
const drawTimeBlocksOnCanvas_1 = require("./drawTimeBlocksOnCanvas");
|
|
34
|
-
const OverlayCanvas = styled_components_1.default.canvas `
|
|
1
|
+
import React, { forwardRef, useContext, useEffect, useImperativeHandle, useRef, } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { ZoomContext } from '../ZoomContext/ZoomContext';
|
|
4
|
+
import TickTimeCollectionDisplay from './TickTimeCollectionDisplay';
|
|
5
|
+
import { drawTimeBlocksOnCanvas } from './drawTimeBlocksOnCanvas';
|
|
6
|
+
const OverlayCanvas = styled.canvas `
|
|
35
7
|
position: absolute;
|
|
36
8
|
top: 0;
|
|
37
9
|
left: 0;
|
|
@@ -39,9 +11,9 @@ const OverlayCanvas = styled_components_1.default.canvas `
|
|
|
39
11
|
height: 100%;
|
|
40
12
|
color: #c9c9c9;
|
|
41
13
|
`;
|
|
42
|
-
const TimelineCanvas =
|
|
43
|
-
const internalCanvasRef =
|
|
44
|
-
const zoomContextValue =
|
|
14
|
+
const TimelineCanvas = forwardRef(({ duration, withTimeBlocks }, ref) => {
|
|
15
|
+
const internalCanvasRef = useRef(null);
|
|
16
|
+
const zoomContextValue = useContext(ZoomContext);
|
|
45
17
|
const blockStartingTimes = (() => {
|
|
46
18
|
if (!withTimeBlocks || !zoomContextValue.blockOffset)
|
|
47
19
|
return [];
|
|
@@ -56,17 +28,17 @@ const TimelineCanvas = (0, react_1.forwardRef)(({ duration, withTimeBlocks }, re
|
|
|
56
28
|
return blockStartingTimes;
|
|
57
29
|
})();
|
|
58
30
|
// Pass the internal ref's current value directly to the forwarded ref
|
|
59
|
-
|
|
60
|
-
|
|
31
|
+
useImperativeHandle(ref, () => internalCanvasRef.current);
|
|
32
|
+
useEffect(() => {
|
|
61
33
|
const canvas = internalCanvasRef.current;
|
|
62
34
|
// https://stackoverflow.com/questions/8696631/canvas-drawings-like-lines-are-blurry
|
|
63
35
|
canvas.width = canvas.offsetWidth;
|
|
64
36
|
canvas.height = canvas.offsetHeight;
|
|
65
37
|
if (withTimeBlocks)
|
|
66
|
-
|
|
38
|
+
drawTimeBlocksOnCanvas(canvas, blockStartingTimes, zoomContextValue);
|
|
67
39
|
}, [blockStartingTimes, withTimeBlocks, zoomContextValue]);
|
|
68
|
-
return (
|
|
69
|
-
|
|
70
|
-
withTimeBlocks && (
|
|
40
|
+
return (React.createElement(React.Fragment, null,
|
|
41
|
+
React.createElement(OverlayCanvas, { ref: internalCanvasRef, className: 'media-timeline-value-line-canvas' }),
|
|
42
|
+
withTimeBlocks && (React.createElement(TickTimeCollectionDisplay, { tickTimes: blockStartingTimes }))));
|
|
71
43
|
});
|
|
72
|
-
|
|
44
|
+
export default TimelineCanvas;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.drawTimeBlocksOnCanvas = void 0;
|
|
4
|
-
const utils_1 = require("../utils/utils");
|
|
5
|
-
const drawTimeBlocksOnCanvas = (canvas, blockStartingTimes, zoomContextValue) => {
|
|
1
|
+
import { secondsToPixel } from '../utils/utils';
|
|
2
|
+
export const drawTimeBlocksOnCanvas = (canvas, blockStartingTimes, zoomContextValue) => {
|
|
6
3
|
const blockHeight = 20;
|
|
7
4
|
const context = canvas.getContext('2d');
|
|
8
5
|
// draw top line
|
|
@@ -14,8 +11,8 @@ const drawTimeBlocksOnCanvas = (canvas, blockStartingTimes, zoomContextValue) =>
|
|
|
14
11
|
.getPropertyValue('color');
|
|
15
12
|
context.stroke();
|
|
16
13
|
for (const blockStartingTime of blockStartingTimes) {
|
|
17
|
-
const x0Pixel =
|
|
18
|
-
const x1Pixel =
|
|
14
|
+
const x0Pixel = secondsToPixel(zoomContextValue, blockStartingTime);
|
|
15
|
+
const x1Pixel = secondsToPixel(zoomContextValue, blockStartingTime + zoomContextValue.blockOffset);
|
|
19
16
|
context.beginPath();
|
|
20
17
|
// draw left line
|
|
21
18
|
context.moveTo(x0Pixel, canvas.height);
|
|
@@ -29,4 +26,3 @@ const drawTimeBlocksOnCanvas = (canvas, blockStartingTimes, zoomContextValue) =>
|
|
|
29
26
|
context.stroke();
|
|
30
27
|
}
|
|
31
28
|
};
|
|
32
|
-
exports.drawTimeBlocksOnCanvas = drawTimeBlocksOnCanvas;
|
|
@@ -1,80 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.TimelineValue = void 0;
|
|
30
|
-
const react_1 = __importStar(require("react"));
|
|
31
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
-
const utils_1 = require("../utils/utils");
|
|
33
|
-
const ZoomContext_1 = require("../ZoomContext/ZoomContext");
|
|
34
|
-
const PreValueLine = styled_components_1.default.span `
|
|
1
|
+
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { getComputedElementWidth, numberToPxString, secondsToPixel, } from '../utils/utils';
|
|
4
|
+
import { ZoomContext } from '../ZoomContext/ZoomContext';
|
|
5
|
+
const PreValueLine = styled.span `
|
|
35
6
|
position: absolute;
|
|
36
7
|
left: 0;
|
|
37
8
|
height: 100%;
|
|
38
9
|
`;
|
|
39
|
-
const ValueLine =
|
|
10
|
+
const ValueLine = styled.span `
|
|
40
11
|
position: absolute;
|
|
41
12
|
width: 1px;
|
|
42
13
|
height: 100%;
|
|
43
14
|
background-color: #575757;
|
|
44
15
|
`;
|
|
45
|
-
const PostValueLine =
|
|
16
|
+
const PostValueLine = styled.span `
|
|
46
17
|
position: absolute;
|
|
47
18
|
height: 100%;
|
|
48
19
|
`;
|
|
49
|
-
const TimelineValue = ({ canvasRef, value }) => {
|
|
50
|
-
const preValueLineRef =
|
|
51
|
-
const valueLineRef =
|
|
52
|
-
const postValueLineRef =
|
|
53
|
-
const zoomContextValue =
|
|
54
|
-
const showValueLine =
|
|
20
|
+
export const TimelineValue = ({ canvasRef, value }) => {
|
|
21
|
+
const preValueLineRef = useRef(null);
|
|
22
|
+
const valueLineRef = useRef(null);
|
|
23
|
+
const postValueLineRef = useRef(null);
|
|
24
|
+
const zoomContextValue = useContext(ZoomContext);
|
|
25
|
+
const showValueLine = useCallback(() => {
|
|
55
26
|
const canvas = canvasRef.current;
|
|
56
27
|
const preValueLineElement = preValueLineRef.current;
|
|
57
28
|
const valueLineElement = valueLineRef.current;
|
|
58
29
|
const postValueLineElement = postValueLineRef.current;
|
|
59
|
-
const valueLineWidth =
|
|
60
|
-
const linePosition =
|
|
30
|
+
const valueLineWidth = getComputedElementWidth(valueLineElement);
|
|
31
|
+
const linePosition = secondsToPixel(zoomContextValue, value);
|
|
61
32
|
const valueLinePositionBeginningConsideringWidth = linePosition - valueLineWidth / 2;
|
|
62
33
|
// configure preValueLineElement
|
|
63
|
-
preValueLineElement.style.width =
|
|
34
|
+
preValueLineElement.style.width = numberToPxString(valueLinePositionBeginningConsideringWidth);
|
|
64
35
|
// configure valueLineElement
|
|
65
|
-
valueLineElement.style.left =
|
|
36
|
+
valueLineElement.style.left = numberToPxString(valueLinePositionBeginningConsideringWidth);
|
|
66
37
|
// configure postValueLineElement
|
|
67
38
|
const postValueLinePosition = valueLinePositionBeginningConsideringWidth + valueLineWidth;
|
|
68
39
|
const postValueLineWidth = canvas.width - postValueLinePosition;
|
|
69
|
-
postValueLineElement.style.left =
|
|
70
|
-
postValueLineElement.style.width =
|
|
40
|
+
postValueLineElement.style.left = numberToPxString(postValueLinePosition);
|
|
41
|
+
postValueLineElement.style.width = numberToPxString(postValueLineWidth);
|
|
71
42
|
}, [canvasRef, value, zoomContextValue]);
|
|
72
|
-
|
|
43
|
+
useEffect(() => {
|
|
73
44
|
showValueLine();
|
|
74
45
|
}, [showValueLine]);
|
|
75
|
-
return (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
46
|
+
return (React.createElement(React.Fragment, null,
|
|
47
|
+
React.createElement(PreValueLine, { ref: preValueLineRef, className: 'media-timeline-pre-value-line' }),
|
|
48
|
+
React.createElement(ValueLine, { ref: valueLineRef, className: 'media-timeline-value-line' }),
|
|
49
|
+
React.createElement(PostValueLine, { ref: postValueLineRef, className: 'media-timeline-post-value-line' })));
|
|
79
50
|
};
|
|
80
|
-
exports.TimelineValue = TimelineValue;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ZoomContext = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
exports.ZoomContext = react_1.default.createContext(null);
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const ZoomContext = React.createContext(null);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zoomLevelConfigurations = void 0;
|
|
4
1
|
//[blockOffset, pixelsInSecond] when zoomLevel === 0, each block has an offset of 20 seconds, and each second has a width of 7px.
|
|
5
|
-
|
|
2
|
+
export const zoomLevelConfigurations = [
|
|
6
3
|
[20, 7],
|
|
7
4
|
[10, 10],
|
|
8
5
|
[10, 15],
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Timeline"), exports);
|
|
1
|
+
export * from './Timeline';
|
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBlockOffsetForZoomLevel = exports.getTimelineWrapperWidth = exports.numberToPxString = exports.getComputedElementWidth = exports.pixelToSeconds = exports.secondsToPixel = void 0;
|
|
4
|
-
const secondsToPixel = (zoomContextValue, seconds) => {
|
|
1
|
+
export const secondsToPixel = (zoomContextValue, seconds) => {
|
|
5
2
|
return zoomContextValue.pixelsInSecond * seconds;
|
|
6
3
|
};
|
|
7
|
-
|
|
8
|
-
const pixelToSeconds = (zoomContextValue, pixel) => {
|
|
4
|
+
export const pixelToSeconds = (zoomContextValue, pixel) => {
|
|
9
5
|
const seconds = pixel / zoomContextValue.pixelsInSecond;
|
|
10
6
|
return Math.round((seconds + Number.EPSILON) * 100) / 100;
|
|
11
7
|
};
|
|
12
|
-
|
|
13
|
-
const getComputedElementWidth = (element) => {
|
|
8
|
+
export const getComputedElementWidth = (element) => {
|
|
14
9
|
const elementWidthCSSProperty = window
|
|
15
10
|
.getComputedStyle(element)
|
|
16
11
|
.getPropertyValue('width')
|
|
17
12
|
.replace(/[^-\d]/g, '');
|
|
18
13
|
return parseInt(elementWidthCSSProperty);
|
|
19
14
|
};
|
|
20
|
-
|
|
21
|
-
const numberToPxString = (number) => {
|
|
15
|
+
export const numberToPxString = (number) => {
|
|
22
16
|
return `${number}px`;
|
|
23
17
|
};
|
|
24
|
-
|
|
25
|
-
const getTimelineWrapperWidth = (timeLineContainerWidth, zoomLevel) => {
|
|
18
|
+
export const getTimelineWrapperWidth = (timeLineContainerWidth, zoomLevel) => {
|
|
26
19
|
return timeLineContainerWidth * Math.pow(1.25, zoomLevel) - 2; //-2px to account for the border
|
|
27
20
|
};
|
|
28
|
-
|
|
29
|
-
function getBlockOffsetForZoomLevel(zoomLevel, duration, timelineWrapperWidth) {
|
|
21
|
+
export function getBlockOffsetForZoomLevel(zoomLevel, duration, timelineWrapperWidth) {
|
|
30
22
|
const offsets = [10, 5, 5, 5, 2, 2, 2, 2, 2, 1];
|
|
31
23
|
let optimalOffset = offsets[zoomLevel];
|
|
32
24
|
while ((duration / optimalOffset) * 40 > timelineWrapperWidth) {
|
|
@@ -34,4 +26,3 @@ function getBlockOffsetForZoomLevel(zoomLevel, duration, timelineWrapperWidth) {
|
|
|
34
26
|
}
|
|
35
27
|
return Math.ceil(optimalOffset);
|
|
36
28
|
}
|
|
37
|
-
exports.getBlockOffsetForZoomLevel = getBlockOffsetForZoomLevel;
|