@ldelia/react-media 0.6.2 → 0.6.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.
@@ -3,13 +3,14 @@ import styled from 'styled-components';
3
3
  import { ZoomContext } from '../ZoomContext/ZoomContext';
4
4
  import { pixelToSeconds, secondsToPixel } from '../utils/utils';
5
5
  const OverlayCanvas = styled.canvas `
6
- position: absolute;
7
- top: 0;
8
- left: 0;
9
- width: 100%;
10
- height: 100%;
11
- color: cadetblue;
12
- cursor: pointer;
6
+ position: absolute;
7
+ top: 0;
8
+ left: 0;
9
+ width: 100%;
10
+ height: 100%;
11
+ color: cadetblue;
12
+ cursor: pointer;
13
+ z-index: 2; // Ensure this canvas is on top of the TimeLineValue, otherwise we won't be able to change the range until the current TimelineValue position
13
14
  `;
14
15
  var DragMode;
15
16
  (function (DragMode) {
@@ -22,7 +23,10 @@ const RESIZE_HANDLE_WIDTH = 10; // Width in pixels for the resize handle detecti
22
23
  const RangeSelectorCanvas = ({ selectedRange, onChange, onRangeChange, }) => {
23
24
  const canvasRef = useRef(null);
24
25
  const zoomContextValue = useContext(ZoomContext);
25
- const [selection, setSelection] = useState({ start: null, end: null });
26
+ const [selection, setSelection] = useState({
27
+ start: null,
28
+ end: null,
29
+ });
26
30
  const [dragMode, setDragMode] = useState(DragMode.NONE);
27
31
  const [cursorStyle, setCursorStyle] = useState('pointer');
28
32
  const getMousePointerPixelPosition = (e) => {
@@ -112,12 +116,13 @@ const RangeSelectorCanvas = ({ selectedRange, onChange, onRangeChange, }) => {
112
116
  });
113
117
  }
114
118
  }
115
- else if (dragMode === DragMode.RESIZE_START || dragMode === DragMode.RESIZE_END) {
119
+ else if (dragMode === DragMode.RESIZE_START ||
120
+ dragMode === DragMode.RESIZE_END) {
116
121
  // Resizing completed
117
122
  if (selection.start !== null && selection.end !== null) {
118
123
  const curatedSelection = [
119
124
  Math.min(selection.start, selection.end),
120
- Math.max(selection.start, selection.end)
125
+ Math.max(selection.start, selection.end),
121
126
  ];
122
127
  onRangeChange(curatedSelection);
123
128
  }
@@ -136,19 +141,19 @@ const RangeSelectorCanvas = ({ selectedRange, onChange, onRangeChange, }) => {
136
141
  const pixel = getMousePointerPixelPosition(event);
137
142
  const seconds = pixelToSeconds(zoomContextValue, pixel);
138
143
  if (dragMode === DragMode.CREATE) {
139
- setSelection(prevSelection => ({
144
+ setSelection((prevSelection) => ({
140
145
  start: prevSelection.start,
141
146
  end: seconds,
142
147
  }));
143
148
  }
144
149
  else if (dragMode === DragMode.RESIZE_START) {
145
- setSelection(prevSelection => ({
150
+ setSelection((prevSelection) => ({
146
151
  start: seconds,
147
152
  end: prevSelection.end,
148
153
  }));
149
154
  }
150
155
  else if (dragMode === DragMode.RESIZE_END) {
151
- setSelection(prevSelection => ({
156
+ setSelection((prevSelection) => ({
152
157
  start: prevSelection.start,
153
158
  end: seconds,
154
159
  }));
@@ -159,7 +164,8 @@ const RangeSelectorCanvas = ({ selectedRange, onChange, onRangeChange, }) => {
159
164
  // https://stackoverflow.com/questions/8696631/canvas-drawings-like-lines-are-blurry
160
165
  canvas.width = canvas.offsetWidth;
161
166
  canvas.height = canvas.offsetHeight;
162
- if (selectedRange.length !== 2 || zoomContextValue.timelineWrapperWidth === 0)
167
+ if (selectedRange.length !== 2 ||
168
+ zoomContextValue.timelineWrapperWidth === 0)
163
169
  return;
164
170
  drawRect(secondsToPixel(zoomContextValue, selectedRange[0]), secondsToPixel(zoomContextValue, selectedRange[1]));
165
171
  }, [selectedRange, zoomContextValue]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldelia/react-media",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "A React components collection for media-related features.",
5
5
  "private": false,
6
6
  "keywords": [