@cloud-app-dev/vidc 3.0.17 → 3.0.19

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.
Files changed (78) hide show
  1. package/.umirc.ts +1 -1
  2. package/es/CustomRenderSelect/index.d.ts +1 -1
  3. package/es/CustomRenderSelect/index.js +3 -3
  4. package/es/LoaderScript/utils.js +1 -0
  5. package/es/Map/LevelCenter/DragMarker/index.d.ts +1 -4
  6. package/es/Map/LevelCenter/DragMarker/index.js +2 -5
  7. package/es/Map/LevelCenter/index.js +13 -2
  8. package/es/Map/SinglePoint/index.d.ts +10 -3
  9. package/es/Map/SinglePoint/index.js +37 -15
  10. package/es/Map/hook/useMapEvent.js +9 -8
  11. package/es/Map/index.d.ts +1 -1
  12. package/es/Player/api/index.d.ts +5 -1
  13. package/es/Player/api/index.js +36 -24
  14. package/es/Player/context.d.ts +21 -0
  15. package/es/Player/context.js +16 -0
  16. package/es/Player/contraller_bar/contraller_event.d.ts +1 -4
  17. package/es/Player/contraller_bar/contraller_event.js +37 -28
  18. package/es/Player/contraller_bar/index.d.ts +2 -7
  19. package/es/Player/contraller_bar/index.js +4 -12
  20. package/es/Player/contraller_bar/left_bar.d.ts +2 -7
  21. package/es/Player/contraller_bar/left_bar.js +29 -33
  22. package/es/Player/contraller_bar/right_bar.d.ts +1 -6
  23. package/es/Player/contraller_bar/right_bar.js +6 -3
  24. package/es/Player/contraller_bar/time.d.ts +3 -0
  25. package/es/Player/contraller_bar/time.js +34 -0
  26. package/es/Player/contraller_bar/useBarStatus.js +17 -24
  27. package/es/Player/contraller_bar/volume.d.ts +9 -0
  28. package/es/Player/contraller_bar/volume.js +86 -0
  29. package/es/Player/demo.js +5 -1
  30. package/es/Player/event/errorEvent.js +34 -43
  31. package/es/Player/event/eventName.d.ts +17 -2
  32. package/es/Player/event/eventName.js +5 -1
  33. package/es/Player/event/index.d.ts +2 -0
  34. package/es/Player/event/index.js +55 -3
  35. package/es/Player/fps_play.d.ts +11 -0
  36. package/es/Player/fps_play.js +99 -0
  37. package/es/Player/frontend_player.js +0 -2
  38. package/es/Player/frontend_timeline.d.ts +1 -5
  39. package/es/Player/frontend_timeline.js +14 -11
  40. package/es/Player/live_heart.js +1 -1
  41. package/es/Player/message.js +69 -84
  42. package/es/Player/player.d.ts +15 -15
  43. package/es/Player/segment_player.js +12 -29
  44. package/es/Player/segment_timeline.d.ts +1 -6
  45. package/es/Player/segment_timeline.js +56 -11
  46. package/es/Player/single_player.js +80 -35
  47. package/es/Player/style/bar.css +2 -1
  48. package/es/Player/style/iconfont.js +15 -16
  49. package/es/Player/style/index.css +8 -0
  50. package/es/Player/style/timeline.css +7 -0
  51. package/es/Player/style/volume.css +19 -0
  52. package/es/Player/timeline.d.ts +1 -1
  53. package/es/Player/timeline.js +26 -37
  54. package/es/Player/util.d.ts +2 -1
  55. package/es/Player/util.js +10 -6
  56. package/es/ScreenPlayer/Live.js +0 -1
  57. package/es/ScreenPlayer/LiveTools.js +7 -27
  58. package/es/ScreenPlayer/PlayerWithExt.d.ts +1 -1
  59. package/es/ScreenPlayer/PlayerWithExt.js +2 -4
  60. package/es/ScreenPlayer/Record.js +0 -1
  61. package/es/ScreenPlayer/RecordTools.js +31 -16
  62. package/es/ScreenPlayer/ScreenSelect.js +2 -2
  63. package/es/ScreenPlayer/TimeMode.js +1 -1
  64. package/es/ScreenPlayer/demo2.js +1 -1
  65. package/es/ScreenPlayer/index.css +17 -8
  66. package/es/ScreenPlayer/utils.js +4 -4
  67. package/es/index.d.ts +1 -0
  68. package/es/index.js +1 -0
  69. package/es/useRafInterval/index.d.ts +5 -0
  70. package/es/useRafInterval/index.js +94 -0
  71. package/icon-fix.js +31 -0
  72. package/package.json +1 -1
  73. package/es/Map/SinglePoint/Marker/index.d.ts +0 -7
  74. package/es/Map/SinglePoint/Marker/index.js +0 -29
  75. package/es/Player/event/browserTabEvent.d.ts +0 -9
  76. package/es/Player/event/browserTabEvent.js +0 -57
  77. package/es/ScreenPlayer/TimeSlider.d.ts +0 -129
  78. package/es/ScreenPlayer/TimeSlider.js +0 -556
