mirror of
https://github.com/webslides/WebSlides.git
synced 2025-08-22 04:43:42 +02:00
Housekeeping
This commit is contained in:
@@ -2,7 +2,6 @@ import DOM from '../utils/dom';
|
|||||||
import Keys from '../utils/keys';
|
import Keys from '../utils/keys';
|
||||||
import Slide from '../modules/slide';
|
import Slide from '../modules/slide';
|
||||||
|
|
||||||
|
|
||||||
const CLASSES = {
|
const CLASSES = {
|
||||||
ZOOM: 'grid',
|
ZOOM: 'grid',
|
||||||
DIV: 'column',
|
DIV: 'column',
|
||||||
@@ -45,7 +44,7 @@ export default class Zoom {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* On key down handler. Will decide if Zoom in or out
|
* On key down handler. Will decide if Zoom in or out
|
||||||
* @param {Event} event Key down event
|
* @param {Event} event Key down event.
|
||||||
*/
|
*/
|
||||||
onKeyDown(event) {
|
onKeyDown(event) {
|
||||||
if (!this.isZoomed_ && Keys.MINUS.includes(event.which)) {
|
if (!this.isZoomed_ && Keys.MINUS.includes(event.which)) {
|
||||||
@@ -58,7 +57,7 @@ export default class Zoom {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare zoom structure, scales the slides and uses a grid layout
|
* Prepare zoom structure, scales the slides and uses a grid layout
|
||||||
* to show them
|
* to show them.
|
||||||
*/
|
*/
|
||||||
preBuildZoom_() {
|
preBuildZoom_() {
|
||||||
// Clone #webslides element
|
// Clone #webslides element
|
||||||
@@ -83,8 +82,8 @@ export default class Zoom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a block structure around the slide
|
* Creates a block structure around the slide.
|
||||||
* @param {Element} elem slide element
|
* @param {Element} elem slide element.
|
||||||
*/
|
*/
|
||||||
createSlideBlock_(elem) {
|
createSlideBlock_(elem) {
|
||||||
// Wraps the slide around a container
|
// Wraps the slide around a container
|
||||||
@@ -145,7 +144,7 @@ export default class Zoom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles zoom
|
* Toggles zoom.
|
||||||
*/
|
*/
|
||||||
toggleZoom() {
|
toggleZoom() {
|
||||||
if (this.isZoomed_) {
|
if (this.isZoomed_) {
|
||||||
@@ -156,7 +155,7 @@ export default class Zoom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zoom In the slider, scales the slides and uses a grid layout to show them
|
* Zoom In the slider, scales the slides and uses a grid layout to show them.
|
||||||
*/
|
*/
|
||||||
zoomIn() {
|
zoomIn() {
|
||||||
this.ws_.el.classList.add('zooming', 'in');
|
this.ws_.el.classList.add('zooming', 'in');
|
||||||
@@ -172,7 +171,7 @@ export default class Zoom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zoom Out the slider, remove scale from the slides
|
* Zoom Out the slider, remove scale from the slides.
|
||||||
*/
|
*/
|
||||||
zoomOut() {
|
zoomOut() {
|
||||||
this.ws_.el.classList.add('zooming', 'out');
|
this.ws_.el.classList.add('zooming', 'out');
|
||||||
@@ -188,10 +187,9 @@ export default class Zoom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When windows resize it is necessary to recalculate layers sizes
|
* When windows resize it is necessary to recalculate layers sizes.
|
||||||
* @param {Event} ev
|
|
||||||
*/
|
*/
|
||||||
onWindowResize(ev) {
|
onWindowResize() {
|
||||||
if (this.isZoomed_) this.zoomOut();
|
if (this.isZoomed_) this.zoomOut();
|
||||||
|
|
||||||
this.zws_.slides.forEach(elem => {
|
this.zws_.slides.forEach(elem => {
|
||||||
|
@@ -182,19 +182,19 @@ export default class DOM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the integer value of a style property
|
* Gets the integer value of a style property.
|
||||||
* @param {string} prop CSS property value
|
* @param {string} prop CSS property value.
|
||||||
* @return {integer} The property without the units
|
* @return {Number} The property without the units.
|
||||||
*/
|
*/
|
||||||
static parseSize(prop) {
|
static parseSize(prop) {
|
||||||
return Number(prop.replace(/[^\d\.]/g, ''));
|
return Number(prop.replace(/[^\d\.]/g, ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps a HTML structure arrond a element
|
* Wraps a HTML structure around an element.
|
||||||
* @param {Element} elem the element to be wrapped
|
* @param {Element} elem the element to be wrapped.
|
||||||
* @param {string} tag the new element tag
|
* @param {string} tag the new element tag.
|
||||||
* @return {Element} the new element
|
* @return {Element} the new element.
|
||||||
*/
|
*/
|
||||||
static wrap(elem, tag) {
|
static wrap(elem, tag) {
|
||||||
const wrap = document.createElement(tag);
|
const wrap = document.createElement(tag);
|
||||||
@@ -205,9 +205,9 @@ export default class DOM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts and element after another element
|
* Inserts and element after another element.
|
||||||
* @param {Element} elem the element to be inserted
|
* @param {Element} elem the element to be inserted.
|
||||||
* @param {Element} target the element to be inserted after
|
* @param {Element} target the element to be inserted after.
|
||||||
*/
|
*/
|
||||||
static after(elem, target) {
|
static after(elem, target) {
|
||||||
const parent = target.parentNode;
|
const parent = target.parentNode;
|
||||||
|
Reference in New Issue
Block a user