@fonixtree/magic-design 0.0.163 → 0.0.165

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 (37) hide show
  1. package/es/common/Video/index.js +172 -55
  2. package/es/common/Video/index.less +3 -2
  3. package/es/composite-comp/bol/components/Video/components/VideoTag/index.less +1 -0
  4. package/es/composite-comp/bol/components/Video/defaultJSON.js +2 -2
  5. package/es/composite-comp/bol/components/Video/imgs/play-circle.png +0 -0
  6. package/es/composite-comp/bol/components/Video/mobile/Layout1/index.js +1 -1
  7. package/es/composite-comp/bol/components/Video/mobile/Layout2/index.js +1 -1
  8. package/es/composite-comp/bol/components/Video/mobile/Layout3/index.js +5 -0
  9. package/es/composite-comp/bol/components/Video/mobile/Layout3/index.less +2 -2
  10. package/es/composite-comp/bol/components/Video/pc/Layout1/index.js +5 -0
  11. package/es/composite-comp/bol/components/Video/pc/Layout1/index.less +3 -2
  12. package/es/composite-comp/bol/components/Video/pc/Layout2/index.js +10 -0
  13. package/es/composite-comp/bol/components/Video/pc/Layout2/index.less +6 -5
  14. package/es/composite-comp/bol/components/Video/pc/Layout3/index.js +5 -0
  15. package/es/composite-comp/bol/components/Video/pc/Layout3/index.less +1 -0
  16. package/es/composite-comp/bol/components/Video/pc/Layout4/index.js +5 -0
  17. package/es/composite-comp/bol/components/Video/pc/Layout5/index.js +5 -0
  18. package/es/utils/commonUtil.js +218 -2
  19. package/lib/common/Video/index.js +172 -55
  20. package/lib/common/Video/index.less +3 -2
  21. package/lib/composite-comp/bol/components/Video/components/VideoTag/index.less +1 -0
  22. package/lib/composite-comp/bol/components/Video/defaultJSON.js +2 -2
  23. package/lib/composite-comp/bol/components/Video/imgs/play-circle.png +0 -0
  24. package/lib/composite-comp/bol/components/Video/mobile/Layout1/index.js +1 -1
  25. package/lib/composite-comp/bol/components/Video/mobile/Layout2/index.js +1 -1
  26. package/lib/composite-comp/bol/components/Video/mobile/Layout3/index.js +5 -0
  27. package/lib/composite-comp/bol/components/Video/mobile/Layout3/index.less +2 -2
  28. package/lib/composite-comp/bol/components/Video/pc/Layout1/index.js +5 -0
  29. package/lib/composite-comp/bol/components/Video/pc/Layout1/index.less +3 -2
  30. package/lib/composite-comp/bol/components/Video/pc/Layout2/index.js +10 -0
  31. package/lib/composite-comp/bol/components/Video/pc/Layout2/index.less +6 -5
  32. package/lib/composite-comp/bol/components/Video/pc/Layout3/index.js +5 -0
  33. package/lib/composite-comp/bol/components/Video/pc/Layout3/index.less +1 -0
  34. package/lib/composite-comp/bol/components/Video/pc/Layout4/index.js +5 -0
  35. package/lib/composite-comp/bol/components/Video/pc/Layout5/index.js +5 -0
  36. package/lib/utils/commonUtil.js +218 -2
  37. package/package.json +1 -1
@@ -204,7 +204,7 @@ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
204
204
  }
205
205
  };
206
206
 
207
- var createVideo = function createVideo(domId, opts) {
207
+ var createAliVideo = function createAliVideo(domId, opts) {
208
208
  if (opts === void 0) {
209
209
  opts = {};
210
210
  }
@@ -301,12 +301,125 @@ var createVideo = function createVideo(domId, opts) {
301
301
  });
302
302
  };
303
303
 