@@ -1,129 +0,0 @@
1
- import { ISegmentType } from '../Player/player';
2
- export interface ITimeSliderOptions {
3
- hours_per_ruler?: number;
4
- start_timestamp?: number;
5
- timecell?: TimeCellItem[];
6
- current_timestamp?: number;
7
- onTimeChange?: (time: number, outTimeline?: boolean) => void;
8
- onHoursPerChange?: (hour: number) => void;
9
- }
10
- export declare type TimeCellItem = ISegmentType;
11
- export default class TimeSlider {
12
- canvas: HTMLCanvasElement;
13
- options: ITimeSliderOptions;
14
- canvansW: number;
15
- canVansH: number;
16
- minutes_per_step: number[];
17
- graduation_step: number;
18
- hours_per_ruler: number;
19
- start_timestamp: number;
20
- distance_between_gtitle: number;
21
- zoom: number;
22
- g_isMousedown: boolean;
23
- g_isMousemove: boolean;
24
- g_mousedownCursor: number;
25
- current_timestamp: number;
26
- timecell: TimeCellItem[];
27
- domLeft: number;
28
- constructor(canvas: HTMLCanvasElement, options: ITimeSliderOptions);
29
- get ctx(): CanvasRenderingContext2D;
30
- init(start_timestamp: number, timecell: TimeCellItem[], redrawFlag: boolean): void;
31
- drawCurrentLine(): void;
32
- drawCellBg(): void;
33
- get_line_sizes(start_timestamp: number): {
34
- num_steps: number;
35
- px_offset: number;
36
- ms_per_step: number;
37
- px_per_step: number;
38
- min_per_step: number;
39
- medium_step: number;
40
- ms_offset: number;
41
- px_per_ms: number;
42
- };
43
- add_graduations(start_timestamp: number): void;
44
- ms_to_next_step(timestamp: number, step: number): number;
45
- /**
46
- * 返回时间轴上刻度的时间
47
- * @param {*} datetime new Date 格式
48
- */
49
- graduation_title(datetime: Date): string;
50
- /**
51
- * 绘制线
52
- * @param {*} beginX
53
- * @param {*} beginY
54
- * @param {*} endX
55
- * @param {*} endY
56
- * @param {*} color
57
- * @param {*} width
58
- */
59
- drawLine(beginX: number, beginY: number, endX: number, endY: number, color: string, width: number): void;
60
- /**
61
- * 添加录像段
62
- * @param {*} cells 录像数组
63
- */
64
- add_cells(cells: TimeCellItem[]): void;
65
- /**
66
- * 绘制录像块
67
- * @param {*} cell cell包括beginTime ms;endTime ms;style
68
- */
69
- draw_cell(cell: TimeCellItem): void;
70
- /**·
71
- * 时间轴事件
72
- */
73
- add_events(): void;
74
- remove_events(): void;
75
- destory(): void;
76
- /**
77
- * 拖动/点击 mousedown事件
78
- */
79
- mousedownFunc: (e: MouseEvent) => void;
80
- /**
81
- * 鼠标移出隐藏时间 mouseout事件
82
- * @param {*} e
83
- */
84
- mouseoutFunc: () => void;
85
- /**
86
- * 拖动/鼠标hover显示 mousemove事件
87
- */
88
- mousemoveFunc: (e: MouseEvent) => void;
89
- /**
90
- * 拖动/鼠标hover显示
91
- */
92
- mousemoveFunc2: (e: MouseEvent) => void;
93
- /**
94
- * 点击 mouseup事件
95
- */
96
- mouseupFunc: (e: MouseEvent) => void;
97
- /**
98
- * 拖动停止 mouseup事件
99
- */
100
- mouseupFunc2: () => void;
101
- /**
102
- * 返回 2018-01-01 10:00:00 格式时间
103
- * @param {*} time
104
- */
105
- changeTime(time: number): string;
106
- /**
107
- * 设置时间,让这个时间点跳到中间红线处
108
- * @param {*} time 单位ms
109
- */
110
- set_time_to_middle(time: number): void;
111
- /**
112
- * 返回点击或者拖动的时间点
113
- */
114
- returnMouseupTime(callback: (time: number) => void): void;
115
- /**
116
- * 滚轮放大缩小,以时间轴中心为准 mousewheel事件
117
- */
118
- mousewheelFunc: (event: any) => void;
119
- drawHourChange(hour: number): void;
120
- /**
121
- * 获取鼠标posx
122
- * @param {*} e
123
- */
124
- get_cursor_x_position: (e: MouseEvent) => number;
125
- /**
126
- * 清除canvas 每次重新绘制需要先清除
127
- */
128
- clearCanvas(): void;
129
- }
@@ -1,556 +0,0 @@
1
- import _nextTick from "@cloud-app-dev/utils/es/nextTick";
2
-
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
-
5
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6
-
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
-
9
- import moment from 'moment';
10
- var hours = [1, 6, 12, 24];
11
- var currentColor = '#FF000A';
12
- var normalLineColor = '#ffffff';
13
- var hoverLineColor = '#319BFF';
14
- var minPerStep = [1, 2, 5, 10, 15, 20, 30, 60, 120, 180, 240, 360, 720, 1440];
15
- var minStepSize = 20;
16
-
17
- var TimeSlider = /*#__PURE__*/function () {
18
- function TimeSlider(canvas, options) {
19
- var _this = this;
20
-
21
- _classCallCheck(this, TimeSlider);
22
-
23
- var _a, _b, _c, _d; //min/格
24
-
25
-
26
- this.minutes_per_step = minPerStep; //刻度间最小宽度,单位px
27
-
28
- this.graduation_step = minStepSize; //时间轴显示24小时
29
-
30
- this.hours_per_ruler = 24; // 当前刻度开始
31
-
32
- this.start_timestamp = new Date().getTime() - 12 * 60 * 60 * 1000;
33
- this.distance_between_gtitle = 80;
34
- this.zoom = 24; ////拖动mousedown标记
35
-
36
- this.g_isMousedown = false; //拖动mousemove标记
37
-
38
- this.g_isMousemove = false; //选中当前时间
39
-
40
- this.current_timestamp = new Date().getTime();
41
- this.timecell = [];
42
- this.domLeft = 0;
43
- /**
44
- * 拖动/点击 mousedown事件
45
- */
46
-
47
- this.mousedownFunc = function (e) {
48
- _this.g_isMousedown = true;
49
- _this.g_mousedownCursor = _this.get_cursor_x_position(e); //记住mousedown的位置
50
-
51
- document.addEventListener('mousemove', _this.mousemoveFunc); //拖动
52
-
53
- document.addEventListener('mouseup', _this.mouseupFunc2); //停止拖动
54
- };
55
- /**
56
- * 鼠标移出隐藏时间 mouseout事件
57
- * @param {*} e
58
- */
59
-
60
-
61
- this.mouseoutFunc = function () {
62
- _this.clearCanvas();
63
-
64
- _this.init(_this.start_timestamp, _this.timecell, true);
65
- };
66
- /**
67
- * 拖动/鼠标hover显示 mousemove事件
68
- */
69
-
70
-
71
- this.mousemoveFunc = function (e) {
72
- if (_this.g_isMousedown) {
73
- var pos_x = _this.get_cursor_x_position(e);
74
-
75
- var px_per_ms = _this.canvansW / (_this.hours_per_ruler * 60 * 60 * 1000); // px/ms
76
-
77
- _this.clearCanvas();
78
-
79
- var diff_x = pos_x - _this.g_mousedownCursor;
80
- _this.start_timestamp = _this.start_timestamp - Math.round(diff_x / px_per_ms);
81
-
82
- _this.init(_this.start_timestamp, _this.timecell, true);
83
-
84
- _this.g_isMousemove = true;
85
- _this.g_mousedownCursor = pos_x;
86
- }
87
- };
88
- /**
89
- * 拖动/鼠标hover显示
90
- */
91
-
92
-
93
- this.mousemoveFunc2 = function (e) {
94
- if (!_this.g_isMousedown) {
95
- var pos_x = _this.get_cursor_x_position(e); // const px_per_ms = this.canvansW / (this.hours_per_ruler * 60 * 60 * 1000); // px/ms
96
- // const current_timestamp = this.start_timestamp + pos_x / px_per_ms;
97
-
98
-
99
- var ms_per_px = _this.hours_per_ruler * 3600 * 1000 / _this.canvansW; // ms/px
100
-
101
- var current_timestamp = _this.start_timestamp + pos_x * ms_per_px;
102
-
103
- _this.clearCanvas();
104
-
105
- _this.init(_this.start_timestamp, _this.timecell, true);
106
-
107
- _this.drawLine(pos_x, 20, pos_x, _this.canVansH, hoverLineColor, 1);
108
-
109
- _this.ctx.fillStyle = hoverLineColor;
110
- _this.ctx.font = '10px Arial';
111
-
112
- _this.ctx.fillText(_this.changeTime(current_timestamp), pos_x - 50, 12);
113
- }
114
- };
115
- /**
116
- * 点击 mouseup事件
117
- */
118
-
119
-
120
- this.mouseupFunc = function (e) {
121
- var _a, _b;
122
-
123
- if (!_this.g_isMousemove) {
124
- // click 事件
125
- _this.g_isMousedown = false;
126
-
127
- var pos_x = _this.get_cursor_x_position(e); //鼠标距离 px
128
-
129
-
130
- var ms_per_px = _this.hours_per_ruler * 3600 * 1000 / _this.canvansW; // ms/px
131
-
132
- var current_timestamp = _this.start_timestamp + pos_x * ms_per_px;
133
-
134
- var timecellItem = _this.timecell.find(function (v) {
135
- return current_timestamp >= v.beginTime && current_timestamp < v.endTime;
136
- }); // 当前片段没有录像的时候
137
-
138
-
139
- var outTimeline = timecellItem && !timecellItem.url;
140
- _this.current_timestamp = current_timestamp;
141
-
142
- _this.set_time_to_middle(_this.current_timestamp);
143
-
144
- (_b = (_a = _this.options).onTimeChange) === null || _b === void 0 ? void 0 : _b.call(_a, current_timestamp, outTimeline);
145
- }
146
- };
147
- /**
148
- * 拖动停止 mouseup事件
149
- */
150
-
151
-
152
- this.mouseupFunc2 = function () {
153
- if (_this.g_isMousemove) {
154
- //拖动 事件
155
- _this.g_isMousemove = false;
156
- _this.g_isMousedown = false; // this.returnTime = this.start_timestamp + (this.hours_per_ruler * 3600 * 1000) / 2;
157
- }
158
-
159
- document.removeEventListener('mousemove', _this.mousemoveFunc);
160
- document.removeEventListener('mouseup', _this.mouseupFunc2);
161
- };
162
- /**
163
- * 滚轮放大缩小,以时间轴中心为准 mousewheel事件
164
- */
165
-
166
-
167
- this.mousewheelFunc = function (event) {
168
- if (event && event.preventDefault) {
169
- event.preventDefault();
170
- } else {
171
- window.event.returnValue = false;
172
- return;
173
- }
174
-
175
- var e = window.event || event;
176
- var delta = Math.max(-1, Math.min(1, e.wheelDelta || -e.detail));
177
- var middle_time = _this.start_timestamp + _this.hours_per_ruler * 3600 * 1000 / 2; //ms 记住当前中间的时间
178
-
179
- if (delta < 0) {
180
- // 缩小
181
- var index = hours.indexOf(_this.zoom);
182
-
183
- if (index === hours.length - 1) {
184
- _this.zoom = hours[index];
185
- } else {
186
- _this.zoom = hours[index + 1];
187
- }
188
-
189
- _this.hours_per_ruler = _this.zoom;
190
- } else if (delta > 0) {
191
- // 放大
192
- var _index = hours.indexOf(_this.zoom);
193
-
194
- if (_index === 0) {
195
- _this.zoom = hours[0];
196
- } else {
197
- _this.zoom = hours[_index - 1];
198
- }
199
-
200
- _this.hours_per_ruler = _this.zoom;
201
- }
202
-
203
- _nextTick(function () {
204
- var _a, _b;
205
-
206
- return (_b = (_a = _this.options).onHoursPerChange) === null || _b === void 0 ? void 0 : _b.call(_a, _this.hours_per_ruler);
207
- });
208
-
209
- _this.clearCanvas();
210
-
211
- _this.start_timestamp = middle_time - _this.hours_per_ruler * 3600 * 1000 / 2; //start_timestamp = 当前中间的时间 - zoom/2
212
-
213
- _this.init(_this.start_timestamp, _this.timecell, true);
214
- };
215
- /**
216
- * 获取鼠标posx
217
- * @param {*} e
218
- */
219
-
220
-
221
- this.get_cursor_x_position = function (e) {
222
- var posx = 0;
223
-
224
- if (!e) {
225
- e = window.event;
226
- }
227
-
228
- if (e.pageX || e.pageY) {
229
- posx = e.pageX - _this.domLeft;
230
- } else if (e.clientX || e.clientY) {
231
- posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
232
- }
233
-
234
- return posx;
235
- };
236
-
237
- var _canvas$getBoundingCl = canvas.getBoundingClientRect(),
238
- left = _canvas$getBoundingCl.left;
239
-
240
- this.canvas = canvas;
241
- this.options = options;
242
- this.canvansW = this.canvas.width = this.canvas.clientWidth;
243
- this.canVansH = this.canvas.height = this.canvas.clientHeight;
244
- this.zoom = this.hours_per_ruler = (_a = this.options.hours_per_ruler) !== null && _a !== void 0 ? _a : this.hours_per_ruler;
245
- this.start_timestamp = (_b = this.options.start_timestamp) !== null && _b !== void 0 ? _b : this.start_timestamp;
246
- this.current_timestamp = (_c = this.options.current_timestamp) !== null && _c !== void 0 ? _c : this.current_timestamp;
247
- this.timecell = (_d = this.options.timecell) !== null && _d !== void 0 ? _d : this.timecell;
248
- this.domLeft = left;
249
- this.init(this.start_timestamp, this.timecell, false);
250
- }
251
-
252
- _createClass(TimeSlider, [{
253
- key: "ctx",
254
- get: function get() {
255
- var _a;
256
-
257
- return (_a = this.canvas) === null || _a === void 0 ? void 0 : _a.getContext('2d');
258
- }
259
- }, {
260
- key: "init",
261
- value: function init(start_timestamp, timecell, redrawFlag) {
262
- this.timecell = timecell;
263
- this.start_timestamp = start_timestamp;
264
- this.drawCellBg();
265
- this.add_cells(timecell);
266
- this.add_graduations(start_timestamp);
267
-
268
- if (!redrawFlag) {
269
- //只有第一次进入才需要添加事件
270
- this.add_events();
271
- }
272
-
273
- this.drawCurrentLine();
274
- }
275
- }, {
276
- key: "drawCurrentLine",
277
- value: function drawCurrentLine() {
278
- var time = this.current_timestamp;
279
- var range = [this.start_timestamp, this.start_timestamp + this.hours_per_ruler * 3600 * 1000];
280
-
281
- if (time < range[0] || time > range[1]) {
282
- return;
283
- }
284
-
285
- var ms_current = time - this.start_timestamp;
286
- var px_per_ms = this.canvansW / (this.hours_per_ruler * 60 * 60 * 1000); // px/ms
287
-
288
- var left = px_per_ms * ms_current;
289
- this.ctx.fillStyle = '#ffffff';
290
- this.ctx.font = '12px Arial';
291
- this.ctx.fillText(this.changeTime(time), left - 64, 14);
292
- this.drawLine(left, 20, left, this.canVansH, currentColor, 2); //中间当前点线
293
- }
294
- }, {
295
- key: "drawCellBg",
296
- value: function drawCellBg() {// this.ctx.fillStyle = canvasbg;
297
- // this.ctx.fillRect(0, 0, this.canvansW, 15);
298
- }
299
- }, {
300
- key: "get_line_sizes",
301
- value: function get_line_sizes(start_timestamp) {
302
- var px_per_min = this.canvansW / (this.hours_per_ruler * 60); // px/min
303
-
304
- var px_per_ms = this.canvansW / (this.hours_per_ruler * 60 * 60 * 1000); // px/ms
305
-
306
- var px_per_step = this.graduation_step; // px/格 默认最小值20px
307
-
308
- var min_per_step = px_per_step / px_per_min; // min/格
309
-
310
- for (var i = 0; i < this.minutes_per_step.length; i++) {
311
- if (min_per_step <= this.minutes_per_step[i]) {
312
- //让每格时间在minutes_per_step规定的范围内
313
- min_per_step = this.minutes_per_step[i];
314
- px_per_step = px_per_min * min_per_step;
315
- break;
316
- }
317
- }
318
-
319
- var medium_step = 30;
320
-
321
- for (var _i = 0; _i < this.minutes_per_step.length; _i++) {
322
- if (this.distance_between_gtitle / px_per_min <= this.minutes_per_step[_i]) {
323
- medium_step = this.minutes_per_step[_i];
324
- break;
325
- }
326
- }
327
-
328
- var num_steps = this.canvansW / px_per_step; //总格数
329
-
330
- var ms_offset = this.ms_to_next_step(start_timestamp, min_per_step * 60 * 1000); //开始的偏移时间 ms
331
-
332
- var px_offset = ms_offset * px_per_ms; //开始的偏移距离 px
333
-
334
- var ms_per_step = px_per_step / px_per_ms; // ms/step
335
-
336
- return {
337
- num_steps: num_steps,
338
- px_offset: px_offset,
339
- ms_per_step: ms_per_step,
340
- px_per_step: px_per_step,
341
- min_per_step: min_per_step,
342
- medium_step: medium_step,
343
- ms_offset: ms_offset,
344
- px_per_ms: px_per_ms
345
- };
346
- }
347
- }, {
348
- key: "add_graduations",
349
- value: function add_graduations(start_timestamp) {
350
- var _this$get_line_sizes = this.get_line_sizes(start_timestamp),
351
- num_steps = _this$get_line_sizes.num_steps,
352
- px_offset = _this$get_line_sizes.px_offset,
353
- px_per_step = _this$get_line_sizes.px_per_step,
354
- ms_per_step = _this$get_line_sizes.ms_per_step,
355
- medium_step = _this$get_line_sizes.medium_step,
356
- ms_offset = _this$get_line_sizes.ms_offset;
357
-
358
- var graduation_left, graduation_time, lineH;
359
-
360
- for (var i = 0; i < num_steps; i++) {
361
- graduation_left = px_offset + i * px_per_step; // 距离=开始的偏移距离+格数*px/格
362
-
363
- graduation_time = start_timestamp + ms_offset + i * ms_per_step; //时间=左侧开始时间+偏移时间+格数*ms/格
364
-
365
- var date = new Date(graduation_time);
366
-
367
- if (date.getUTCHours() === 0 && date.getUTCMinutes() === 0) {
368
- lineH = 10;
369
- var big_date = this.graduation_title(date);
370
- this.ctx.fillStyle = normalLineColor;
371
- this.ctx.font = '10px Arial';
372
- this.ctx.fillText(big_date, graduation_left - 12, 30);
373
- } else if (graduation_time / (60 * 1000) % medium_step === 0) {
374
- lineH = 10;
375
- var middle_date = this.graduation_title(date);
376
- this.ctx.fillStyle = normalLineColor;
377
- this.ctx.font = '10px Arial';
378
- this.ctx.fillText(middle_date, graduation_left - (middle_date.length > 5 ? 24 : 12), 30);
379
- } else {
380
- lineH = 5;
381
- }
382
-
383
- this.drawLine(graduation_left, this.canVansH - lineH, graduation_left, this.canVansH, normalLineColor, 2);
384
- }
385
- }
386
- }, {
387
- key: "ms_to_next_step",
388
- value: function ms_to_next_step(timestamp, step) {
389
- var remainder = timestamp % step;
390
- return remainder ? step - remainder : 0;
391
- }
392
- /**
393
- * 返回时间轴上刻度的时间
394
- * @param {*} datetime new Date 格式
395
- */
396
-
397
- }, {
398
- key: "graduation_title",
399
- value: function graduation_title(datetime) {
400
- var h = datetime.getHours();
401
- var m = datetime.getMinutes();
402
- var s = datetime.getMilliseconds();
403
-
404
- if (h === 0 && m === 0 && s === 0) {
405
- return moment(datetime).format('YYYY.MM.DD');
406
- }
407
-
408
- return moment(datetime).format('HH:mm');
409
- }
410
- /**
411
- * 绘制线
412
- * @param {*} beginX
413
- * @param {*} beginY
414
- * @param {*} endX
415
- * @param {*} endY
416
- * @param {*} color
417
- * @param {*} width
418
- */
419
-
420
- }, {
421
- key: "drawLine",
422
- value: function drawLine(beginX, beginY, endX, endY, color, width) {
423
- this.ctx.beginPath();
424
- this.ctx.moveTo(beginX, beginY);
425
- this.ctx.lineTo(endX, endY);
426
- this.ctx.strokeStyle = color;
427
- this.ctx.lineWidth = width;
428
- this.ctx.stroke();
429
- }
430
- /**
431
- * 添加录像段
432
- * @param {*} cells 录像数组
433
- */
434
-
435
- }, {
436
- key: "add_cells",
437
- value: function add_cells(cells) {
438
- var _this2 = this;
439
-
440
- cells.forEach(function (cell) {
441
- return _this2.draw_cell(cell);
442
- });
443
- }
444
- /**
445
- * 绘制录像块
446
- * @param {*} cell cell包括beginTime ms;endTime ms;style
447
- */
448
-
449
- }, {
450
- key: "draw_cell",
451
- value: function draw_cell(cell) {
452
- var _a;
453
-
454
- var px_per_ms = this.canvansW / (this.hours_per_ruler * 60 * 60 * 1000); // px/ms
455
-
456
- var beginX = (cell.beginTime - this.start_timestamp) * px_per_ms;
457
- var cell_width = (cell.endTime - cell.beginTime) * px_per_ms;
458
- this.ctx.fillStyle = cell.url ? ((_a = cell.style) === null || _a === void 0 ? void 0 : _a.background) || hoverLineColor : '#242C3D';
459
- this.ctx.fillRect(beginX, this.canVansH - 10, cell_width + 1, this.canVansH);
460
- }
461
- /**·
462
- * 时间轴事件
463
- */
464
-
465
- }, {
466
- key: "add_events",
467
- value: function add_events() {
468
- this.canvas.addEventListener('mousewheel', this.mousewheelFunc); // 调整刻度范围
469
-
470
- this.canvas.addEventListener('mousedown', this.mousedownFunc); // 触发 拖动或者点击标记
471
-
472
- this.canvas.addEventListener('mousemove', this.mousemoveFunc2); //hover 提示当前刻度时间
473
-
474
- this.canvas.addEventListener('mouseup', this.mouseupFunc); // 点击触发
475
-
476
- this.canvas.addEventListener('mouseout', this.mouseoutFunc);
477
- }
478
- }, {
479
- key: "remove_events",
480
- value: function remove_events() {
481
- this.canvas.removeEventListener('mousewheel', this.mousewheelFunc);
482
- this.canvas.removeEventListener('mousedown', this.mousedownFunc);
483
- this.canvas.removeEventListener('mousemove', this.mousemoveFunc2);
484
- this.canvas.removeEventListener('mouseup', this.mouseupFunc);
485
- this.canvas.removeEventListener('mouseout', this.mouseoutFunc);
486
- }
487
- }, {
488
- key: "destory",
489
- value: function destory() {
490
- this.clearCanvas();
491
- this.remove_events();
492
- this.canvas = null;
493
- this.options = null;
494
- this.timecell = null;
495
- }
496
- /**
497
- * 返回 2018-01-01 10:00:00 格式时间
498
- * @param {*} time
499
- */
500
-
501
- }, {
502
- key: "changeTime",
503
- value: function changeTime(time) {
504
- return moment(time).format('YYYY-MM-DD HH:mm:ss');
505
- }
506
- /**
507
- * 设置时间,让这个时间点跳到中间红线处
508
- * @param {*} time 单位ms
509
- */
510
-
511
- }, {
512
- key: "set_time_to_middle",
513
- value: function set_time_to_middle(time) {
514
- this.clearCanvas();
515
- this.start_timestamp = time - this.hours_per_ruler * 60 * 60 * 1000 / 2;
516
- this.init(this.start_timestamp, this.timecell, true);
517
- }
518
- /**
519
- * 返回点击或者拖动的时间点
520
- */
521
-
522
- }, {
523
- key: "returnMouseupTime",
524
- value: function returnMouseupTime(callback) {
525
- if (this.current_timestamp != null) {
526
- if (callback) {
527
- callback(this.current_timestamp);
528
- }
529
- }
530
- }
531
- }, {
532
- key: "drawHourChange",
533
- value: function drawHourChange(hour) {
534
- var middle_time = this.start_timestamp + this.hours_per_ruler * 3600 * 1000 / 2; //ms 记住当前中间的时间
535
-
536
- this.hours_per_ruler = this.zoom = hour;
537
- this.clearCanvas();
538
- this.start_timestamp = middle_time - this.hours_per_ruler * 3600 * 1000 / 2; //start_timestamp = 当前中间的时间 - zoom/2
539
-
540
- this.init(this.start_timestamp, this.timecell, true);
541
- }
542
- /**
543
- * 清除canvas 每次重新绘制需要先清除
544
- */
545
-
546
- }, {
547
- key: "clearCanvas",
548
- value: function clearCanvas() {
549
- this.ctx.clearRect(0, 0, 1500, 150);
550
- }
551
- }]);
552
-
553
- return TimeSlider;
554
- }();
555
-
556
- export { TimeSlider as default };