videojs-mobile-ui 1.2.0 → 1.2.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/README.md +3 -3
- package/dist/videojs-mobile-ui.cjs.js +2 -2
- package/dist/videojs-mobile-ui.es.js +2 -2
- package/dist/videojs-mobile-ui.js +2 -2
- package/dist/videojs-mobile-ui.min.js +2 -2
- package/docs/api/TouchOverlay.html +241 -49
- package/docs/api/global.html +298 -826
- package/docs/api/index.html +4 -4
- package/docs/api/plugin.js.html +86 -131
- package/docs/api/scripts/linenumber.js +9 -9
- package/docs/api/styles/jsdoc-default.css +2 -2
- package/docs/api/touchOverlay.js.html +61 -53
- package/package.json +1 -1
package/docs/api/index.html
CHANGED
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
<div class="container-overview">
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
<div class="description">touchOverlay.js
|
|
67
|
-
Touch UI component</div>
|
|
66
|
+
<div class="description"><p>touchOverlay.js
|
|
67
|
+
Touch UI component</p></div>
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
|
|
@@ -144,13 +144,13 @@ Touch UI component</div>
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<nav>
|
|
147
|
-
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="TouchOverlay.html">TouchOverlay</a></li></ul><h3>Global</h3><ul><li><a href="global.html#
|
|
147
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="TouchOverlay.html">TouchOverlay</a></li></ul><h3>Global</h3><ul><li><a href="global.html#mobileUi">mobileUi</a></li><li><a href="global.html#onPlayerReady">onPlayerReady</a></li></ul>
|
|
148
148
|
</nav>
|
|
149
149
|
|
|
150
150
|
<br class="clear">
|
|
151
151
|
|
|
152
152
|
<footer>
|
|
153
|
-
Documentation generated by <a href="https://github.com/
|
|
153
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 02 2021 09:43:56 GMT+0100 (CET)
|
|
154
154
|
</footer>
|
|
155
155
|
|
|
156
156
|
<script> prettyPrint(); </script>
|
package/docs/api/plugin.js.html
CHANGED
|
@@ -29,102 +29,41 @@
|
|
|
29
29
|
<pre class="prettyprint source linenums"><code>import videojs from 'video.js';
|
|
30
30
|
import {version as VERSION} from '../package.json';
|
|
31
31
|
import './touchOverlay.js';
|
|
32
|
-
import initSwipe from './swipeFullscreen.js';
|
|
33
32
|
import window from 'global/window';
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
* @typedef {Object} MobileUiOptions
|
|
37
|
-
* @property {Object} [fullscreen]
|
|
38
|
-
* Options for fullscreen behaviours.
|
|
39
|
-
* @property {boolean} [fullscreen.enterOnRotate]
|
|
40
|
-
* If the device is rotated, enter fullscreen.
|
|
41
|
-
* Default true.
|
|
42
|
-
* @property {boolean} [fullscreen.exitOnRotate]
|
|
43
|
-
* If the device is rotated, exit fullscreen.
|
|
44
|
-
* Default true.
|
|
45
|
-
* @property {boolean} [fullscreen.lockOnRotate]
|
|
46
|
-
* If the device is rotated, lock the orientation (not supported by iOS).
|
|
47
|
-
* Default true.
|
|
48
|
-
* @property {boolean} [fullscreen.lockToLandscapeOnEnter]
|
|
49
|
-
* When fullscreen is entered, lock the orientation (not supported by iOS).
|
|
50
|
-
* Default false.
|
|
51
|
-
* @property {boolean} [fullscreen.swipeToFullscreen]
|
|
52
|
-
* Swipe up to enter fullscreen.
|
|
53
|
-
* Default false.
|
|
54
|
-
* @property {boolean} [fullscreen.swipeFromFullscreen]
|
|
55
|
-
* Swipe down to exit fullscreen.
|
|
56
|
-
* Won't do anything on iOS native fullscreen, which has its own swipe down exit gesture.
|
|
57
|
-
* Default false.
|
|
58
|
-
* @property {boolean} [fullscreen.disabled]
|
|
59
|
-
* All fullscreen functionality provided by this plugin disabled.
|
|
60
|
-
* Default false.
|
|
61
|
-
* @property {Object} [touchControls]
|
|
62
|
-
* Options for tap overlay.
|
|
63
|
-
* @property {number} [touchControls.seekSeconds]
|
|
64
|
-
* Increment to seek in seconds.
|
|
65
|
-
* Default 10.
|
|
66
|
-
* @property {number} [touchControls.tapTimeout]
|
|
67
|
-
* Timeout to tap on the button after display, in ms. ???
|
|
68
|
-
* Default 300.
|
|
69
|
-
* @property {boolean} [touchControls.disableOnEnd]
|
|
70
|
-
* Disable the touch overlay when the video ends.
|
|
71
|
-
* Useful if an end screen overlay is used.
|
|
72
|
-
* Default false.
|
|
73
|
-
* @property {boolean} [touchControls.disabled]
|
|
74
|
-
* All tap overlay functionality provided by this plugin disabled.
|
|
75
|
-
* Default false.
|
|
76
|
-
* @internal
|
|
77
|
-
* @property {boolean} [forceForTesting]
|
|
78
|
-
* Used in unit tests
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
/** @type {MobileUiOptions} */
|
|
34
|
+
// Default options for the plugin.
|
|
82
35
|
const defaults = {
|
|
83
36
|
fullscreen: {
|
|
84
37
|
enterOnRotate: true,
|
|
85
38
|
exitOnRotate: true,
|
|
86
39
|
lockOnRotate: true,
|
|
87
|
-
|
|
88
|
-
swipeToFullscreen: false,
|
|
89
|
-
swipeFromFullscreen: false,
|
|
90
|
-
disabled: false
|
|
40
|
+
iOS: false
|
|
91
41
|
},
|
|
92
42
|
touchControls: {
|
|
93
43
|
seekSeconds: 10,
|
|
94
44
|
tapTimeout: 300,
|
|
95
|
-
disableOnEnd: false
|
|
96
|
-
disabled: false
|
|
45
|
+
disableOnEnd: false
|
|
97
46
|
}
|
|
98
47
|
};
|
|
99
48
|
|
|
100
49
|
const screen = window.screen;
|
|
101
50
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*
|
|
105
|
-
* @return {string} orientation
|
|
106
|
-
*/
|
|
107
|
-
const getOrientation = () => {
|
|
108
|
-
if (screen) {
|
|
109
|
-
// Prefer the string over angle, as 0° can be landscape on some tablets
|
|
110
|
-
const orientationString = ((screen.orientation || {}).type || screen.mozOrientation || screen.msOrientation || '').split('-')[0];
|
|
111
|
-
|
|
112
|
-
if (orientationString === 'landscape' || orientationString === 'portrait') {
|
|
113
|
-
return orientationString;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// iOS only supports window.orientation
|
|
51
|
+
const angle = () => {
|
|
52
|
+
// iOS
|
|
118
53
|
if (typeof window.orientation === 'number') {
|
|
119
|
-
|
|
120
|
-
return 'portrait';
|
|
121
|
-
}
|
|
122
|
-
return 'landscape';
|
|
54
|
+
return window.orientation;
|
|
123
55
|
}
|
|
124
|
-
|
|
125
|
-
|
|
56
|
+
// Android
|
|
57
|
+
if (screen && screen.orientation && screen.orientation.angle) {
|
|
58
|
+
return window.orientation;
|
|
59
|
+
}
|
|
60
|
+
videojs.log('angle unknown');
|
|
61
|
+
return 0;
|
|
126
62
|
};
|
|
127
63
|
|
|
64
|
+
// Cross-compatibility for Video.js 5 and 6.
|
|
65
|
+
const registerPlugin = videojs.registerPlugin || videojs.plugin;
|
|
66
|
+
|
|
128
67
|
/**
|
|
129
68
|
* Add UI and event listeners
|
|
130
69
|
*
|
|
@@ -132,86 +71,77 @@ const getOrientation = () => {
|
|
|
132
71
|
* @param {Player} player
|
|
133
72
|
* A Video.js player object.
|
|
134
73
|
*
|
|
135
|
-
* @param {
|
|
74
|
+
* @param {Object} [options={}]
|
|
136
75
|
* A plain object containing options for the plugin.
|
|
137
76
|
*/
|
|
138
77
|
const onPlayerReady = (player, options) => {
|
|
139
78
|
player.addClass('vjs-mobile-ui');
|
|
140
79
|
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
if (options.touchControls.disableOnEnd || typeof player.endscreen === 'function') {
|
|
144
|
-
player.addClass('vjs-mobile-ui-disable-end');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Insert before the control bar
|
|
148
|
-
const controlBarIdx = player.children_.indexOf(player.getChild('ControlBar'));
|
|
149
|
-
|
|
150
|
-
player.touchOverlay = player.addChild('TouchOverlay', options.touchControls, controlBarIdx);
|
|
80
|
+
if (options.touchControls.disableOnEnd || typeof player.endscreen === 'function') {
|
|
81
|
+
player.addClass('vjs-mobile-ui-disable-end');
|
|
151
82
|
}
|
|
152
83
|
|
|
153
|
-
if (options.fullscreen.
|
|
154
|
-
|
|
84
|
+
if (options.fullscreen.iOS &&
|
|
85
|
+
videojs.browser.IS_IOS && videojs.browser.IOS_VERSION > 9 &&
|
|
86
|
+
!player.el_.ownerDocument.querySelector('.bc-iframe')) {
|
|
87
|
+
player.tech_.el_.setAttribute('playsinline', 'playsinline');
|
|
88
|
+
player.tech_.supportsFullScreen = function() {
|
|
89
|
+
return false;
|
|
90
|
+
};
|
|
155
91
|
}
|
|
156
92
|
|
|
157
|
-
|
|
158
|
-
|
|
93
|
+
// Insert before the control bar
|
|
94
|
+
let controlBarIdx;
|
|
95
|
+
const versionParts = videojs.VERSION.split('.');
|
|
96
|
+
const major = parseInt(versionParts[0], 10);
|
|
97
|
+
const minor = parseInt(versionParts[1], 10);
|
|
98
|
+
|
|
99
|
+
// Video.js < 7.7.0 doesn't account for precedding components that don't have elements
|
|
100
|
+
if (major < 7 || (major === 7 && minor < 7)) {
|
|
101
|
+
controlBarIdx = Array.prototype.indexOf.call(
|
|
102
|
+
player.el_.children,
|
|
103
|
+
player.getChild('ControlBar').el_
|
|
104
|
+
);
|
|
105
|
+
} else {
|
|
106
|
+
controlBarIdx = player.children_.indexOf(player.getChild('ControlBar'));
|
|
159
107
|
}
|
|
160
108
|
|
|
109
|
+
player.addChild('TouchOverlay', options.touchControls, controlBarIdx);
|
|
110
|
+
|
|
161
111
|
let locked = false;
|
|
162
112
|
|
|
163
113
|
const rotationHandler = () => {
|
|
164
|
-
const
|
|
114
|
+
const currentAngle = angle();
|
|
165
115
|
|
|
166
|
-
if (
|
|
116
|
+
if ((currentAngle === 90 || currentAngle === 270 || currentAngle === -90) &&
|
|
117
|
+
options.enterOnRotate) {
|
|
167
118
|
if (player.paused() === false) {
|
|
168
119
|
player.requestFullscreen();
|
|
169
|
-
if (
|
|
120
|
+
if (options.fullscreen.lockOnRotate &&
|
|
170
121
|
screen.orientation && screen.orientation.lock) {
|
|
171
122
|
screen.orientation.lock('landscape').then(() => {
|
|
172
123
|
locked = true;
|
|
173
|
-
}).catch((
|
|
174
|
-
videojs.log('
|
|
124
|
+
}).catch(() => {
|
|
125
|
+
videojs.log('orientation lock not allowed');
|
|
175
126
|
});
|
|
176
127
|
}
|
|
177
128
|
}
|
|
178
|
-
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if ((currentAngle === 0 || currentAngle === 180) && options.exitOnRotate) {
|
|
179
132
|
if (player.isFullscreen()) {
|
|
180
133
|
player.exitFullscreen();
|
|
181
134
|
}
|
|
182
135
|
}
|
|
183
136
|
};
|
|
184
137
|
|
|
185
|
-
if (
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
window.removeEventListener('orientationchange', rotationHandler);
|
|
191
|
-
});
|
|
192
|
-
} else if (screen.orientation) {
|
|
193
|
-
// addEventListener('orientationchange') is not a user interaction on Android
|
|
194
|
-
screen.orientation.onchange = rotationHandler;
|
|
195
|
-
|
|
196
|
-
player.on('dispose', () => {
|
|
197
|
-
screen.orientation.onchange = null;
|
|
198
|
-
});
|
|
199
|
-
}
|
|
138
|
+
if (videojs.browser.IS_IOS) {
|
|
139
|
+
window.addEventListener('orientationchange', rotationHandler);
|
|
140
|
+
} else if (screen.orientation) {
|
|
141
|
+
// addEventListener('orientationchange') is not a user interaction on Android
|
|
142
|
+
screen.orientation.onchange = rotationHandler;
|
|
200
143
|
}
|
|
201
144
|
|
|
202
|
-
player.on('fullscreenchange', _ => {
|
|
203
|
-
if (player.isFullscreen() && options.fullscreen.lockToLandscapeOnEnter && getOrientation() === 'portrait') {
|
|
204
|
-
screen.orientation.lock('landscape').then(()=>{
|
|
205
|
-
locked = true;
|
|
206
|
-
}).catch((e) => {
|
|
207
|
-
videojs.log('Browser refused orientation lock:', e);
|
|
208
|
-
});
|
|
209
|
-
} else if (!player.isFullscreen() && locked) {
|
|
210
|
-
screen.orientation.unlock();
|
|
211
|
-
locked = false;
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
|
|
215
145
|
player.on('ended', _ => {
|
|
216
146
|
if (locked === true) {
|
|
217
147
|
screen.orientation.unlock();
|
|
@@ -221,21 +151,46 @@ const onPlayerReady = (player, options) => {
|
|
|
221
151
|
};
|
|
222
152
|
|
|
223
153
|
/**
|
|
224
|
-
*
|
|
154
|
+
* A video.js plugin.
|
|
155
|
+
*
|
|
156
|
+
* Adds a monile UI for player control, and fullscreen orientation control
|
|
225
157
|
*
|
|
226
158
|
* @function mobileUi
|
|
227
|
-
* @param {
|
|
159
|
+
* @param {Object} [options={}]
|
|
160
|
+
* Plugin options.
|
|
161
|
+
* @param {boolean} [options.forceForTesting=false]
|
|
162
|
+
* Enables the display regardless of user agent, for testing purposes
|
|
163
|
+
* @param {Object} [options.fullscreen={}]
|
|
164
|
+
* Fullscreen options.
|
|
165
|
+
* @param {boolean} [options.fullscreen.enterOnRotate=true]
|
|
166
|
+
* Whether to go fullscreen when rotating to landscape
|
|
167
|
+
* @param {boolean} [options.fullscreen.exitOnRotate=true]
|
|
168
|
+
* Whether to leave fullscreen when rotating to portrait (if not locked)
|
|
169
|
+
* @param {boolean} [options.fullscreen.lockOnRotate=true]
|
|
170
|
+
* Whether to lock orientation when rotating to landscape
|
|
171
|
+
* Unlocked when exiting fullscreen or on 'ended'
|
|
172
|
+
* @param {boolean} [options.fullscreen.iOS=false]
|
|
173
|
+
* Whether to disable iOS's native fullscreen so controls can work
|
|
174
|
+
* @param {Object} [options.touchControls={}]
|
|
175
|
+
* Touch UI options.
|
|
176
|
+
* @param {int} [options.touchControls.seekSeconds=10]
|
|
177
|
+
* Number of seconds to seek on double-tap
|
|
178
|
+
* @param {int} [options.touchControls.tapTimeout=300]
|
|
179
|
+
* Interval in ms to be considered a doubletap
|
|
180
|
+
* @param {boolean} [options.touchControls.disableOnEnd=false]
|
|
181
|
+
* Whether to disable when the video ends (e.g., if there is an endscreen)
|
|
182
|
+
* Never shows if the endscreen plugin is present
|
|
228
183
|
*/
|
|
229
184
|
const mobileUi = function(options = {}) {
|
|
230
185
|
if (options.forceForTesting || videojs.browser.IS_ANDROID || videojs.browser.IS_IOS) {
|
|
231
186
|
this.ready(() => {
|
|
232
|
-
onPlayerReady(this, videojs.
|
|
187
|
+
onPlayerReady(this, videojs.mergeOptions(defaults, options));
|
|
233
188
|
});
|
|
234
189
|
}
|
|
235
190
|
};
|
|
236
191
|
|
|
237
192
|
// Register the plugin with video.js.
|
|
238
|
-
|
|
193
|
+
registerPlugin('mobileUi', mobileUi);
|
|
239
194
|
|
|
240
195
|
// Include the version number.
|
|
241
196
|
mobileUi.VERSION = VERSION;
|
|
@@ -251,13 +206,13 @@ export default mobileUi;
|
|
|
251
206
|
</div>
|
|
252
207
|
|
|
253
208
|
<nav>
|
|
254
|
-
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="TouchOverlay.html">TouchOverlay</a></li></ul><h3>Global</h3><ul><li><a href="global.html#
|
|
209
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="TouchOverlay.html">TouchOverlay</a></li></ul><h3>Global</h3><ul><li><a href="global.html#mobileUi">mobileUi</a></li><li><a href="global.html#onPlayerReady">onPlayerReady</a></li></ul>
|
|
255
210
|
</nav>
|
|
256
211
|
|
|
257
212
|
<br class="clear">
|
|
258
213
|
|
|
259
214
|
<footer>
|
|
260
|
-
Documentation generated by <a href="https://github.com/
|
|
215
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 02 2021 09:43:56 GMT+0100 (CET)
|
|
261
216
|
</footer>
|
|
262
217
|
|
|
263
218
|
<script> prettyPrint(); </script>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*global document */
|
|
2
|
-
(()
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
(function() {
|
|
3
|
+
var source = document.getElementsByClassName('prettyprint source linenums');
|
|
4
|
+
var i = 0;
|
|
5
|
+
var lineNumber = 0;
|
|
6
|
+
var lineId;
|
|
7
|
+
var lines;
|
|
8
|
+
var totalLines;
|
|
9
|
+
var anchorHash;
|
|
10
10
|
|
|
11
11
|
if (source && source[0]) {
|
|
12
12
|
anchorHash = document.location.hash.substring(1);
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
for (; i < totalLines; i++) {
|
|
17
17
|
lineNumber++;
|
|
18
|
-
lineId =
|
|
18
|
+
lineId = 'line' + lineNumber;
|
|
19
19
|
lines[i].id = lineId;
|
|
20
20
|
if (lineId === anchorHash) {
|
|
21
21
|
lines[i].className += ' selected';
|
|
@@ -273,7 +273,7 @@ tr > th:last-child { border-right: 1px solid #ddd; }
|
|
|
273
273
|
margin: 0;
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
-
.
|
|
276
|
+
.prettyprint
|
|
277
277
|
{
|
|
278
278
|
border: 1px solid #ddd;
|
|
279
279
|
width: 80%;
|
|
@@ -284,7 +284,7 @@ tr > th:last-child { border-right: 1px solid #ddd; }
|
|
|
284
284
|
width: inherit;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
-
.
|
|
287
|
+
.prettyprint code
|
|
288
288
|
{
|
|
289
289
|
font-size: 100%;
|
|
290
290
|
line-height: 18px;
|
|
@@ -34,8 +34,6 @@
|
|
|
34
34
|
import videojs from 'video.js';
|
|
35
35
|
import window from 'global/window';
|
|
36
36
|
|
|
37
|
-
/** @import Player from 'video.js/dist/types/player' */
|
|
38
|
-
|
|
39
37
|
const Component = videojs.getComponent('Component');
|
|
40
38
|
const dom = videojs.dom || videojs;
|
|
41
39
|
|
|
@@ -52,7 +50,7 @@ class TouchOverlay extends Component {
|
|
|
52
50
|
* @param {Player} player
|
|
53
51
|
* The `Player` that this class should be attached to.
|
|
54
52
|
*
|
|
55
|
-
* @param {
|
|
53
|
+
* @param {Object} [options]
|
|
56
54
|
* The key/value store of player options.
|
|
57
55
|
*/
|
|
58
56
|
constructor(player, options) {
|
|
@@ -60,7 +58,6 @@ class TouchOverlay extends Component {
|
|
|
60
58
|
|
|
61
59
|
this.seekSeconds = options.seekSeconds;
|
|
62
60
|
this.tapTimeout = options.tapTimeout;
|
|
63
|
-
this.taps = 0;
|
|
64
61
|
|
|
65
62
|
// Add play toggle overlay
|
|
66
63
|
this.addChild('playToggle', {});
|
|
@@ -75,46 +72,6 @@ class TouchOverlay extends Component {
|
|
|
75
72
|
this.player_.options_.inactivityTimeout = 5000;
|
|
76
73
|
}
|
|
77
74
|
|
|
78
|
-
/**
|
|
79
|
-
* Debounced tap handler.
|
|
80
|
-
* Seeks number of (taps - 1) * configured seconds to skip.
|
|
81
|
-
* One tap is a non-op
|
|
82
|
-
*
|
|
83
|
-
* @param {Event} event
|
|
84
|
-
*/
|
|
85
|
-
this.handleTaps_ = videojs.fn.debounce(event => {
|
|
86
|
-
const increment = (this.taps - 1) * this.seekSeconds;
|
|
87
|
-
|
|
88
|
-
this.taps = 0;
|
|
89
|
-
if (increment < 1) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const rect = this.el_.getBoundingClientRect();
|
|
94
|
-
const x = event.changedTouches[0].clientX - rect.left;
|
|
95
|
-
|
|
96
|
-
// Check if double tap is in left or right area
|
|
97
|
-
if (x < rect.width * 0.4) {
|
|
98
|
-
this.player_.currentTime(Math.max(0, this.player_.currentTime() - increment));
|
|
99
|
-
this.addClass('reverse');
|
|
100
|
-
} else if (x > rect.width - (rect.width * 0.4)) {
|
|
101
|
-
this.player_.currentTime(Math.min(this.player_.duration(), this.player_.currentTime() + increment));
|
|
102
|
-
this.removeClass('reverse');
|
|
103
|
-
} else {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Remove play toggle if showing
|
|
108
|
-
this.removeClass('show-play-toggle');
|
|
109
|
-
|
|
110
|
-
// Remove and readd class to trigger animation
|
|
111
|
-
this.setAttribute('data-skip-text', `${increment} ${this.localize('seconds')}`);
|
|
112
|
-
this.removeClass('skip');
|
|
113
|
-
window.requestAnimationFrame(() => {
|
|
114
|
-
this.addClass('skip');
|
|
115
|
-
});
|
|
116
|
-
}, this.tapTimeout);
|
|
117
|
-
|
|
118
75
|
this.enable();
|
|
119
76
|
}
|
|
120
77
|
|
|
@@ -147,16 +104,67 @@ class TouchOverlay extends Component {
|
|
|
147
104
|
return;
|
|
148
105
|
}
|
|
149
106
|
|
|
150
|
-
|
|
151
|
-
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
|
|
109
|
+
if (this.firstTapCaptured) {
|
|
110
|
+
this.firstTapCaptured = false;
|
|
111
|
+
if (this.timeout) {
|
|
112
|
+
window.clearTimeout(this.timeout);
|
|
113
|
+
}
|
|
114
|
+
this.handleDoubleTap(event);
|
|
115
|
+
} else {
|
|
116
|
+
this.firstTapCaptured = true;
|
|
117
|
+
this.timeout = window.setTimeout(() => {
|
|
118
|
+
this.firstTapCaptured = false;
|
|
119
|
+
this.handleSingleTap(event);
|
|
120
|
+
}, this.tapTimeout);
|
|
152
121
|
}
|
|
122
|
+
}
|
|
153
123
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Toggles display of play toggle
|
|
126
|
+
*
|
|
127
|
+
* @param {Event} event
|
|
128
|
+
* The touch event
|
|
129
|
+
*
|
|
130
|
+
*/
|
|
131
|
+
handleSingleTap(event) {
|
|
132
|
+
this.removeClass('skip');
|
|
133
|
+
this.toggleClass('show-play-toggle');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Seeks by configured number of seconds if left or right part of video double tapped
|
|
138
|
+
*
|
|
139
|
+
* @param {Event} event
|
|
140
|
+
* The touch event
|
|
141
|
+
*
|
|
142
|
+
*/
|
|
143
|
+
handleDoubleTap(event) {
|
|
144
|
+
const rect = this.el_.getBoundingClientRect();
|
|
145
|
+
const x = event.changedTouches[0].clientX - rect.left;
|
|
146
|
+
|
|
147
|
+
// Check if double tap is in left or right area
|
|
148
|
+
if (x < rect.width * 0.4) {
|
|
149
|
+
this.player_.currentTime(Math.max(
|
|
150
|
+
0, this.player_.currentTime() - this.seekSeconds));
|
|
151
|
+
this.addClass('reverse');
|
|
152
|
+
} else if (x > rect.width - (rect.width * 0.4)) {
|
|
153
|
+
this.player_.currentTime(Math.min(
|
|
154
|
+
this.player_.duration(), this.player_.currentTime() + this.seekSeconds));
|
|
155
|
+
this.removeClass('reverse');
|
|
156
|
+
} else {
|
|
157
|
+
return;
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
|
|
160
|
+
// Remove play toggle if showing
|
|
161
|
+
this.removeClass('show-play-toggle');
|
|
162
|
+
|
|
163
|
+
// Remove and readd class to trigger animation
|
|
164
|
+
this.removeClass('skip');
|
|
165
|
+
window.requestAnimationFrame(() => {
|
|
166
|
+
this.addClass('skip');
|
|
167
|
+
});
|
|
160
168
|
}
|
|
161
169
|
|
|
162
170
|
/**
|
|
@@ -188,13 +196,13 @@ export default TouchOverlay;
|
|
|
188
196
|
</div>
|
|
189
197
|
|
|
190
198
|
<nav>
|
|
191
|
-
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="TouchOverlay.html">TouchOverlay</a></li></ul><h3>Global</h3><ul><li><a href="global.html#
|
|
199
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="TouchOverlay.html">TouchOverlay</a></li></ul><h3>Global</h3><ul><li><a href="global.html#mobileUi">mobileUi</a></li><li><a href="global.html#onPlayerReady">onPlayerReady</a></li></ul>
|
|
192
200
|
</nav>
|
|
193
201
|
|
|
194
202
|
<br class="clear">
|
|
195
203
|
|
|
196
204
|
<footer>
|
|
197
|
-
Documentation generated by <a href="https://github.com/
|
|
205
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 02 2021 09:43:56 GMT+0100 (CET)
|
|
198
206
|
</footer>
|
|
199
207
|
|
|
200
208
|
<script> prettyPrint(); </script>
|
package/package.json
CHANGED