videojs-mobile-ui 1.2.0-alpha.0 → 1.2.0

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 (53) hide show
  1. package/README.md +104 -53
  2. package/dist/lang/de.js +1 -3
  3. package/dist/lang/en.js +1 -3
  4. package/dist/lang/it.js +1 -3
  5. package/dist/videojs-mobile-ui.cjs.js +195 -43
  6. package/dist/videojs-mobile-ui.css +104 -2
  7. package/dist/videojs-mobile-ui.es.js +195 -43
  8. package/dist/videojs-mobile-ui.js +204 -53
  9. package/dist/videojs-mobile-ui.min.js +2 -2
  10. package/docs/api/TouchOverlay.html +772 -0
  11. package/docs/api/fonts/OpenSans-Bold-webfont.eot +0 -0
  12. package/docs/api/fonts/OpenSans-Bold-webfont.svg +1830 -0
  13. package/docs/api/fonts/OpenSans-Bold-webfont.woff +0 -0
  14. package/docs/api/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  15. package/docs/api/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  16. package/docs/api/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  17. package/docs/api/fonts/OpenSans-Italic-webfont.eot +0 -0
  18. package/docs/api/fonts/OpenSans-Italic-webfont.svg +1830 -0
  19. package/docs/api/fonts/OpenSans-Italic-webfont.woff +0 -0
  20. package/docs/api/fonts/OpenSans-Light-webfont.eot +0 -0
  21. package/docs/api/fonts/OpenSans-Light-webfont.svg +1831 -0
  22. package/docs/api/fonts/OpenSans-Light-webfont.woff +0 -0
  23. package/docs/api/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  24. package/docs/api/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  25. package/docs/api/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  26. package/docs/api/fonts/OpenSans-Regular-webfont.eot +0 -0
  27. package/docs/api/fonts/OpenSans-Regular-webfont.svg +1831 -0
  28. package/docs/api/fonts/OpenSans-Regular-webfont.woff +0 -0
  29. package/docs/api/global.html +1485 -0
  30. package/docs/api/index.html +159 -0
  31. package/docs/api/plugin.js.html +266 -0
  32. package/docs/api/scripts/linenumber.js +25 -0
  33. package/docs/api/scripts/prettify/Apache-License-2.0.txt +202 -0
  34. package/docs/api/scripts/prettify/lang-css.js +2 -0
  35. package/docs/api/scripts/prettify/prettify.js +28 -0
  36. package/docs/api/styles/jsdoc-default.css +358 -0
  37. package/docs/api/styles/prettify-jsdoc.css +111 -0
  38. package/docs/api/styles/prettify-tomorrow.css +132 -0
  39. package/docs/api/swipeFullscreen.js.html +173 -0
  40. package/docs/api/touchOverlay.js.html +203 -0
  41. package/index.html +238 -170
  42. package/package.json +23 -13
  43. package/scripts/lang.js +24 -0
  44. package/scripts/netlify.js +16 -0
  45. package/scripts/postcss.config.js +29 -5
  46. package/scripts/readme-options.js +370 -0
  47. package/scripts/rollup.config.js +0 -8
  48. package/src/plugin.css +6 -0
  49. package/src/plugin.js +65 -39
  50. package/src/swipeFullscreen.js +122 -0
  51. package/src/touchOverlay.js +7 -3
  52. package/test/plugin.test.js +125 -18
  53. package/test/swipeFullscreen.test.js +365 -0
