1
0
mirror of https://github.com/webslides/WebSlides.git synced 2025-09-15 23:42:16 +02:00

Compare commits

...

3 Commits
master ... dev

Author SHA1 Message Date
Antonio Laguna
b8b7211f4f Making video plugin a tad more generic
Fixes #122
2019-02-19 19:32:57 +01:00
Antonio Laguna
9dc223912e Adding the slide element to the ws:slide-change event
Fixes #127
2019-02-19 19:20:33 +01:00
Antonio Laguna
587590a8e8 Hiding scrollbar on Firefox
Fixes #129
2019-02-19 19:15:52 +01:00
6 changed files with 21 additions and 19 deletions

View File

@@ -19,7 +19,7 @@ const PLUGINS = {
'nav': Plugins.Navigation,
'scroll': Plugins.Scroll,
'touch': Plugins.Touch,
'video': Plugins.Video,
'media': Plugins.Media,
'youtube': Plugins.YouTube,
'zoom': Plugins.Zoom
};
@@ -315,6 +315,7 @@ export default class WebSlides {
DOM.fireEvent(this.el, 'ws:slide-change', {
slides: this.maxSlide_,
slideEl: slide.el,
currentSlide0: this.currentSlideI_,
currentSlide: this.currentSlideI_ + 1
});

View File

@@ -5,7 +5,7 @@ import {default as Slide, Events as SlideEvents} from '../modules/slide';
* Video plugin. Video plugin that allows to autoplay videos once the slide gets
* active.
*/
export default class Video {
export default class Media {
/**
* @param {WebSlides} wsInstance The WebSlides instance.
* @constructor
@@ -17,24 +17,24 @@ export default class Video {
*/
this.ws_ = wsInstance;
const videos = DOM.toArray(this.ws_.el.querySelectorAll('video'));
const medias = DOM.toArray(this.ws_.el.querySelectorAll('video,audio'));
if (videos.length) {
videos.forEach(video => {
if (!video.hasAttribute('autoplay')) {
if (medias.length) {
medias.forEach(media => {
if (!media.hasAttribute('autoplay')) {
return;
}
video.removeAttribute('autoplay');
video.pause();
video.currentTime = 0;
const {i} = Slide.getSectionFromEl(video);
media.removeAttribute('autoplay');
media.pause();
media.currentTime = 0;
const {i} = Slide.getSectionFromEl(media);
const slide = wsInstance.slides[i - 1];
slide.video = video;
slide.media = media;
slide.el.addEventListener(SlideEvents.ENABLE, Video.onSectionEnabled);
slide.el.addEventListener(SlideEvents.DISABLE, Video.onSectionDisabled);
slide.el.addEventListener(SlideEvents.ENABLE, Media.onSectionEnabled);
slide.el.addEventListener(SlideEvents.DISABLE, Media.onSectionDisabled);
});
}
}
@@ -44,7 +44,7 @@ export default class Video {
* @param {CustomEvent} event
*/
static onSectionEnabled(event) {
event.detail.slide.video.play();
event.detail.slide.media.play();
}
/**
@@ -52,6 +52,6 @@ export default class Video {
* @param {CustomEvent} event
*/
static onSectionDisabled(event) {
event.detail.slide.video.pause();
event.detail.slide.media.pause();
}
}

View File

@@ -6,7 +6,7 @@ import Keyboard from './keyboard';
import Navigation from './navigation';
import Scroll from './scroll';
import Touch from './touch';
import Video from './video';
import Media from './media';
import YouTube from './youtube';
import Zoom from './zoom';
@@ -19,7 +19,7 @@ export default {
Navigation,
Scroll,
Touch,
Video,
Media,
YouTube,
Zoom
};

View File

@@ -30,6 +30,7 @@ webslides.js will add .ws-ready automatically. Don't worry :) -- */
height: 100vh;
overflow-x: hidden;
overflow-y: scroll;
scrollbar-width: none; // sass-lint:disable-line no-misspelled-properties
&::-webkit-scrollbar {
display: none;

View File

@@ -51,7 +51,7 @@ test('Should have correct properties', () => {
expect(webslides.plugins.nav).toBeDefined();
expect(webslides.plugins.scroll).toBeDefined();
expect(webslides.plugins.touch).toBeDefined();
expect(webslides.plugins.video).toBeDefined();
expect(webslides.plugins.media).toBeDefined();
expect(webslides.plugins.youtube).toBeDefined();
expect(webslides.plugins.zoom).toBeDefined();

View File

@@ -1,4 +1,4 @@
import Video from '../../src/js/plugins/video';
import Video from '../../src/js/plugins/media';
import DOM from '../../src/js/utils/dom';
beforeAll(() => {