@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,43 +0,0 @@
|
|
|
1
|
-
import { secondsToPixel } from '../utils/utils';
|
|
2
|
-
import { ZoomContextType } from '../ZoomContext/ZoomContext';
|
|
3
|
-
|
|
4
|
-
export const drawTimeBlocksOnCanvas = (
|
|
5
|
-
canvas: HTMLCanvasElement,
|
|
6
|
-
blockStartingTimes: number[],
|
|
7
|
-
zoomContextValue: ZoomContextType,
|
|
8
|
-
): void => {
|
|
9
|
-
const blockHeight = 20;
|
|
10
|
-
const context: CanvasRenderingContext2D = canvas.getContext('2d')!;
|
|
11
|
-
|
|
12
|
-
// draw top line
|
|
13
|
-
context.beginPath();
|
|
14
|
-
context.moveTo(0, canvas.height - blockHeight);
|
|
15
|
-
context.lineTo(
|
|
16
|
-
zoomContextValue.timelineWrapperWidth,
|
|
17
|
-
canvas.height - blockHeight,
|
|
18
|
-
);
|
|
19
|
-
context.strokeStyle = window
|
|
20
|
-
.getComputedStyle(canvas)
|
|
21
|
-
.getPropertyValue('color');
|
|
22
|
-
context.stroke();
|
|
23
|
-
|
|
24
|
-
for (const blockStartingTime of blockStartingTimes) {
|
|
25
|
-
const x0Pixel = secondsToPixel(zoomContextValue, blockStartingTime);
|
|
26
|
-
const x1Pixel = secondsToPixel(
|
|
27
|
-
zoomContextValue,
|
|
28
|
-
blockStartingTime + zoomContextValue.blockOffset,
|
|
29
|
-
);
|
|
30
|
-
context.beginPath();
|
|
31
|
-
// draw left line
|
|
32
|
-
context.moveTo(x0Pixel, canvas.height);
|
|
33
|
-
context.lineTo(x0Pixel, canvas.height - blockHeight);
|
|
34
|
-
// draw right line
|
|
35
|
-
context.moveTo(x1Pixel, canvas.height);
|
|
36
|
-
context.lineTo(x1Pixel, canvas.height - blockHeight);
|
|
37
|
-
|
|
38
|
-
context.strokeStyle = window
|
|
39
|
-
.getComputedStyle(canvas)
|
|
40
|
-
.getPropertyValue('color');
|
|
41
|
-
context.stroke();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
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 `
|
|
6
|
-
position: absolute;
|
|
7
|
-
left: 0;
|
|
8
|
-
height: 100%;
|
|
9
|
-
`;
|
|
10
|
-
const ValueLine = styled.span `
|
|
11
|
-
position: absolute;
|
|
12
|
-
width: 1px;
|
|
13
|
-
height: 100%;
|
|
14
|
-
background-color: #575757;
|
|
15
|
-
`;
|
|
16
|
-
const PostValueLine = styled.span `
|
|
17
|
-
position: absolute;
|
|
18
|
-
height: 100%;
|
|
19
|
-
`;
|
|
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(() => {
|
|
26
|
-
const canvas = canvasRef.current;
|
|
27
|
-
const preValueLineElement = preValueLineRef.current;
|
|
28
|
-
const valueLineElement = valueLineRef.current;
|
|
29
|
-
const postValueLineElement = postValueLineRef.current;
|
|
30
|
-
const valueLineWidth = getComputedElementWidth(valueLineElement);
|
|
31
|
-
const linePosition = secondsToPixel(zoomContextValue, value);
|
|
32
|
-
const valueLinePositionBeginningConsideringWidth = linePosition - valueLineWidth / 2;
|
|
33
|
-
// configure preValueLineElement
|
|
34
|
-
preValueLineElement.style.width = numberToPxString(valueLinePositionBeginningConsideringWidth);
|
|
35
|
-
// configure valueLineElement
|
|
36
|
-
valueLineElement.style.left = numberToPxString(valueLinePositionBeginningConsideringWidth);
|
|
37
|
-
// configure postValueLineElement
|
|
38
|
-
const postValueLinePosition = valueLinePositionBeginningConsideringWidth + valueLineWidth;
|
|
39
|
-
const postValueLineWidth = canvas.width - postValueLinePosition;
|
|
40
|
-
postValueLineElement.style.left = numberToPxString(postValueLinePosition);
|
|
41
|
-
postValueLineElement.style.width = numberToPxString(postValueLineWidth);
|
|
42
|
-
}, [canvasRef, value, zoomContextValue]);
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
showValueLine();
|
|
45
|
-
}, [showValueLine]);
|
|
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' })));
|
|
50
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import {
|
|
4
|
-
getComputedElementWidth,
|
|
5
|
-
numberToPxString,
|
|
6
|
-
secondsToPixel,
|
|
7
|
-
} from '../utils/utils';
|
|
8
|
-
import { ZoomContext, ZoomContextType } from '../ZoomContext/ZoomContext';
|
|
9
|
-
|
|
10
|
-
const PreValueLine = styled.span`
|
|
11
|
-
position: absolute;
|
|
12
|
-
left: 0;
|
|
13
|
-
height: 100%;
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
const ValueLine = styled.span`
|
|
17
|
-
position: absolute;
|
|
18
|
-
width: 1px;
|
|
19
|
-
height: 100%;
|
|
20
|
-
background-color: #575757;
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
const PostValueLine = styled.span`
|
|
24
|
-
position: absolute;
|
|
25
|
-
height: 100%;
|
|
26
|
-
`;
|
|
27
|
-
|
|
28
|
-
interface Props {
|
|
29
|
-
canvasRef: React.RefObject<HTMLCanvasElement>;
|
|
30
|
-
value: number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const TimelineValue: React.FC<Props> = ({ canvasRef, value }) => {
|
|
34
|
-
const preValueLineRef = useRef(null);
|
|
35
|
-
const valueLineRef = useRef(null);
|
|
36
|
-
const postValueLineRef = useRef(null);
|
|
37
|
-
|
|
38
|
-
const zoomContextValue: ZoomContextType = useContext(ZoomContext);
|
|
39
|
-
|
|
40
|
-
const showValueLine = useCallback(() => {
|
|
41
|
-
const canvas: HTMLCanvasElement = canvasRef.current!;
|
|
42
|
-
|
|
43
|
-
const preValueLineElement: HTMLElement = preValueLineRef.current!;
|
|
44
|
-
const valueLineElement: HTMLElement = valueLineRef.current!;
|
|
45
|
-
const postValueLineElement: HTMLElement = postValueLineRef.current!;
|
|
46
|
-
|
|
47
|
-
const valueLineWidth: number = getComputedElementWidth(valueLineElement);
|
|
48
|
-
const linePosition: number = secondsToPixel(zoomContextValue, value);
|
|
49
|
-
const valueLinePositionBeginningConsideringWidth: number =
|
|
50
|
-
linePosition - valueLineWidth / 2;
|
|
51
|
-
|
|
52
|
-
// configure preValueLineElement
|
|
53
|
-
preValueLineElement.style.width = numberToPxString(
|
|
54
|
-
valueLinePositionBeginningConsideringWidth,
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
// configure valueLineElement
|
|
58
|
-
valueLineElement.style.left = numberToPxString(
|
|
59
|
-
valueLinePositionBeginningConsideringWidth,
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
// configure postValueLineElement
|
|
63
|
-
const postValueLinePosition =
|
|
64
|
-
valueLinePositionBeginningConsideringWidth + valueLineWidth;
|
|
65
|
-
const postValueLineWidth = canvas.width - postValueLinePosition;
|
|
66
|
-
postValueLineElement.style.left = numberToPxString(postValueLinePosition);
|
|
67
|
-
postValueLineElement.style.width = numberToPxString(postValueLineWidth);
|
|
68
|
-
}, [canvasRef, value, zoomContextValue]);
|
|
69
|
-
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
showValueLine();
|
|
72
|
-
}, [showValueLine]);
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<>
|
|
76
|
-
<PreValueLine
|
|
77
|
-
ref={preValueLineRef}
|
|
78
|
-
className={'media-timeline-pre-value-line'}
|
|
79
|
-
/>
|
|
80
|
-
<ValueLine ref={valueLineRef} className={'media-timeline-value-line'} />
|
|
81
|
-
<PostValueLine
|
|
82
|
-
ref={postValueLineRef}
|
|
83
|
-
className={'media-timeline-post-value-line'}
|
|
84
|
-
/>
|
|
85
|
-
</>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//[blockOffset, pixelsInSecond] when zoomLevel === 0, each block has an offset of 20 seconds, and each second has a width of 7px.
|
|
2
|
-
export const zoomLevelConfigurations = [
|
|
3
|
-
[20, 7],
|
|
4
|
-
[10, 10],
|
|
5
|
-
[10, 15],
|
|
6
|
-
[5, 20],
|
|
7
|
-
[5, 25],
|
|
8
|
-
[2, 35],
|
|
9
|
-
[2, 50],
|
|
10
|
-
[1, 60],
|
|
11
|
-
[1, 75],
|
|
12
|
-
[1, 90],
|
|
13
|
-
];
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//[blockOffset, pixelsInSecond] when zoomLevel === 0, each block has an offset of 20 seconds, and each second has a width of 7px.
|
|
2
|
-
export const zoomLevelConfigurations: number[][] = [
|
|
3
|
-
[20, 7],
|
|
4
|
-
[10, 10],
|
|
5
|
-
[10, 15],
|
|
6
|
-
[5, 20],
|
|
7
|
-
[5, 25],
|
|
8
|
-
[2, 35],
|
|
9
|
-
[2, 50],
|
|
10
|
-
[1, 60],
|
|
11
|
-
[1, 75],
|
|
12
|
-
[1, 90],
|
|
13
|
-
];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Timeline';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Timeline';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const secondsToPixel = (zoomContextValue, seconds) => {
|
|
2
|
-
return zoomContextValue.pixelsInSecond * seconds;
|
|
3
|
-
};
|
|
4
|
-
export const pixelToSeconds = (zoomContextValue, pixel) => {
|
|
5
|
-
const seconds = pixel / zoomContextValue.pixelsInSecond;
|
|
6
|
-
return Math.round((seconds + Number.EPSILON) * 100) / 100;
|
|
7
|
-
};
|
|
8
|
-
export const getComputedElementWidth = (element) => {
|
|
9
|
-
const elementWidthCSSProperty = window
|
|
10
|
-
.getComputedStyle(element)
|
|
11
|
-
.getPropertyValue('width')
|
|
12
|
-
.replace(/[^-\d]/g, '');
|
|
13
|
-
return parseInt(elementWidthCSSProperty);
|
|
14
|
-
};
|
|
15
|
-
export const numberToPxString = (number) => {
|
|
16
|
-
return `${number}px`;
|
|
17
|
-
};
|
|
18
|
-
export const getTimelineWrapperWidth = (timeLineContainerWidth, zoomLevel) => {
|
|
19
|
-
return timeLineContainerWidth * Math.pow(1.25, zoomLevel) - 2; //-2px to account for the border
|
|
20
|
-
};
|
|
21
|
-
export function getBlockOffsetForZoomLevel(zoomLevel, duration, timelineWrapperWidth) {
|
|
22
|
-
const offsets = [10, 5, 5, 5, 2, 2, 2, 2, 2, 1];
|
|
23
|
-
let optimalOffset = offsets[zoomLevel];
|
|
24
|
-
while ((duration / optimalOffset) * 40 > timelineWrapperWidth) {
|
|
25
|
-
optimalOffset = optimalOffset * 1.25;
|
|
26
|
-
}
|
|
27
|
-
return Math.ceil(optimalOffset);
|
|
28
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ZoomContextType } from '../ZoomContext/ZoomContext';
|
|
2
|
-
|
|
3
|
-
export const secondsToPixel = (
|
|
4
|
-
zoomContextValue: ZoomContextType,
|
|
5
|
-
seconds: number,
|
|
6
|
-
) => {
|
|
7
|
-
return zoomContextValue.pixelsInSecond * seconds;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const pixelToSeconds = (
|
|
11
|
-
zoomContextValue: ZoomContextType,
|
|
12
|
-
pixel: number,
|
|
13
|
-
) => {
|
|
14
|
-
const seconds = pixel / zoomContextValue.pixelsInSecond;
|
|
15
|
-
return Math.round((seconds + Number.EPSILON) * 100) / 100;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const getComputedElementWidth = (element: HTMLElement): number => {
|
|
19
|
-
const elementWidthCSSProperty: string = window
|
|
20
|
-
.getComputedStyle(element)
|
|
21
|
-
.getPropertyValue('width')
|
|
22
|
-
.replace(/[^-\d]/g, '');
|
|
23
|
-
return parseInt(elementWidthCSSProperty);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const numberToPxString = (number: number): string => {
|
|
27
|
-
return `${number}px`;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const getTimelineWrapperWidth = (
|
|
31
|
-
timeLineContainerWidth: number,
|
|
32
|
-
zoomLevel: number,
|
|
33
|
-
): number => {
|
|
34
|
-
return timeLineContainerWidth * Math.pow(1.25, zoomLevel) - 2; //-2px to account for the border
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export function getBlockOffsetForZoomLevel(
|
|
38
|
-
zoomLevel: number,
|
|
39
|
-
duration: number,
|
|
40
|
-
timelineWrapperWidth: number,
|
|
41
|
-
): number {
|
|
42
|
-
const offsets = [10, 5, 5, 5, 2, 2, 2, 2, 2, 1];
|
|
43
|
-
|
|
44
|
-
let optimalOffset = offsets[zoomLevel];
|
|
45
|
-
while ((duration / optimalOffset) * 40 > timelineWrapperWidth) {
|
|
46
|
-
optimalOffset = optimalOffset * 1.25;
|
|
47
|
-
}
|
|
48
|
-
return Math.ceil(optimalOffset);
|
|
49
|
-
}
|
package/src/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './components';
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './components';
|
package/src/modules.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare module '*.md';
|
package/src/react-app-env.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
|
-
/// <reference types="react-dom" />
|
|
4
|
-
|
|
5
|
-
declare namespace NodeJS {
|
|
6
|
-
interface ProcessEnv {
|
|
7
|
-
readonly NODE_ENV: 'development' | 'production' | 'test';
|
|
8
|
-
readonly PUBLIC_URL: string;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare module '*.avif' {
|
|
13
|
-
const src: string;
|
|
14
|
-
export default src;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
declare module '*.bmp' {
|
|
18
|
-
const src: string;
|
|
19
|
-
export default src;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare module '*.gif' {
|
|
23
|
-
const src: string;
|
|
24
|
-
export default src;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare module '*.jpg' {
|
|
28
|
-
const src: string;
|
|
29
|
-
export default src;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
declare module '*.jpeg' {
|
|
33
|
-
const src: string;
|
|
34
|
-
export default src;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
declare module '*.png' {
|
|
38
|
-
const src: string;
|
|
39
|
-
export default src;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
declare module '*.webp' {
|
|
43
|
-
const src: string;
|
|
44
|
-
export default src;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
declare module '*.svg' {
|
|
48
|
-
import * as React from 'react';
|
|
49
|
-
|
|
50
|
-
export const ReactComponent: React.FunctionComponent<React.SVGProps<
|
|
51
|
-
SVGSVGElement
|
|
52
|
-
> & { title?: string }>;
|
|
53
|
-
|
|
54
|
-
const src: string;
|
|
55
|
-
export default src;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
declare module '*.module.css' {
|
|
59
|
-
const classes: { readonly [key: string]: string };
|
|
60
|
-
export default classes;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
declare module '*.module.scss' {
|
|
64
|
-
const classes: { readonly [key: string]: string };
|
|
65
|
-
export default classes;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
declare module '*.module.sass' {
|
|
69
|
-
const classes: { readonly [key: string]: string };
|
|
70
|
-
export default classes;
|
|
71
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import 'react';
|
|
2
|
-
|
|
3
|
-
declare module 'react' {
|
|
4
|
-
interface FunctionComponent<P = {}> {
|
|
5
|
-
__docgenInfo?: {
|
|
6
|
-
description?: string;
|
|
7
|
-
displayName?: string;
|
|
8
|
-
props?: {
|
|
9
|
-
[key: string]: {
|
|
10
|
-
description?: string;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
tsType?: {
|
|
13
|
-
name: string;
|
|
14
|
-
elements?: { name: string }[]; // Handle array types
|
|
15
|
-
raw?: string;
|
|
16
|
-
type?: string; // Handle various types
|
|
17
|
-
};
|
|
18
|
-
defaultValue?: {
|
|
19
|
-
value: string;
|
|
20
|
-
computed: boolean;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
methods?: {
|
|
25
|
-
name: string;
|
|
26
|
-
type?: string; // Handle method types
|
|
27
|
-
signature?: {
|
|
28
|
-
arguments: {
|
|
29
|
-
type: { name: string };
|
|
30
|
-
name: string;
|
|
31
|
-
}[];
|
|
32
|
-
return: { name: string };
|
|
33
|
-
}; // Handle method signatures
|
|
34
|
-
}[];
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
package/src/setupTests.js
DELETED
package/src/setupTests.ts
DELETED