@quintype/components 3.4.3 → 3.4.4-infiniteScroll-videos.1
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/cjs/index.js
CHANGED
|
@@ -2381,6 +2381,23 @@ var BrightcoveElement = function BrightcoveElement(props) {
|
|
|
2381
2381
|
posterImage = _useState4[0],
|
|
2382
2382
|
setPosterImage = _useState4[1];
|
|
2383
2383
|
|
|
2384
|
+
var _useState5 = React.useState(null),
|
|
2385
|
+
_useState6 = _slicedToArray__default["default"](_useState5, 2),
|
|
2386
|
+
myPlayer = _useState6[0],
|
|
2387
|
+
setMyPlayer = _useState6[1];
|
|
2388
|
+
|
|
2389
|
+
var _useState7 = React.useState(null),
|
|
2390
|
+
_useState8 = _slicedToArray__default["default"](_useState7, 2),
|
|
2391
|
+
observer = _useState8[0],
|
|
2392
|
+
setObserver = _useState8[1];
|
|
2393
|
+
|
|
2394
|
+
var _useState9 = React.useState(false),
|
|
2395
|
+
_useState10 = _slicedToArray__default["default"](_useState9, 2),
|
|
2396
|
+
thumbnailClicked = _useState10[0],
|
|
2397
|
+
setThumbnailClicked = _useState10[1];
|
|
2398
|
+
|
|
2399
|
+
var videoRef = React.useRef();
|
|
2400
|
+
|
|
2384
2401
|
var loadLibrary = function loadLibrary() {
|
|
2385
2402
|
var _window;
|
|
2386
2403
|
|
|
@@ -2404,11 +2421,34 @@ var BrightcoveElement = function BrightcoveElement(props) {
|
|
|
2404
2421
|
loadLibrary();
|
|
2405
2422
|
}
|
|
2406
2423
|
}, [loadIframeOnClick]);
|
|
2424
|
+
React.useEffect(function () {
|
|
2425
|
+
if (!myPlayer) return;
|
|
2426
|
+
myPlayer.on("play", startObserver);
|
|
2427
|
+
if (thumbnailClicked) myPlayer.play();
|
|
2428
|
+
return function () {
|
|
2429
|
+
myPlayer && myPlayer.off("play");
|
|
2430
|
+
observer && observer.disconnect();
|
|
2431
|
+
};
|
|
2432
|
+
}, [myPlayer, thumbnailClicked]);
|
|
2433
|
+
|
|
2434
|
+
function handleIntersection(entries) {
|
|
2435
|
+
if (!(entries !== null && entries !== void 0 && entries[0])) return;
|
|
2436
|
+
if (entries[0].isIntersecting) myPlayer.play();else myPlayer.pause();
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
function startObserver() {
|
|
2440
|
+
var intersectionObserver = new IntersectionObserver(function (entries) {
|
|
2441
|
+
return handleIntersection(entries);
|
|
2442
|
+
}, {
|
|
2443
|
+
threshold: 0.75
|
|
2444
|
+
});
|
|
2445
|
+
intersectionObserver.observe(videoRef.current);
|
|
2446
|
+
setObserver(intersectionObserver);
|
|
2447
|
+
}
|
|
2407
2448
|
|
|
2408
2449
|
var brightcoveIframe = function brightcoveIframe() {
|
|
2409
2450
|
var _window2;
|
|
2410
2451
|
|
|
2411
|
-
var autoplay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2412
2452
|
var BrightcovePlayerLoader = (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.BrightcovePlayerLoader;
|
|
2413
2453
|
return /*#__PURE__*/React__default["default"].createElement(BrightcovePlayerLoader, {
|
|
2414
2454
|
accountId: accountId,
|
|
@@ -2418,13 +2458,7 @@ var BrightcoveElement = function BrightcoveElement(props) {
|
|
|
2418
2458
|
className: "brightcove-player"
|
|
2419
2459
|
},
|
|
2420
2460
|
onSuccess: function onSuccess(success) {
|
|
2421
|
-
|
|
2422
|
-
var myPlayer = success.ref;
|
|
2423
|
-
myPlayer.ready(function () {
|
|
2424
|
-
myPlayer.muted(true);
|
|
2425
|
-
myPlayer.play();
|
|
2426
|
-
});
|
|
2427
|
-
}
|
|
2461
|
+
return setMyPlayer(success.ref);
|
|
2428
2462
|
},
|
|
2429
2463
|
onFailure: function onFailure() {
|
|
2430
2464
|
return console.log("brightcove failed to load");
|
|
@@ -2482,26 +2516,30 @@ var BrightcoveElement = function BrightcoveElement(props) {
|
|
|
2482
2516
|
}
|
|
2483
2517
|
|
|
2484
2518
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2485
|
-
className: "brightcove-wrapper"
|
|
2519
|
+
className: "brightcove-wrapper",
|
|
2520
|
+
ref: videoRef
|
|
2486
2521
|
}, !showVideo && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
2487
2522
|
className: "brightcove-playBtn",
|
|
2488
2523
|
onClick: function onClick() {
|
|
2489
|
-
|
|
2524
|
+
loadLibrary();
|
|
2525
|
+
setThumbnailClicked(true);
|
|
2490
2526
|
},
|
|
2491
2527
|
"aria-label": "Play Video"
|
|
2492
2528
|
}), posterImage ? /*#__PURE__*/React__default["default"].createElement("img", {
|
|
2493
2529
|
className: "brightcove-poster",
|
|
2494
2530
|
onClick: function onClick() {
|
|
2495
|
-
|
|
2531
|
+
loadLibrary();
|
|
2532
|
+
setThumbnailClicked(true);
|
|
2496
2533
|
},
|
|
2497
2534
|
src: posterImage,
|
|
2498
2535
|
alt: "video"
|
|
2499
2536
|
}) : /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2500
2537
|
className: "brightcove-poster-fallback"
|
|
2501
|
-
})), showVideo && ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.BrightcovePlayerLoader) && brightcoveIframe(
|
|
2538
|
+
})), showVideo && ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.BrightcovePlayerLoader) && brightcoveIframe());
|
|
2502
2539
|
} else if (!loadIframeOnClick && (_window4 = window) !== null && _window4 !== void 0 && _window4.BrightcovePlayerLoader) {
|
|
2503
2540
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2504
|
-
className: "brightcove-wrapper"
|
|
2541
|
+
className: "brightcove-wrapper",
|
|
2542
|
+
ref: videoRef
|
|
2505
2543
|
}, brightcoveIframe());
|
|
2506
2544
|
} else {
|
|
2507
2545
|
return null;
|
|
@@ -2553,8 +2591,23 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
|
|
|
2553
2591
|
|
|
2554
2592
|
_this = _super.call(this, props);
|
|
2555
2593
|
|
|
2594
|
+
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "onAdStart", function (event) {
|
|
2595
|
+
_this.startObserver(event);
|
|
2596
|
+
});
|
|
2597
|
+
|
|
2556
2598
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "onPlayCallback", function (event) {
|
|
2557
2599
|
_this.props.onPlay === "function" && _this.props.onPlay(event);
|
|
2600
|
+
|
|
2601
|
+
if (!_this.state.observerInitialized) {
|
|
2602
|
+
_this.startObserver(event);
|
|
2603
|
+
}
|
|
2604
|
+
});
|
|
2605
|
+
|
|
2606
|
+
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "handleIntersection", function (entries) {
|
|
2607
|
+
var _this$videoRef;
|
|
2608
|
+
|
|
2609
|
+
if (!((_this$videoRef = _this.videoRef) !== null && _this$videoRef !== void 0 && _this$videoRef.current)) return;
|
|
2610
|
+
if (entries !== null && entries !== void 0 && entries[0].isIntersecting) _this.videoRef.current.play();else _this.videoRef.current.pause();
|
|
2558
2611
|
});
|
|
2559
2612
|
|
|
2560
2613
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "onPauseCallback", function (event) {
|
|
@@ -2586,13 +2639,15 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
|
|
|
2586
2639
|
});
|
|
2587
2640
|
|
|
2588
2641
|
_this.state = {
|
|
2589
|
-
showVideo: false
|
|
2642
|
+
showVideo: false,
|
|
2643
|
+
observerInitialized: false
|
|
2590
2644
|
};
|
|
2591
2645
|
_this.opts = {
|
|
2592
2646
|
playerVars: {
|
|
2593
2647
|
autoplay: 0
|
|
2594
2648
|
}
|
|
2595
2649
|
};
|
|
2650
|
+
_this.videoRef = /*#__PURE__*/React__default["default"].createRef();
|
|
2596
2651
|
return _this;
|
|
2597
2652
|
}
|
|
2598
2653
|
|
|
@@ -2607,6 +2662,20 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
|
|
|
2607
2662
|
key: "componentWillUnmount",
|
|
2608
2663
|
value: function componentWillUnmount() {
|
|
2609
2664
|
this._isMounted = false;
|
|
2665
|
+
|
|
2666
|
+
if (this.intersectionObserver) {
|
|
2667
|
+
this.intersectionObserver.disconnect();
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
}, {
|
|
2671
|
+
key: "startObserver",
|
|
2672
|
+
value: function startObserver(event) {
|
|
2673
|
+
this.videoRef.current = event.target;
|
|
2674
|
+
this.intersectionObserver = new IntersectionObserver(this.handleIntersection, {
|
|
2675
|
+
threshold: 0.75
|
|
2676
|
+
});
|
|
2677
|
+
this.intersectionObserver.observe(this.videoRef.current);
|
|
2678
|
+
this.state.observerInitialized = true;
|
|
2610
2679
|
}
|
|
2611
2680
|
}, {
|
|
2612
2681
|
key: "render",
|
|
@@ -2623,7 +2692,9 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
|
|
|
2623
2692
|
onPlay: _this2.onPlayCallback,
|
|
2624
2693
|
onPause: _this2.onPauseCallback,
|
|
2625
2694
|
onEnd: _this2.onEndCallback,
|
|
2626
|
-
|
|
2695
|
+
onAdStart: _this2.onAdStart,
|
|
2696
|
+
autoplay: true,
|
|
2697
|
+
ref: _this2.videoRef
|
|
2627
2698
|
});
|
|
2628
2699
|
};
|
|
2629
2700
|
|
|
@@ -2648,7 +2719,10 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
|
|
|
2648
2719
|
opts: this.opts,
|
|
2649
2720
|
onPlay: this.onPlayCallback,
|
|
2650
2721
|
onPause: this.onPauseCallback,
|
|
2651
|
-
onEnd: this.onEndCallback
|
|
2722
|
+
onEnd: this.onEndCallback,
|
|
2723
|
+
onAdStart: this.onAdStart,
|
|
2724
|
+
autoplay: false,
|
|
2725
|
+
ref: this.videoRef
|
|
2652
2726
|
});
|
|
2653
2727
|
} else return /*#__PURE__*/React__default["default"].createElement("div", null);
|
|
2654
2728
|
}
|
|
@@ -3104,6 +3178,19 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
3104
3178
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "onPlayerReady", function (event) {
|
|
3105
3179
|
event.target.setVolume(100);
|
|
3106
3180
|
event.target.playVideo();
|
|
3181
|
+
_this.videoRef.current = event.target;
|
|
3182
|
+
_this.intersectionObserver = new IntersectionObserver(_this.handleIntersection, {
|
|
3183
|
+
threshold: 0.75
|
|
3184
|
+
});
|
|
3185
|
+
|
|
3186
|
+
_this.intersectionObserver.observe(_this.videoRef.current.getIframe());
|
|
3187
|
+
});
|
|
3188
|
+
|
|
3189
|
+
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "handleIntersection", function (entries) {
|
|
3190
|
+
var _this$videoRef;
|
|
3191
|
+
|
|
3192
|
+
if (!((_this$videoRef = _this.videoRef) !== null && _this$videoRef !== void 0 && _this$videoRef.current)) return;
|
|
3193
|
+
if (entries !== null && entries !== void 0 && entries[0].isIntersecting) _this.videoRef.current.playVideo();else _this.videoRef.current.pauseVideo();
|
|
3107
3194
|
});
|
|
3108
3195
|
|
|
3109
3196
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "renderVideo", function () {
|
|
@@ -3122,6 +3209,7 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
3122
3209
|
autoplay: 0
|
|
3123
3210
|
}
|
|
3124
3211
|
};
|
|
3212
|
+
_this.videoRef = /*#__PURE__*/React__default["default"].createRef();
|
|
3125
3213
|
return _this;
|
|
3126
3214
|
}
|
|
3127
3215
|
|
|
@@ -3136,6 +3224,10 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
3136
3224
|
key: "componentWillUnmount",
|
|
3137
3225
|
value: function componentWillUnmount() {
|
|
3138
3226
|
this._isMounted = false;
|
|
3227
|
+
|
|
3228
|
+
if (this.intersectionObserver) {
|
|
3229
|
+
this.intersectionObserver.disconnect();
|
|
3230
|
+
}
|
|
3139
3231
|
}
|
|
3140
3232
|
}, {
|
|
3141
3233
|
key: "render",
|
|
@@ -3149,7 +3241,8 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
3149
3241
|
onPlay: _this2.onPlayCallback,
|
|
3150
3242
|
onPause: _this2.onPauseCallback,
|
|
3151
3243
|
onEnd: _this2.onEndCallback,
|
|
3152
|
-
onReady: _this2.onPlayerReady
|
|
3244
|
+
onReady: _this2.onPlayerReady,
|
|
3245
|
+
ref: _this2.videoRef
|
|
3153
3246
|
});
|
|
3154
3247
|
};
|
|
3155
3248
|
|
|
@@ -3174,7 +3267,8 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
3174
3267
|
opts: this.opts,
|
|
3175
3268
|
onPlay: this.onPlayCallback,
|
|
3176
3269
|
onPause: this.onPauseCallback,
|
|
3177
|
-
onEnd: this.onEndCallback
|
|
3270
|
+
onEnd: this.onEndCallback,
|
|
3271
|
+
ref: this.videoRef
|
|
3178
3272
|
});
|
|
3179
3273
|
} else return /*#__PURE__*/React__default["default"].createElement("div", null);
|
|
3180
3274
|
}
|
|
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import get from "lodash/get";
|
|
5
5
|
import { bool, object } from "prop-types";
|
|
6
|
-
import React, { useEffect, useState } from "react";
|
|
6
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
7
7
|
import { WithLazy } from "../with-lazy";
|
|
8
8
|
|
|
9
9
|
var BrightcoveElement = function BrightcoveElement(props) {
|
|
@@ -30,6 +30,23 @@ var BrightcoveElement = function BrightcoveElement(props) {
|
|
|
30
30
|
posterImage = _useState4[0],
|
|
31
31
|
setPosterImage = _useState4[1];
|
|
32
32
|
|
|
33
|
+
var _useState5 = useState(null),
|
|
34
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
35
|
+
myPlayer = _useState6[0],
|
|
36
|
+
setMyPlayer = _useState6[1];
|
|
37
|
+
|
|
38
|
+
var _useState7 = useState(null),
|
|
39
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
40
|
+
observer = _useState8[0],
|
|
41
|
+
setObserver = _useState8[1];
|
|
42
|
+
|
|
43
|
+
var _useState9 = useState(false),
|
|
44
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
45
|
+
thumbnailClicked = _useState10[0],
|
|
46
|
+
setThumbnailClicked = _useState10[1];
|
|
47
|
+
|
|
48
|
+
var videoRef = useRef();
|
|
49
|
+
|
|
33
50
|
var loadLibrary = function loadLibrary() {
|
|
34
51
|
var _window;
|
|
35
52
|
|
|
@@ -53,11 +70,34 @@ var BrightcoveElement = function BrightcoveElement(props) {
|
|
|
53
70
|
loadLibrary();
|
|
54
71
|
}
|
|
55
72
|
}, [loadIframeOnClick]);
|
|
73
|
+
useEffect(function () {
|
|
74
|
+
if (!myPlayer) return;
|
|
75
|
+
myPlayer.on("play", startObserver);
|
|
76
|
+
if (thumbnailClicked) myPlayer.play();
|
|
77
|
+
return function () {
|
|
78
|
+
myPlayer && myPlayer.off("play");
|
|
79
|
+
observer && observer.disconnect();
|
|
80
|
+
};
|
|
81
|
+
}, [myPlayer, thumbnailClicked]);
|
|
82
|
+
|
|
83
|
+
function handleIntersection(entries) {
|
|
84
|
+
if (!(entries !== null && entries !== void 0 && entries[0])) return;
|
|
85
|
+
if (entries[0].isIntersecting) myPlayer.play();else myPlayer.pause();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function startObserver() {
|
|
89
|
+
var intersectionObserver = new IntersectionObserver(function (entries) {
|
|
90
|
+
return handleIntersection(entries);
|
|
91
|
+
}, {
|
|
92
|
+
threshold: 0.75
|
|
93
|
+
});
|
|
94
|
+
intersectionObserver.observe(videoRef.current);
|
|
95
|
+
setObserver(intersectionObserver);
|
|
96
|
+
}
|
|
56
97
|
|
|
57
98
|
var brightcoveIframe = function brightcoveIframe() {
|
|
58
99
|
var _window2;
|
|
59
100
|
|
|
60
|
-
var autoplay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
61
101
|
var BrightcovePlayerLoader = (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.BrightcovePlayerLoader;
|
|
62
102
|
return /*#__PURE__*/React.createElement(BrightcovePlayerLoader, {
|
|
63
103
|
accountId: accountId,
|
|
@@ -67,13 +107,7 @@ var BrightcoveElement = function BrightcoveElement(props) {
|
|
|
67
107
|
className: "brightcove-player"
|
|
68
108
|
},
|
|
69
109
|
onSuccess: function onSuccess(success) {
|
|
70
|
-
|
|
71
|
-
var myPlayer = success.ref;
|
|
72
|
-
myPlayer.ready(function () {
|
|
73
|
-
myPlayer.muted(true);
|
|
74
|
-
myPlayer.play();
|
|
75
|
-
});
|
|
76
|
-
}
|
|
110
|
+
return setMyPlayer(success.ref);
|
|
77
111
|
},
|
|
78
112
|
onFailure: function onFailure() {
|
|
79
113
|
return console.log("brightcove failed to load");
|
|
@@ -131,17 +165,20 @@ var BrightcoveElement = function BrightcoveElement(props) {
|
|
|
131
165
|
}
|
|
132
166
|
|
|
133
167
|
return /*#__PURE__*/React.createElement("div", {
|
|
134
|
-
className: "brightcove-wrapper"
|
|
168
|
+
className: "brightcove-wrapper",
|
|
169
|
+
ref: videoRef
|
|
135
170
|
}, !showVideo && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
136
171
|
className: "brightcove-playBtn",
|
|
137
172
|
onClick: function onClick() {
|
|
138
|
-
|
|
173
|
+
loadLibrary();
|
|
174
|
+
setThumbnailClicked(true);
|
|
139
175
|
},
|
|
140
176
|
"aria-label": "Play Video"
|
|
141
177
|
}), posterImage ? /*#__PURE__*/React.createElement("img", {
|
|
142
178
|
className: "brightcove-poster",
|
|
143
179
|
onClick: function onClick() {
|
|
144
|
-
|
|
180
|
+
loadLibrary();
|
|
181
|
+
setThumbnailClicked(true);
|
|
145
182
|
},
|
|
146
183
|
src: posterImage,
|
|
147
184
|
alt: "video"
|
|
@@ -150,7 +187,8 @@ var BrightcoveElement = function BrightcoveElement(props) {
|
|
|
150
187
|
})), showVideo && ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.BrightcovePlayerLoader) && brightcoveIframe(true));
|
|
151
188
|
} else if (!loadIframeOnClick && (_window4 = window) !== null && _window4 !== void 0 && _window4.BrightcovePlayerLoader) {
|
|
152
189
|
return /*#__PURE__*/React.createElement("div", {
|
|
153
|
-
className: "brightcove-wrapper"
|
|
190
|
+
className: "brightcove-wrapper",
|
|
191
|
+
ref: videoRef
|
|
154
192
|
}, brightcoveIframe());
|
|
155
193
|
} else {
|
|
156
194
|
return null;
|
|
@@ -48,8 +48,23 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
|
|
|
48
48
|
|
|
49
49
|
_this = _super.call(this, props);
|
|
50
50
|
|
|
51
|
+
_defineProperty(_assertThisInitialized(_this), "onAdStart", function (event) {
|
|
52
|
+
_this.startObserver(event);
|
|
53
|
+
});
|
|
54
|
+
|
|
51
55
|
_defineProperty(_assertThisInitialized(_this), "onPlayCallback", function (event) {
|
|
52
56
|
_this.props.onPlay === "function" && _this.props.onPlay(event);
|
|
57
|
+
|
|
58
|
+
if (!_this.state.observerInitialized) {
|
|
59
|
+
_this.startObserver(event);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
_defineProperty(_assertThisInitialized(_this), "handleIntersection", function (entries) {
|
|
64
|
+
var _this$videoRef;
|
|
65
|
+
|
|
66
|
+
if (!((_this$videoRef = _this.videoRef) !== null && _this$videoRef !== void 0 && _this$videoRef.current)) return;
|
|
67
|
+
if (entries !== null && entries !== void 0 && entries[0].isIntersecting) _this.videoRef.current.play();else _this.videoRef.current.pause();
|
|
53
68
|
});
|
|
54
69
|
|
|
55
70
|
_defineProperty(_assertThisInitialized(_this), "onPauseCallback", function (event) {
|
|
@@ -81,13 +96,15 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
|
|
|
81
96
|
});
|
|
82
97
|
|
|
83
98
|
_this.state = {
|
|
84
|
-
showVideo: false
|
|
99
|
+
showVideo: false,
|
|
100
|
+
observerInitialized: false
|
|
85
101
|
};
|
|
86
102
|
_this.opts = {
|
|
87
103
|
playerVars: {
|
|
88
104
|
autoplay: 0
|
|
89
105
|
}
|
|
90
106
|
};
|
|
107
|
+
_this.videoRef = /*#__PURE__*/React.createRef();
|
|
91
108
|
return _this;
|
|
92
109
|
}
|
|
93
110
|
|
|
@@ -102,6 +119,20 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
|
|
|
102
119
|
key: "componentWillUnmount",
|
|
103
120
|
value: function componentWillUnmount() {
|
|
104
121
|
this._isMounted = false;
|
|
122
|
+
|
|
123
|
+
if (this.intersectionObserver) {
|
|
124
|
+
this.intersectionObserver.disconnect();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
key: "startObserver",
|
|
129
|
+
value: function startObserver(event) {
|
|
130
|
+
this.videoRef.current = event.target;
|
|
131
|
+
this.intersectionObserver = new IntersectionObserver(this.handleIntersection, {
|
|
132
|
+
threshold: 0.75
|
|
133
|
+
});
|
|
134
|
+
this.intersectionObserver.observe(this.videoRef.current);
|
|
135
|
+
this.state.observerInitialized = true;
|
|
105
136
|
}
|
|
106
137
|
}, {
|
|
107
138
|
key: "render",
|
|
@@ -118,7 +149,9 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
|
|
|
118
149
|
onPlay: _this2.onPlayCallback,
|
|
119
150
|
onPause: _this2.onPauseCallback,
|
|
120
151
|
onEnd: _this2.onEndCallback,
|
|
121
|
-
|
|
152
|
+
onAdStart: _this2.onAdStart,
|
|
153
|
+
autoplay: true,
|
|
154
|
+
ref: _this2.videoRef
|
|
122
155
|
});
|
|
123
156
|
};
|
|
124
157
|
|
|
@@ -143,7 +176,10 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
|
|
|
143
176
|
opts: this.opts,
|
|
144
177
|
onPlay: this.onPlayCallback,
|
|
145
178
|
onPause: this.onPauseCallback,
|
|
146
|
-
onEnd: this.onEndCallback
|
|
179
|
+
onEnd: this.onEndCallback,
|
|
180
|
+
onAdStart: this.onAdStart,
|
|
181
|
+
autoplay: false,
|
|
182
|
+
ref: this.videoRef
|
|
147
183
|
});
|
|
148
184
|
} else return /*#__PURE__*/React.createElement("div", null);
|
|
149
185
|
}
|
|
@@ -106,6 +106,19 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
106
106
|
_defineProperty(_assertThisInitialized(_this), "onPlayerReady", function (event) {
|
|
107
107
|
event.target.setVolume(100);
|
|
108
108
|
event.target.playVideo();
|
|
109
|
+
_this.videoRef.current = event.target;
|
|
110
|
+
_this.intersectionObserver = new IntersectionObserver(_this.handleIntersection, {
|
|
111
|
+
threshold: 0.75
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
_this.intersectionObserver.observe(_this.videoRef.current.getIframe());
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
_defineProperty(_assertThisInitialized(_this), "handleIntersection", function (entries) {
|
|
118
|
+
var _this$videoRef;
|
|
119
|
+
|
|
120
|
+
if (!((_this$videoRef = _this.videoRef) !== null && _this$videoRef !== void 0 && _this$videoRef.current)) return;
|
|
121
|
+
if (entries !== null && entries !== void 0 && entries[0].isIntersecting) _this.videoRef.current.playVideo();else _this.videoRef.current.pauseVideo();
|
|
109
122
|
});
|
|
110
123
|
|
|
111
124
|
_defineProperty(_assertThisInitialized(_this), "renderVideo", function () {
|
|
@@ -124,6 +137,7 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
124
137
|
autoplay: 0
|
|
125
138
|
}
|
|
126
139
|
};
|
|
140
|
+
_this.videoRef = /*#__PURE__*/React.createRef();
|
|
127
141
|
return _this;
|
|
128
142
|
}
|
|
129
143
|
|
|
@@ -138,6 +152,10 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
138
152
|
key: "componentWillUnmount",
|
|
139
153
|
value: function componentWillUnmount() {
|
|
140
154
|
this._isMounted = false;
|
|
155
|
+
|
|
156
|
+
if (this.intersectionObserver) {
|
|
157
|
+
this.intersectionObserver.disconnect();
|
|
158
|
+
}
|
|
141
159
|
}
|
|
142
160
|
}, {
|
|
143
161
|
key: "render",
|
|
@@ -151,7 +169,8 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
151
169
|
onPlay: _this2.onPlayCallback,
|
|
152
170
|
onPause: _this2.onPauseCallback,
|
|
153
171
|
onEnd: _this2.onEndCallback,
|
|
154
|
-
onReady: _this2.onPlayerReady
|
|
172
|
+
onReady: _this2.onPlayerReady,
|
|
173
|
+
ref: _this2.videoRef
|
|
155
174
|
});
|
|
156
175
|
};
|
|
157
176
|
|
|
@@ -176,7 +195,8 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
|
|
|
176
195
|
opts: this.opts,
|
|
177
196
|
onPlay: this.onPlayCallback,
|
|
178
197
|
onPause: this.onPauseCallback,
|
|
179
|
-
onEnd: this.onEndCallback
|
|
198
|
+
onEnd: this.onEndCallback,
|
|
199
|
+
ref: this.videoRef
|
|
180
200
|
});
|
|
181
201
|
} else return /*#__PURE__*/React.createElement("div", null);
|
|
182
202
|
}
|