@eluvio/elv-player-js 1.0.96 → 1.0.97

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-player-js",
3
- "version": "1.0.96",
3
+ "version": "1.0.97",
4
4
  "description": "![Eluvio Logo](src/static/images/Logo.png \"Eluvio Logo\")",
5
5
  "main": "src/index.js",
6
6
  "license": "MIT",
@@ -115,7 +115,6 @@ class PlayerControls {
115
115
  this.playerOptions = playerOptions;
116
116
  this.timeouts = {};
117
117
  this.played = false;
118
- this.controlsHover = false;
119
118
  this.progressHidden = false;
120
119
 
121
120
  if(posterUrl) {
@@ -140,15 +139,17 @@ class PlayerControls {
140
139
  }
141
140
  }
142
141
 
143
- FadeOut(key, elements, delay=250, callback) {
142
+ FadeOut({key, elements, delay=250, unless, callback}) {
143
+ if(unless && unless()) { return; }
144
+
144
145
  clearTimeout(this.timeouts[key]);
145
146
 
146
147
  this.timeouts[key] = setTimeout(() => {
147
148
  elements.forEach(element => {
148
149
  if(!element) { return; }
149
150
 
150
- element.style.pointerEvents = "none";
151
- element.style.opacity = "0";
151
+ element.classList.add("-elv-fade-out");
152
+ element.classList.remove("-elv-fade-in");
152
153
  });
153
154
 
154
155
  if(callback) {
@@ -157,107 +158,86 @@ class PlayerControls {
157
158
  }, delay);
158
159
  }
159
160
 
160
- FadeIn(key, elements) {
161
+ FadeIn({key, elements, callback}) {
161
162
  clearTimeout(this.timeouts[key]);
162
163
 
163
164
  elements.forEach(element => {
164
165
  if(!element) { return; }
165
166
 
166
- element.style.opacity = "1";
167
- element.style.pointerEvents = "unset";
167
+ element.classList.remove("-elv-fade-out");
168
+ element.classList.add("-elv-fade-in");
168
169
  });
169
- }
170
170
 
171
+ if(callback) {
172
+ callback();
173
+ }
174
+ }
171
175
 
172
176
  AutohideControls(controls) {
173
177
  this.video.addEventListener("play", () => {
174
178
  this.played = true;
175
179
  });
176
180
 
177
- const PlayerOut = () => {
178
- if(!this.played && this.video.paused) { return; }
179
-
180
- this.FadeOut("controls", [controls, this.settingsMenu, this.toolTip], 2000);
181
- };
181
+ /*
182
+ Controls should stay visible if:
183
+ - Video hasn't started yet
184
+ - Settings menu is open
185
+ - Currently hovering over controls
186
+ - Currently keyboard-selecting controls
187
+ */
188
+ const ControlsShouldShow = () => (
189
+ (!this.played && this.video.paused) ||
190
+ (this.settingsMenu && this.settingsMenu.dataset.mode !== "hidden") ||
191
+ !!Array.from(document.querySelectorAll(":hover")).find(element => this.controls.contains(element)) ||
192
+ !!this.controls.contains(document.activeElement) && document.activeElement.classList.contains("focus-visible")
193
+ );
182
194
 
183
195
  const PlayerMove = () => {
184
- if(this.controlsHover) { return; }
185
-
186
- this.FadeIn("controls", [controls, this.settingsMenu, this.toolTip]);
187
- this.FadeOut("controls", [controls, this.settingsMenu, this.toolTip], 3000, () => this.target.style.cursor = "none");
196
+ this.FadeIn({
197
+ key: "controls",
198
+ elements: [controls, this.settingsMenu, this.toolTip],
199
+ callback: () => {
200
+ this.target.classList.remove("-elv-no-cursor");
201
+ }
202
+ });
203
+ this.FadeOut({
204
+ key: "controls",
205
+ elements: [controls, this.settingsMenu, this.toolTip],
206
+ delay: 3000,
207
+ unless: () => ControlsShouldShow(),
208
+ callback: () => {
209
+ this.target.classList.add("-elv-no-cursor");
210
+ }
211
+ });
188
212
 
189
213
  this.target.style.cursor = "unset";
190
214
  };
191
215
 
192
- const ControlsIn = () => {
193
- clearTimeout(this.timeouts.controls);
194
- this.controlsHover = true;
195
- };
196
-
197
- const ControlsOut = () => this.controlsHover = false;
198
-
199
216
  // Play / Pause
200
217
  this.video.addEventListener("play", () => PlayerMove);
201
218
  this.video.addEventListener("pause", () => PlayerMove);
202
219
 
203
220
  // Mouse events
204
221
  this.target.addEventListener("mousemove", PlayerMove);
205
- this.target.addEventListener("mouseleave", PlayerOut);
206
- controls.addEventListener("mouseenter", ControlsIn);
207
- controls.addEventListener("mouseleave", ControlsOut);
208
222
 
209
- if(this.settingsMenu) {
210
- this.settingsMenu.addEventListener("mouseenter", ControlsIn);
211
- this.settingsMenu.addEventListener("mouseleave", ControlsOut);
212
- }
213
-
214
- if(this.toolTip) {
215
- this.toolTip.addEventListener("mouseenter", ControlsIn);
216
- this.toolTip.addEventListener("mouseleave", ControlsOut);
217
- }
218
223
 
219
224
  // Touch events
220
225
  this.target.addEventListener("touchmove", PlayerMove);
221
- this.target.addEventListener("touchleave", PlayerOut);
222
- controls.addEventListener("touchmove", ControlsIn);
223
- controls.addEventListener("touchleave", ControlsOut);
224
- controls.addEventListener("touchend", () => { ControlsOut(); PlayerOut(); });
225
-
226
- if(this.settingsMenu) {
227
- this.settingsMenu.addEventListener("touchmove", ControlsIn);
228
- this.settingsMenu.addEventListener("touchleave", ControlsOut);
229
- this.settingsMenu.addEventListener("touchend", () => {
230
- ControlsOut();
231
- PlayerOut();
232
- });
233
- }
234
-
235
- if(this.toolTip) {
236
- this.toolTip.addEventListener("touchmove", ControlsIn);
237
- this.toolTip.addEventListener("touchleave", ControlsOut);
238
- this.toolTip.addEventListener("touchend", () => {
239
- ControlsOut();
240
- PlayerOut();
241
- });
242
- }
243
226
 
244
227
  // Keyboard events
245
228
  this.target.addEventListener("blur", () => setTimeout(() => {
246
229
  if(!this.target.contains(document.activeElement)) {
247
- PlayerOut();
248
- ControlsOut();
230
+ PlayerMove();
249
231
  }
250
232
  }), 2000);
251
233
 
252
- window.addEventListener("blur", () => { PlayerOut(); ControlsOut(); });
234
+ window.addEventListener("blur", () => { PlayerMove(); });
253
235
 
254
236
  Array.from(this.target.querySelectorAll("button, input")).forEach(button => {
255
- button.addEventListener("focus", () => { PlayerMove(); ControlsIn(); });
237
+ button.addEventListener("focus", () => { PlayerMove(); });
256
238
  });
257
239
 
258
- if(!this.controlsHover) {
259
- PlayerOut();
260
- }
240
+ PlayerMove();
261
241
  }
262
242
 
263
243
  InitializeControls(className="") {
@@ -380,12 +360,12 @@ class PlayerControls {
380
360
  });
381
361
 
382
362
  this.video.addEventListener("play", () => {
383
- this.FadeOut("big-play-button", [this.bigPlayButton]);
363
+ this.FadeOut({key: "big-play-button", elements: [this.bigPlayButton]});
384
364
 
385
365
  // Prevent big play button from flashing
386
366
  setTimeout(() => this.target.classList.remove("eluvio-player-restarted"), 1000);
387
367
  });
388
- this.video.addEventListener("pause", () => this.FadeIn("big-play-button", [this.bigPlayButton]));
368
+ this.video.addEventListener("pause", () => this.FadeIn({key: "big-play-button", elements: [this.bigPlayButton]}));
389
369
 
390
370
  this.bigPlayButton.style.display = this.video.paused ? null : "none";
391
371
  this.bigPlayButton.addEventListener("click", () => this.video.play());
@@ -41,6 +41,7 @@ $button-height: 35px;
41
41
  box-sizing: border-box;
42
42
  font-family: "Helvetica Neue", Helvetica, sans-serif;
43
43
  line-height: 1;
44
+ overscroll-behavior-y: contain; // sass-lint:disable-line no-misspelled-properties
44
45
  }
45
46
 
46
47
  // sass-lint:disable force-attribute-nesting no-qualifying-elements
@@ -460,12 +461,6 @@ $button-height: 35px;
460
461
  }
461
462
  }
462
463
 
463
- &.eluvio-player-autohide {
464
- .eluvio-player__controls {
465
- opacity: 0;
466
- }
467
- }
468
-
469
464
  &:fullscreen {
470
465
  margin: 0;
471
466
  max-height: unset;
@@ -697,7 +692,7 @@ $button-height: 35px;
697
692
  align-items: center;
698
693
  height: 100%;
699
694
  max-height: 100%;
700
- padding: 80px 0 30px;
695
+ padding: 80px 0 100px;
701
696
  right: 0;
702
697
  top: 0;
703
698
  width: 100%;
@@ -728,6 +723,29 @@ $button-height: 35px;
728
723
  }
729
724
  }
730
725
 
726
+ // sass-lint:disable no-important
727
+ .-elv-fade-in,
728
+ .-elv-fade-out {
729
+ transition: opacity 0.25s linear;
730
+ }
731
+
732
+ .-elv-fade-out {
733
+ opacity: 0 !important;
734
+ pointer-events: none !important;
735
+ }
736
+
737
+ .-elv-fade-in {
738
+ opacity: 1;
739
+ }
740
+
741
+ .-elv-no-cursor {
742
+ cursor: none !important;
743
+
744
+ * {
745
+ cursor: none !important;
746
+ }
747
+ }
748
+
731
749
  // sass-lint:disable no-color-literals
732
750
  @keyframes hotspot-select {
733
751
  0% {