@@ -0,0 +1,173 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: swipeFullscreen.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Source: swipeFullscreen.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>/** @import Player from 'video.js/dist/types/player' */
30
+ /** @import Plugin from 'video.js/dist/types/plugin' */
31
+ /** @import {MobileUiOptions} from './plugin' */
32
+
33
+ /**
34
+ * Sets up swiping to enter and exit fullscreen.
35
+ *
36
+ * @this {Plugin}
37
+ * @param {Player} player
38
+ * The player to initialise on.
39
+ * @param {MobileUiOptions} pluginOptions
40
+ * The options used by the mobile ui plugin.
41
+ */
42
+ const initSwipe = (player, pluginOptions) => {
43
+ const {swipeToFullscreen, swipeFromFullscreen} = pluginOptions.fullscreen;
44
+
45
+ if (swipeToFullscreen) {
46
+ player.addClass('using-fs-swipe-up');
47
+ }
48
+ if (swipeFromFullscreen) {
49
+ player.addClass('using-fs-swipe-down');
50
+ }
51
+
52
+ let touchStartY = 0;
53
+ let couldBeSwiping = false;
54
+ const swipeThreshold = 30;
55
+
56
+ /**
57
+ * Monitor the possible start of a swipe
58
+ *
59
+ * @param {TouchEvent} e Triggering touch event
60
+ */
61
+ const onStart = (e) => {
62
+ const isFullscreen = player.isFullscreen();
63
+
64
+ if (
65
+ (!isFullscreen &amp;&amp; !swipeToFullscreen) ||
66
+ (isFullscreen &amp;&amp; !swipeFromFullscreen)
67
+ ) {
68
+ couldBeSwiping = false;
69
+ return;
70
+ }
71
+
72
+ touchStartY = e.changedTouches[0].clientY;
73
+ couldBeSwiping = true;
74
+ player.tech_.el().style.transition = '';
75
+ };
76
+
77
+ /**
78
+ * Monitor the movement of a swipe
79
+ *
80
+ * @param {TouchEvent} e Triggering touch event
81
+ */
82
+ const onMove = (e) => {
83
+ if (!couldBeSwiping) {
84
+ return;
85
+ }
86
+
87
+ const currentY = e.touches[0].clientY;
88
+ const deltaY = touchStartY - currentY;
89
+ const isFullscreen = player.isFullscreen();
90
+
91
+ let scale = 1;
92
+
93
+ if (!isFullscreen &amp;&amp; deltaY > 0) {
94
+ // Swiping up to enter fullscreen: Zoom in (Max 1.1)
95
+ scale = 1 + Math.min(0.1, deltaY / 500);
96
+ player.tech_.el().style.transform = `scale(${scale})`;
97
+ } else if (isFullscreen &amp;&amp; deltaY &lt; 0) {
98
+ // Swiping down to exit fullscreen: Zoom out (Min 0.9)
99
+ scale = 1 - Math.min(0.1, Math.abs(deltaY) / 500);
100
+ player.tech_.el().style.transform = `scale(${scale})`;
101
+ }
102
+ };
103
+
104
+ /**
105
+ * Monitor the touch end to determine a valid swipe
106
+ *
107
+ * @param {TouchEvent} e Triggering touch event
108
+ */
109
+ const onEnd = (e) => {
110
+ if (!couldBeSwiping) {
111
+ return;
112
+ }
113
+ couldBeSwiping = false;
114
+
115
+ player.tech_.el().style.transition = 'transform 0.3s ease-out';
116
+ player.tech_.el().style.transform = 'scale(1)';
117
+
118
+ if (e.type === 'touchcancel') {
119
+ return;
120
+ }
121
+
122
+ const touchEndY = e.changedTouches[0].clientY;
123
+ const deltaY = touchStartY - touchEndY;
124
+
125
+ if (deltaY > swipeThreshold &amp;&amp; !player.isFullscreen()) {
126
+ player.requestFullscreen().catch((err) => {
127
+ player.log.warn('Browser refused fullscreen', err);
128
+ });
129
+ } else if (deltaY &lt; -swipeThreshold &amp;&amp; player.isFullscreen()) {
130
+ player.exitFullscreen();
131
+ }
132
+ };
133
+
134
+ player.el().addEventListener('touchstart', onStart, { passive: true });
135
+ player.el().addEventListener('touchmove', onMove, { passive: true });
136
+ player.el().addEventListener('touchend', onEnd, { passive: true });
137
+ player.el().addEventListener('touchcancel', onEnd, { passive: true });
138
+
139
+ player.on('dispose', () => {
140
+ player.el().removeEventListener('touchstart', onStart, { passive: true });
141
+ player.el().removeEventListener('touchmove', onMove, { passive: true });
142
+ player.el().removeEventListener('touchend', onEnd, { passive: true });
143
+ player.el().removeEventListener('touchcancel', onEnd, { passive: true });
144
+ player.tech_.el().style.transform = '';
145
+ player.tech_.el().style.transition = '';
146
+ });
147
+
148
+ };
149
+
150
+ export default initSwipe;
151
+ </code></pre>
152
+ </article>
153
+ </section>
154
+
155
+
156
+
157
+
158
+ </div>
159
+
160
+ <nav>
161
+ <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#Component">Component</a></li><li><a href="global.html#defaults">defaults</a></li><li><a href="global.html#getOrientation">getOrientation</a></li><li><a href="global.html#initSwipe">initSwipe</a></li><li><a href="global.html#mobileUi">mobileUi</a></li><li><a href="global.html#onPlayerReady">onPlayerReady</a></li></ul>
162
+ </nav>
163
+
164
+ <br class="clear">
165
+
166
+ <footer>
167
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Jan 23 2026 14:03:20 GMT+0100 (Mitteleuropäische Normalzeit)
168
+ </footer>
169
+
170
+ <script> prettyPrint(); </script>
171
+ <script src="scripts/linenumber.js"> </script>
172
+ </body>
173
+ </html>
@@ -0,0 +1,203 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: touchOverlay.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Source: touchOverlay.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>/**
30
+ * @file touchOverlay.js
31
+ * Touch UI component
32
+ */
33
+
34
+ import videojs from 'video.js';
35
+ import window from 'global/window';
36
+
37
+ /** @import Player from 'video.js/dist/types/player' */
38
+
39
+ const Component = videojs.getComponent('Component');
40
+ const dom = videojs.dom || videojs;
41
+
42
+ /**
43
+ * The `TouchOverlay` is an overlay to capture tap events.
44
+ *
45
+ * @extends Component
46
+ */
47
+ class TouchOverlay extends Component {
48
+
49
+ /**
50
+ * Creates an instance of the this class.
51
+ *
52
+ * @param {Player} player
53
+ * The `Player` that this class should be attached to.
54
+ *
55
+ * @param {options} [options]
56
+ * The key/value store of player options.
57
+ */
58
+ constructor(player, options) {
59
+ super(player, options);
60
+
61
+ this.seekSeconds = options.seekSeconds;
62
+ this.tapTimeout = options.tapTimeout;
63
+ this.taps = 0;
64
+
65
+ // Add play toggle overlay
66
+ this.addChild('playToggle', {});
67
+
68
+ // Clear overlay when playback starts or with control fade
69
+ player.on(['playing', 'userinactive'], e => {
70
+ this.removeClass('show-play-toggle');
71
+ });
72
+
73
+ // A 0 inactivity timeout won't work here
74
+ if (this.player_.options_.inactivityTimeout === 0) {
75
+ this.player_.options_.inactivityTimeout = 5000;
76
+ }
77
+
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 &lt; 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 &lt; 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
+ this.enable();
119
+ }
120
+
121
+ /**
122
+ * Builds the DOM element.
123
+ *
124
+ * @return {Element}
125
+ * The DOM element.
126
+ */
127
+ createEl() {
128
+ const el = dom.createEl('div', {
129
+ className: 'vjs-touch-overlay',
130
+ // Touch overlay is not tabbable.
131
+ tabIndex: -1
132
+ });
133
+
134
+ return el;
135
+ }
136
+
137
+ /**
138
+ * Debounces to either handle a delayed single tap, or a double tap
139
+ *
140
+ * @param {Event} event
141
+ * The touch event
142
+ *
143
+ */
144
+ handleTap(event) {
145
+ // Don't handle taps on the play button
146
+ if (event.target !== this.el_) {
147
+ return;
148
+ }
149
+
150
+ if (event.cancelable) {
151
+ event.preventDefault();
152
+ }
153
+
154
+ this.taps += 1;
155
+ if (this.taps === 1) {
156
+ this.removeClass('skip');
157
+ this.toggleClass('show-play-toggle');
158
+ }
159
+ this.handleTaps_(event);
160
+ }
161
+
162
+ /**
163
+ * Enables touch handler
164
+ */
165
+ enable() {
166
+ this.firstTapCaptured = false;
167
+ this.on('touchend', this.handleTap);
168
+ }
169
+
170
+ /**
171
+ * Disables touch handler
172
+ */
173
+ disable() {
174
+ this.off('touchend', this.handleTap);
175
+ }
176
+
177
+ }
178
+
179
+ Component.registerComponent('TouchOverlay', TouchOverlay);
180
+ export default TouchOverlay;
181
+ </code></pre>
182
+ </article>
183
+ </section>
184
+
185
+
186
+
187
+
188
+ </div>
189
+
190
+ <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#Component">Component</a></li><li><a href="global.html#defaults">defaults</a></li><li><a href="global.html#getOrientation">getOrientation</a></li><li><a href="global.html#initSwipe">initSwipe</a></li><li><a href="global.html#mobileUi">mobileUi</a></li><li><a href="global.html#onPlayerReady">onPlayerReady</a></li></ul>
192
+ </nav>
193
+
194
+ <br class="clear">
195
+
196
+ <footer>
197
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Jan 23 2026 14:03:20 GMT+0100 (Mitteleuropäische Normalzeit)
198
+ </footer>
199
+
200
+ <script> prettyPrint(); </script>
201
+ <script src="scripts/linenumber.js"> </script>
202
+ </body>
203
+ </html>