mirror of
https://github.com/webslides/WebSlides.git
synced 2025-09-02 17:42:45 +02:00
Adding eslintrc and add linting
This commit is contained in:
@@ -18,6 +18,10 @@ const PLUGINS = {
|
||||
'touch': Plugins.Touch
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* WebSlides module.
|
||||
*/
|
||||
export default class WebSlides {
|
||||
/**
|
||||
* Options for WebSlides
|
||||
@@ -144,8 +148,8 @@ export default class WebSlides {
|
||||
*/
|
||||
createPlugins_() {
|
||||
Object.keys(PLUGINS).forEach(pluginName => {
|
||||
const pluginCto = PLUGINS[pluginName];
|
||||
this.plugins[pluginName] = new pluginCto(this);
|
||||
const PluginCto = PLUGINS[pluginName];
|
||||
this.plugins[pluginName] = new PluginCto(this);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -232,7 +236,9 @@ export default class WebSlides {
|
||||
}
|
||||
|
||||
this.el.style.overflow = 'auto';
|
||||
setTimeout(() => { callback.call(this, nextSlide); }, 150);
|
||||
setTimeout(() => {
|
||||
callback.call(this, nextSlide);
|
||||
}, 150);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -7,6 +7,9 @@ const CLICKABLE_ELS = [
|
||||
'TEXTAREA'
|
||||
];
|
||||
|
||||
/**
|
||||
* Click to Nav plugin.
|
||||
*/
|
||||
export default class ClickNav {
|
||||
/**
|
||||
* ClickNav plugin that allows to click on the page to get to the next slide.
|
||||
|
@@ -1,5 +1,8 @@
|
||||
import Keys from '../utils/keys';
|
||||
|
||||
/**
|
||||
* Grid plugin.
|
||||
*/
|
||||
export default class Grid {
|
||||
/**
|
||||
* Grid plugin that shows a grid on top of the WebSlides for easy prototyping.
|
||||
@@ -20,7 +23,7 @@ export default class Grid {
|
||||
|
||||
style.type = 'text/css';
|
||||
|
||||
if (style.styleSheet){
|
||||
if (style.styleSheet) {
|
||||
style.styleSheet.cssText = CSS;
|
||||
} else {
|
||||
style.appendChild(document.createTextNode(CSS));
|
||||
|
@@ -8,7 +8,7 @@ const slideRegex = /#slide=(\d+)/;
|
||||
export default class Hash {
|
||||
/**
|
||||
* Listens to the slide change event and the hash change events.
|
||||
* @param wsInstance
|
||||
* @param {WebSlides} wsInstance
|
||||
*/
|
||||
constructor(wsInstance) {
|
||||
this.ws_ = wsInstance;
|
||||
@@ -29,6 +29,11 @@ export default class Hash {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for the slide change event which updates the slide on the hash.
|
||||
* @param {Event} event
|
||||
* @private
|
||||
*/
|
||||
static onSlideChange_(event) {
|
||||
Hash.setSlideNumber(event.detail.currentSlide);
|
||||
}
|
||||
@@ -40,7 +45,7 @@ export default class Hash {
|
||||
* @return {?number}
|
||||
*/
|
||||
static getSlideNumber() {
|
||||
let results = document.location.hash.match(slideRegex);
|
||||
const results = document.location.hash.match(slideRegex);
|
||||
let slide = 0;
|
||||
|
||||
if (Array.isArray(results)) {
|
||||
|
@@ -1,5 +1,8 @@
|
||||
import Keys from '../utils/keys';
|
||||
|
||||
/**
|
||||
* Keyboard plugin.
|
||||
*/
|
||||
export default class Keyboard {
|
||||
/**
|
||||
* Keyboard interaction plugin.
|
||||
|
@@ -18,6 +18,9 @@ const LABELS = {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Navigation plugin.
|
||||
*/
|
||||
export default class Navigation {
|
||||
/**
|
||||
* The Navigation constructor. It'll create all the nodes needed for the
|
||||
|
@@ -1,5 +1,9 @@
|
||||
import MobileDetector from '../utils/mobile-detector';
|
||||
|
||||
|
||||
/**
|
||||
* Scroll plugin.
|
||||
*/
|
||||
export default class Scroll {
|
||||
/**
|
||||
* Scroll handler for the WebSlides.
|
||||
@@ -54,7 +58,9 @@ export default class Scroll {
|
||||
*/
|
||||
onSlideChange_() {
|
||||
this.timeout_ = setTimeout(
|
||||
() => { this.timeout_ = null; },
|
||||
() => {
|
||||
this.timeout_ = null;
|
||||
},
|
||||
this.ws_.options.scrollWait);
|
||||
}
|
||||
|
||||
@@ -70,7 +76,7 @@ export default class Scroll {
|
||||
return;
|
||||
}
|
||||
|
||||
const { deltaY: wheelDeltaY, deltaX: wheelDeltaX } = event;
|
||||
const {deltaY: wheelDeltaY, deltaX: wheelDeltaX} = event;
|
||||
const isVertical = this.ws_.isVertical;
|
||||
const isHorizontalMovement = Math.abs(wheelDeltaX) > Math.abs(wheelDeltaY);
|
||||
this.isGoingUp_ = wheelDeltaY < 0;
|
||||
@@ -100,4 +106,4 @@ export default class Scroll {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -13,6 +13,9 @@ const EVENTS = {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Touch plugin.
|
||||
*/
|
||||
export default class Touch {
|
||||
/**
|
||||
* @param {WebSlides} wsInstance The WebSlides instance
|
||||
@@ -80,7 +83,7 @@ export default class Touch {
|
||||
|
||||
/**
|
||||
* Start touch handler. Saves starting points.
|
||||
* @param event
|
||||
* @param {Event} event The Touch event.
|
||||
* @private
|
||||
*/
|
||||
onStart_(event) {
|
||||
@@ -94,7 +97,7 @@ export default class Touch {
|
||||
|
||||
/**
|
||||
* Move touch handler. Saves end points.
|
||||
* @param event
|
||||
* @param {Event} event The Touch event.
|
||||
* @private
|
||||
*/
|
||||
onMove_(event) {
|
||||
@@ -125,25 +128,22 @@ export default class Touch {
|
||||
/**
|
||||
* Normalizes an event to deal with differences between PointerEvent and
|
||||
* TouchEvent.
|
||||
* @param event
|
||||
* @return {*}
|
||||
* @param {Event} event
|
||||
* @return {Object} Normalised touch points.
|
||||
*/
|
||||
static normalizeEventInfo(event) {
|
||||
let x;
|
||||
let y;
|
||||
let touchEvent = { pageX : 0, pageY : 0};
|
||||
let touchEvent = {pageX: 0, pageY: 0};
|
||||
|
||||
if (typeof event.changedTouches !== 'undefined'){
|
||||
if (typeof event.changedTouches !== 'undefined') {
|
||||
touchEvent = event.changedTouches[0];
|
||||
}
|
||||
else if (typeof event.originalEvent !== 'undefined' &&
|
||||
typeof event.originalEvent.changedTouches !== 'undefined'){
|
||||
} else if (typeof event.originalEvent !== 'undefined' &&
|
||||
typeof event.originalEvent.changedTouches !== 'undefined') {
|
||||
touchEvent = event.originalEvent.changedTouches[0];
|
||||
}
|
||||
|
||||
x = event.offsetX || event.layerX || touchEvent.pageX;
|
||||
y = event.offsetY || event.layerY || touchEvent.pageY;
|
||||
const x = event.offsetX || event.layerX || touchEvent.pageX;
|
||||
const y = event.offsetY || event.layerY || touchEvent.pageY;
|
||||
|
||||
return { x, y };
|
||||
return {x, y};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -5,12 +5,16 @@ const NativeCustomEvent = window.CustomEvent;
|
||||
* completely on IE.
|
||||
* @return {boolean} Whether it can be used or not.
|
||||
*/
|
||||
function canIuseNativeCustom () {
|
||||
function canIuseNativeCustom() {
|
||||
try {
|
||||
const p = new NativeCustomEvent('t', { detail: { a: 'b' } });
|
||||
return 't' === p.type && 'b' === p.detail.a;
|
||||
} catch (e) {
|
||||
}
|
||||
const p = new NativeCustomEvent('t', {
|
||||
detail: {
|
||||
a: 'b'
|
||||
}
|
||||
});
|
||||
return 't' === p.type && 'b' === p.detail.a;
|
||||
} catch (e) { }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* @param {number} p The percentage of time that has passed.
|
||||
* @return {number}
|
||||
*/
|
||||
function swing (p) {
|
||||
function swing(p) {
|
||||
return 0.5 - Math.cos(p * Math.PI) / 2;
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ function linear(p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
export default { swing, linear };
|
||||
export default {swing, linear};
|
||||
|
@@ -1,5 +1,9 @@
|
||||
const UA = window.navigator.userAgent;
|
||||
|
||||
/**
|
||||
* Mobile detector helper class. Tests the User Agent to see if we're, likely,
|
||||
* on a mobile device.
|
||||
*/
|
||||
export default class MobileDetector {
|
||||
/**
|
||||
* Whether the device is Android or not.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import Easings from './easing';
|
||||
|
||||
let SCROLLABLE_CONTAINER = document.getElementById('webslides');
|
||||
const SCROLLABLE_CONTAINER = document.getElementById('webslides');
|
||||
|
||||
/**
|
||||
* Smoothly scrolls to a given Y position using Easing.Swing. It'll run a
|
||||
|
Reference in New Issue
Block a user