UNPKG

@huluvu424242/honey-slideshow

Version:

Text to Speech component wich is reading texts from DOM elements.

113 lines (110 loc) 2.98 kB
'use strict'; const HapticEngine = { getEngine() { const win = window; return (win.TapticEngine) || (win.Capacitor && win.Capacitor.isPluginAvailable('Haptics') && win.Capacitor.Plugins.Haptics); }, available() { return !!this.getEngine(); }, isCordova() { return !!window.TapticEngine; }, isCapacitor() { const win = window; return !!win.Capacitor; }, impact(options) { const engine = this.getEngine(); if (!engine) { return; } const style = this.isCapacitor() ? options.style.toUpperCase() : options.style; engine.impact({ style }); }, notification(options) { const engine = this.getEngine(); if (!engine) { return; } const style = this.isCapacitor() ? options.style.toUpperCase() : options.style; engine.notification({ style }); }, selection() { this.impact({ style: 'light' }); }, selectionStart() { const engine = this.getEngine(); if (!engine) { return; } if (this.isCapacitor()) { engine.selectionStart(); } else { engine.gestureSelectionStart(); } }, selectionChanged() { const engine = this.getEngine(); if (!engine) { return; } if (this.isCapacitor()) { engine.selectionChanged(); } else { engine.gestureSelectionChanged(); } }, selectionEnd() { const engine = this.getEngine(); if (!engine) { return; } if (this.isCapacitor()) { engine.selectionChanged(); } else { engine.gestureSelectionChanged(); } } }; /** * Trigger a selection changed haptic event. Good for one-time events * (not for gestures) */ const hapticSelection = () => { HapticEngine.selection(); }; /** * Tell the haptic engine that a gesture for a selection change is starting. */ const hapticSelectionStart = () => { HapticEngine.selectionStart(); }; /** * Tell the haptic engine that a selection changed during a gesture. */ const hapticSelectionChanged = () => { HapticEngine.selectionChanged(); }; /** * Tell the haptic engine we are done with a gesture. This needs to be * called lest resources are not properly recycled. */ const hapticSelectionEnd = () => { HapticEngine.selectionEnd(); }; /** * Use this to indicate success/failure/warning to the user. * options should be of the type `{ style: 'light' }` (or `medium`/`heavy`) */ const hapticImpact = (options) => { HapticEngine.impact(options); }; exports.hapticImpact = hapticImpact; exports.hapticSelection = hapticSelection; exports.hapticSelectionChanged = hapticSelectionChanged; exports.hapticSelectionEnd = hapticSelectionEnd; exports.hapticSelectionStart = hapticSelectionStart;