304
- var AComponent =
304
+ var createYoutuVideo = function createYoutuVideo(domId, opts) {
305
+ if (opts === void 0) {
306
+ opts = {};
307
+ }
308
+
309
+ return __awaiter(void 0, void 0, void 0, function () {
310
+ var videoId;
311
+ return __generator(this, function (_a) {
312
+ switch (_a.label) {
313
+ case 0:
314
+ videoId = opts.source.split('youtu.be/')[1];
315
+ return [4
316
+ /*yield*/
317
+ , (0, _commonUtil.asyncNextTick)(function () {
318
+ return __awaiter(void 0, void 0, void 0, function () {
319
+ var player;
320
+ return __generator(this, function (_a) {
321
+ player = new YT.Player('video' + domId, {
322
+ height: '100%',
323
+ width: '100%',
324
+ videoId: videoId,
325
+ events: {
326
+ onReady: function onReady() {
327
+ if (!opts.videoSound) {
328
+ player.mute();
329
+ }
330
+
331
+ if (opts.speed) {
332
+ player.setPlaybackRate(opts.speed);
333
+ }
334
+
335
+ if (opts.startAt) {
336
+ player.seekTo(opts.startAt);
337
+ player.pauseVideo();
338
+ }
339
+
340
+ if (opts.loop) {
341
+ player.setLoop(true);
342
+ }
343
+
344
+ if (opts.autoplay) {
345
+ player.playVideo();
346
+ }
347
+ }
348
+ }
349
+ });
350
+ return [2
351
+ /*return*/
352
+ , player];
353
+ });
354
+ });
355
+ }, 500, 10)];
356
+
357
+ case 1:
358
+ return [2
359
+ /*return*/
360
+ , _a.sent()];
361
+ }
362
+ });
363
+ });
364
+ };
365
+
366
+ var createVideo = function createVideo(type, domId, opts) {
367
+ if (opts === void 0) {
368
+ opts = {};
369
+ }
370
+
371
+ return __awaiter(void 0, void 0, void 0, function () {
372
+ return __generator(this, function (_a) {
373
+ switch (_a.label) {
374
+ case 0:
375
+ if (!(type == 'ali')) return [3
376
+ /*break*/
377
+ , 2];
378
+ return [4
379
+ /*yield*/
380
+ , createAliVideo(domId, opts)];
381
+
382
+ case 1:
383
+ return [2
384
+ /*return*/
385
+ , _a.sent()];
386
+
387
+ case 2:
388
+ if (!(type == 'youtu')) return [3
389
+ /*break*/
390
+ , 4];
391
+ return [4
392
+ /*yield*/
393
+ , createYoutuVideo(domId, opts)];
394
+
395
+ case 3:
396
+ return [2
397
+ /*return*/
398
+ , _a.sent()];
399
+
400
+ case 4:
401
+ return [2
402
+ /*return*/
403
+ ];
404
+ }
405
+ });
406
+ });
407
+ };
408
+
409
+ var getVideoType = function getVideoType(opts) {
410
+ if (/youtu/.test(opts.source)) {
411
+ return 'youtu';
412
+ }
413
+
414
+ return 'ali';
415
+ };
416
+
417
+ var Video =
305
418
  /** @class */
