mirror of
https://github.com/webslides/WebSlides.git
synced 2025-08-29 16:00:31 +02:00
Reworking the plugins
This commit is contained in:
@@ -8,7 +8,9 @@ const CLASSES = {
|
|||||||
VERTICAL: 'vertical'
|
VERTICAL: 'vertical'
|
||||||
};
|
};
|
||||||
|
|
||||||
const PLUGINS = ['Navigation'];
|
const PLUGINS = {
|
||||||
|
'nav': Plugins.Navigation
|
||||||
|
};
|
||||||
|
|
||||||
export default class WebSlides {
|
export default class WebSlides {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -31,6 +33,7 @@ export default class WebSlides {
|
|||||||
this.initSlides_();
|
this.initSlides_();
|
||||||
|
|
||||||
Hash.init(this);
|
Hash.init(this);
|
||||||
|
this.onInit_();
|
||||||
}
|
}
|
||||||
|
|
||||||
removeChildren_() {
|
removeChildren_() {
|
||||||
@@ -47,16 +50,16 @@ export default class WebSlides {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createPlugins_() {
|
createPlugins_() {
|
||||||
PLUGINS.forEach(pluginName => {
|
Object.keys(PLUGINS).forEach(pluginName => {
|
||||||
if (Plugins[pluginName]) {
|
const pluginCto = PLUGINS[pluginName];
|
||||||
const pluginCto = Plugins[pluginName];
|
this.plugins[pluginCto] = new pluginCto(this);
|
||||||
this.plugins[pluginCto] = new pluginCto(this);
|
|
||||||
} else {
|
|
||||||
throw new Error(`Tried to initialize plugin ${pluginName} but doesn't exist.`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onInit_() {
|
||||||
|
DOM.fireEvent(this.el, 'ws:init');
|
||||||
|
}
|
||||||
|
|
||||||
grabSlides_() {
|
grabSlides_() {
|
||||||
this.slides = Array.from(this.el.childNodes)
|
this.slides = Array.from(this.el.childNodes)
|
||||||
.map((slide, i) => new Slide(slide, i));
|
.map((slide, i) => new Slide(slide, i));
|
||||||
@@ -133,6 +136,11 @@ export default class WebSlides {
|
|||||||
this.isMoving = false;
|
this.isMoving = false;
|
||||||
|
|
||||||
Hash.setSlideNumber(this.currentSlideI_ + 1);
|
Hash.setSlideNumber(this.currentSlideI_ + 1);
|
||||||
|
DOM.fireEvent(this.el, 'ws:slide-change', {
|
||||||
|
slides: this.maxSlide_,
|
||||||
|
currentSlide0: this.currentSlideI_,
|
||||||
|
currentSlide: this.currentSlideI_ + 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
goNext() {
|
goNext() {
|
||||||
|
Reference in New Issue
Block a user