306
419
  function (_super) {
307
- __extends(AComponent, _super);
420
+ __extends(Video, _super);
308
421
 
309
- function AComponent() {
422
+ function Video() {
310
423
  var _this = _super !== null && _super.apply(this, arguments) || this;
311
424
 
312
425
  _this.state = {};
@@ -370,87 +483,93 @@ function (_super) {
370
483
  modelWrap.appendChild(shadowWrap);
371
484
  modelWrap.appendChild(contentWrap);
372
485
  (document.querySelector('[magic_design]') || document.body).appendChild(modelWrap);
373
- createVideo('-modal-' + videoId, __assign(__assign({}, _this.props.opts), {
486
+ var type = getVideoType(_this.props.opts);
487
+ createVideo(type, '-modal-' + videoId, __assign(__assign({}, _this.props.opts), {
374
488
  autoplay: true
375
489
  }));
376
490
  };
377
491
 
378
492
  _this.getInit = function () {
379
493
  return __awaiter(_this, void 0, void 0, function () {
380
- var videoId_1, _a;
494
+ var videoType, _a, _b;
381
495
 
382
496
  var _this = this;
383
497
 
384
- return __generator(this, function (_b) {
385
- switch (_b.label) {
498
+ return __generator(this, function (_c) {
499
+ switch (_c.label) {
386
500
  case 0:
387
- if (!!window.Aliplayer) return [3
501
+ if (!this.props.opts.source) return [3
502
+ /*break*/
503
+ , 8];
504
+ videoType = getVideoType(this.props.opts);
505
+ if (!(videoType == 'youtu')) return [3
506
+ /*break*/
507
+ , 4];
508
+ if (!!window.YT) return [3
388
509
  /*break*/
389
510
  , 2];
390
511
  return [4
391
512
  /*yield*/
392
- , Promise.all([(0, _commonUtil.importAsync)('https://g.alicdn.com/de/prismplayer/2.13.2/aliplayer-min.js'), (0, _commonUtil.importAsync)('https://g.alicdn.com/de/prismplayer/2.13.2/skins/default/aliplayer-min.css')])];
513
+ , Promise.all([(0, _commonUtil.importAsync)('https://www.youtube.com/iframe_api', 'js')])];
393
514
 
394
515
  case 1:
395
- _b.sent();
516
+ _c.sent();
396
517
 
397
- _b.label = 2;
518
+ _c.label = 2;
398
519
 
399
520
  case 2:
400
- if (!!window.YT) return [3
401
- /*break*/
402
- , 4];
521
+ _a = this;
403
522
  return [4
404
523
  /*yield*/
405
- , Promise.all([(0, _commonUtil.importAsync)('https://www.youtube.com/iframe_api', 'js')])];
524
+ , createVideo('youtu', this.props.videoId, this.props.opts)];
406
525
 
407
526
  case 3:
408
- _b.sent();
527
+ _a.ytPlayer = _c.sent();
528
+ this.ytPlayer.addEventListener('onStateChange', function (event) {
529
+ if (!_this.props.opts.loop) {
530
+ if (event.data == YT.PlayerState.ENDED) {
531
+ console.log('youtu end');
409
532
 
410
- _b.label = 4;
533
+ _this.props.onEnd();
534
+ }
535
+ }
536
+ });
537
+ _c.label = 4;
411
538
 
412
539
  case 4:
413
- if (!this.props.opts.source) return [3
540
+ if (!(videoType == 'ali')) return [3
414
541
  /*break*/
415
- , 7];
416
- if (!/youtu/.test(this.props.opts.source)) return [3
417
- /*break*/
418
- , 5];
419
- videoId_1 = this.props.opts.source.split('youtu.be/')[1];
420
- (0, _commonUtil.nextTick)(function () {
421
- _this.ytPlayer = new YT.Player('video' + _this.props.videoId, {
422
- height: '100%',
423
- width: '100%',
424
- videoId: videoId_1,
425
- events: {
426
- onReady: function onReady() {
427
- console.log('onReady');
428
- },
429
- onStateChange: function onStateChange() {
430
- console.log('onStateChange');
431
- }
432
- }
433
- });
434
- }, 500, 10);
435
- return [3
542
+ , 8];
543
+ if (!!window.Aliplayer) return [3
436
544
  /*break*/
437
- , 7];
545
+ , 6];
546
+ return [4
547
+ /*yield*/
548
+ , Promise.all([(0, _commonUtil.importAsync)('https://g.alicdn.com/de/prismplayer/2.13.2/aliplayer-min.js'), (0, _commonUtil.importAsync)('https://g.alicdn.com/de/prismplayer/2.13.2/skins/default/aliplayer-min.css')])];
438
549
 
439
550
  case 5:
440
- _a = this;
551
+ _c.sent();
552
+
553
+ _c.label = 6;
554
+
555
+ case 6:
556
+ _b = this;
441
557
  return [4
442
558
  /*yield*/
443
- , createVideo(this.props.videoId, this.props.opts)];
559
+ , createVideo('ali', this.props.videoId, this.props.opts)];
444
560
 
445
- case 6:
446
- _a.aliPlayer = _b.sent();
561
+ case 7:
562
+ _b.aliPlayer = _c.sent();
447
563
  this.aliPlayer.on('ended', function () {
448
- if (!_this.props.opts.loop) {// this.props.onEnd();
564
+ if (!_this.props.opts.loop) {
565
+ console.log('ali end');
566
+
567
+ _this.props.onEnd();
449
568
  }
450
569
  });
451
- _b.label = 7;
570
+ _c.label = 8;
452
571
 
453
- case 7:
572
+ case 8:
454
573
  return [2
455
574
  /*return*/
456
575
  ];
@@ -466,11 +585,11 @@ function (_super) {
466
585
  return _this;
467
586
  }
468
587
 
469
- AComponent.prototype.componentDidMount = function () {
588
+ Video.prototype.componentDidMount = function () {
470
589
  this.getInit();
471
590
  };
472
591
 
473
- AComponent.prototype.render = function () {
592
+ Video.prototype.render = function () {
474
593
  var _a = this.props,
475
594
  videoId = _a.videoId,
476
595
  opts = _a.opts,
@@ -485,11 +604,9 @@ function (_super) {
485
604
  }));
486
605
  };
487
606
 
488
- AComponent.defaultProps = {
489
- title: 'title'
490
- };
491
- return AComponent;
607
+ Video.defaultProps = {};
608
+ return Video;
492
609
  }(_react["default"].Component);
493
610
 
494
- var _default = AComponent;
611
+ var _default = Video;
495
612
  exports["default"] = _default;
@@ -23,7 +23,7 @@
23
23
  }
24
24
 
25
25
  .pc-video-modal-wrap {
26
- position: absolute;
26
+ position: fixed;
27
27
  top: 0;
28
28
  left: 0;
29
29
  right: 0;
@@ -31,6 +31,7 @@
31
31
  display: flex;
32
32
  align-items: center;
33
33
  justify-content: center;
34
+ z-index: 999;
34
35
 
35
36
  .video-shadow-wrap {
36
37
  position: fixed;
@@ -51,7 +52,7 @@
51
52
  background: rgb(255 255 255);
52
53
  border-radius: 5px;
53
54
  z-index: 1001;
54
- position: fixed;
55
+ position: relative;
55
56
 
56
57
  .close-img-wrap {
57
58
  position: absolute;
@@ -13,6 +13,7 @@
13
13
  height: 100%;
14
14
  flex-shrink: 0;
15
15
  align-self: end;
16
+ min-height: 60px;
16
17
 
17
18
  .play-btn {
18
19
  position: absolute;
@@ -44,7 +44,7 @@ var videoGroupSourceJSON = function videoGroupSourceJSON(parentId) {
44
44
  fontFamily: 'Open Sans',
45
45
  fontWeight: 700,
46
46
  fontSize: 16,
47
- pcFontSize: 28,
47
+ pcFontSize: 18,
48
48
  color: '#232f46',
49
49
  width: 319
50
50
  },
@@ -67,7 +67,7 @@ var videoGroupSourceJSON = function videoGroupSourceJSON(parentId) {
67
67
  fontFamily: 'Open Sans',
68
68
  fontWeight: 400,
69
69
  fontSize: 13,
70
- pcFontSize: 22,
70
+ pcFontSize: 13,
71
71
  color: '#232f46',
72
72
  width: 319
73
73
  },
@@ -134,7 +134,7 @@ function (_super) {
134
134
  _this.setState({});
135
135
  }
136
136
  },
137
- onPause: function onPause() {
137
+ onEnd: function onEnd() {
138
138
  _this.videoRefMap[group.id].playing = false;
139
139
 
140
140
  _this.setState({});
@@ -166,7 +166,7 @@ function (_super) {
166
166
  _this.setState({});
167
167
  }
168
168
  },
169
- onPause: function onPause() {
169
+ onEnd: function onEnd() {
170
170
  _this.videoRefMap[group.id].playing = false;
171
171
 
172
172
  _this.setState({});
@@ -136,6 +136,11 @@ function (_super) {
136
136
  _this.setState({});
137
137
  }
138
138
  },
139
+ onEnd: function onEnd() {
140
+ _this.videoRefMap[group.id].playing = false;
141
+
142
+ _this.setState({});
143
+ },
139
144
  opts: __assign(__assign({}, group.video), {
140
145
  cover: (0, _coreUtil.getVideoCover)(group),
141
146
  source: group.video.sourceUrl
@@ -46,8 +46,8 @@
46
46
 
47
47
  .video-share-btn {
48
48
  position: absolute;
49
- right: 20px;
50
- bottom: 20px;
49
+ right: 12px;
50
+ bottom: 12px;
51
51
  }
52
52
  }
53
53
  }
@@ -133,6 +133,11 @@ function (_super) {
133
133
  _this.setState({});
134
134
  }
135
135
  },
136
+ onEnd: function onEnd() {
137
+ _this.videoRefMap[group.id].playing = false;
138
+
139
+ _this.setState({});
140
+ },
136
141
  opts: __assign(__assign({}, group.video), {
137
142
  cover: (0, _coreUtil.getVideoCover)(group),
138
143
  source: group.video.sourceUrl
@@ -4,6 +4,7 @@
4
4
 
5
5
  .video-tag-container .left-wrap {
6
6
  width: 120px;
7
+ min-height: 100px;
7
8
  }
8
9
 
9
10
  .video-tag-container .left-wrap+.right-wrap {
@@ -24,8 +25,8 @@
24
25
  top: 50%;
25
26
  left: 50%;
26
27
  transform: translate(-50%, -50%);
27
- width: 170px;
28
- height: 170px;
28
+ width: 100px;
29
+ height: 100px;
29
30
  z-index: 1;
30
31
  cursor: pointer;
31
32
 
@@ -135,6 +135,11 @@ function (_super) {
135
135
  _this.setState({});
136
136
  }
137
137
  },
138
+ onEnd: function onEnd() {
139
+ _this.videoRefMap[firstGroup.id].playing = false;
140
+
141
+ _this.setState({});
142
+ },
138
143
  opts: __assign(__assign({}, firstGroup.video), {
139
144
  cover: (0, _coreUtil.isPc)() ? firstGroup.overilay.content.pcImgSrc : firstGroup.overilay.content.h5ImgSrc,
140
145
  source: firstGroup.video.sourceUrl
@@ -179,6 +184,11 @@ function (_super) {
179
184
  _this.setState({});
180
185
  }
181
186
  },
187
+ onEnd: function onEnd() {
188
+ _this.videoRefMap[group.id].playing = false;
189
+
190
+ _this.setState({});
191
+ },
182
192
  opts: __assign(__assign({}, group.video), {
183
193
  cover: (0, _coreUtil.getVideoCover)(group),
184
194
  source: group.video.sourceUrl
@@ -11,7 +11,8 @@
11
11
  }
12
12
 
13
13
  .video-tag-container .left-wrap {
14
- width: 110px;
14
+ width: 100px;
15
+ min-height: 100px;
15
16
  }
16
17
 
17
18
  .video-tag-container .left-wrap+.right-wrap {
@@ -28,8 +29,8 @@
28
29
  top: 50%;
29
30
  left: 50%;
30
31
  transform: translate(-50%, -50%);
31
- width: 110px;
32
- height: 110px;
32
+ width: 100px;
33
+ height: 100px;
33
34
  z-index: 1;
34
35
  cursor: pointer;
35
36
 
@@ -52,8 +53,8 @@
52
53
  top: 50%;
53
54
  left: 50%;
54
55
  transform: translate(-50%, -50%);
55
- width: 110px;
56
- height: 110px;
56
+ width: 100px;
57
+ height: 100px;
57
58
  z-index: 1;
58
59
  cursor: pointer;
59
60
 
@@ -142,6 +142,11 @@ function (_super) {
142
142
  _this.setState({});
143
143
  }
144
144
  },
145
+ onEnd: function onEnd() {
146
+ _this.videoRefMap[group.id].playing = false;
147
+
148
+ _this.setState({});
149
+ },
145
150
  opts: __assign(__assign({}, group.video), {
146
151
  cover: (0, _coreUtil.getVideoCover)(group),
147
152
  source: group.video.sourceUrl
@@ -4,6 +4,7 @@
4
4
 
5
5
  .video-tag-container .left-wrap {
6
6
  width: 90px;
7
+ min-height: 100px;
7
8
  }
8
9
 
9
10
  .video-tag-container .left-wrap+.right-wrap {
@@ -136,6 +136,11 @@ function (_super) {
136
136
  _this.setState({});
137
137
  }
138
138
  },
139
+ onEnd: function onEnd() {
140
+ _this.videoRefMap[group.id].playing = false;
141
+
142
+ _this.setState({});
143
+ },
139
144
  opts: __assign(__assign({}, group.video), {
140
145
  cover: (0, _coreUtil.getVideoCover)(group),
141
146
  source: group.video.sourceUrl
@@ -136,6 +136,11 @@ function (_super) {
136
136
  _this.setState({});
137
137
  }
138
138
  },
139
+ onEnd: function onEnd() {
140
+ _this.videoRefMap[group.id].playing = false;
141
+
142
+ _this.setState({});
143
+ },
139
144
  opts: __assign(__assign({}, group.video), {
140
145
  cover: (0, _coreUtil.getVideoCover)(group),
141
146
  source: group.video.sourceUrl