move progress bar to new module
This commit is contained in:
1 parent
c50ec00419
commit
6ff4e9306c
6 files changed
+125
-63
No files matched your search
Vendored
+1
-1
@@ -5,4 +5,4 @@
|
||||
*
|
||||
* Copyright (C) 2020 Hakim El Hattab, https://hakim.se
|
||||
*/
|
||||
!function(e){var t={};function i(a){if(t[a])return t[a].exports;var s=t[a]={i:a,l:!1,exports:{}};return e[a].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=e,i.c=t,i.d=function(e,t,a){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(i.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(a,s,function(t){return e[t]}.bind(null,s));return a},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=0)}([function(e,t,i){"use strict";i.r(t);const a=/registerPlugin|registerKeyboardShortcut|addKeyBinding|addEventListener/,s=(e,t)=>{for(let i in t)e[i]=t[i];return e},n=e=>Array.prototype.slice.call(e),r=e=>{if("string"==typeof e){if("null"===e)return null;if("true"===e)return!0;if("false"===e)return!1;if(e.match(/^-?[\d\.]+$/))return parseFloat(e)}return e},o=(e,t)=>{e.style.transform=t},l=(e,t)=>{let i=e.parentNode;for(;i;){let e=i.matches||i.matchesSelector||i.msMatchesSelector;if(e&&e.call(i,t))return i;i=i.parentNode}return null},d=(e,t,i,a="")=>{let s=e.querySelectorAll("."+i);for(let t=0;t<s.length;t++){let i=s[t];if(i.parentNode===e)return i}let n=document.createElement(t);return n.className=i,n.innerHTML=a,e.appendChild(n),n},c=e=>{let t=document.createElement("style");return t.type="text/css",e&&e.length>0&&(t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))),document.head.appendChild(t),t},h=()=>{let e={};location.search.replace(/[A-Z0-9]+?=([\w\.%-]*)/gi,t=>{e[t.split("=").shift()]=t.split("=").pop()});for(let t in e){let i=e[t];e[t]=r(unescape(i))}return void 0!==e.dependencies&&delete e.dependencies,e},u=navigator.userAgent,g=document.createElement("div"),v=/(iphone|ipod|ipad|android)/gi.test(u)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,p=/chrome/i.test(u)&&!/edge/i.test(u),m=/android/gi.test(u),f="zoom"in g.style&&!v&&(p||/Version\/[\d\.]+.*Safari/.test(u));class b{constructor(e){this.Reveal=e}shouldPreload(e){let t=this.Reveal.getConfig().preloadIframes;return"boolean"!=typeof t&&(t=e.hasAttribute("data-preload")),t}load(e,t={}){e.style.display=this.Reveal.getConfig().display,n(e.querySelectorAll("img[data-src], video[data-src], audio[data-src], iframe[data-src]")).forEach(e=>{("IFRAME"!==e.tagName||this.shouldPreload(e))&&(e.setAttribute("src",e.getAttribute("data-src")),e.setAttribute("data-lazy-loaded",""),e.removeAttribute("data-src"))}),n(e.querySelectorAll("video, audio")).forEach(e=>{let t=0;n(e.querySelectorAll("source[data-src]")).forEach(e=>{e.setAttribute("src",e.getAttribute("data-src")),e.removeAttribute("data-src"),e.setAttribute("data-lazy-loaded",""),t+=1}),t>0&&e.load()});let i=e.slideBackgroundElement;if(i){i.style.display="block";let a=e.slideBackgroundContentElement,s=e.getAttribute("data-background-iframe");if(!1===i.hasAttribute("data-loaded")){i.setAttribute("data-loaded","true");let n=e.getAttribute("data-background-image"),r=e.getAttribute("data-background-video"),o=e.hasAttribute("data-background-video-loop"),l=e.hasAttribute("data-background-video-muted");if(n)a.style.backgroundImage="url("+encodeURI(n)+")";else if(r&&!this.Reveal.isSpeakerNotes()){let e=document.createElement("video");o&&e.setAttribute("loop",""),l&&(e.muted=!0),v&&(e.muted=!0,e.autoplay=!0,e.setAttribute("playsinline","")),r.split(",").forEach(t=>{e.innerHTML+='<source src="'+t+'">'}),a.appendChild(e)}else if(s&&!0!==t.excludeIframes){let e=document.createElement("iframe");e.setAttribute("allowfullscreen",""),e.setAttribute("mozallowfullscreen",""),e.setAttribute("webkitallowfullscreen",""),e.setAttribute("allow","autoplay"),e.setAttribute("data-src",s),e.style.width="100%",e.style.height="100%",e.style.maxHeight="100%",e.style.maxWidth="100%",a.appendChild(e)}}let n=a.querySelector("iframe[data-src]");n&&this.shouldPreload(i)&&!/autoplay=(1|true|yes)/gi.test(s)&&n.getAttribute("src")!==s&&n.setAttribute("src",s)}}unload(e){e.style.display="none";let t=this.Reveal.getSlideBackground(e);t&&(t.style.display="none",n(t.querySelectorAll("iframe[src]")).forEach(e=>{e.removeAttribute("src")})),n(e.querySelectorAll("video[data-lazy-loaded][src], audio[data-lazy-loaded][src], iframe[data-lazy-loaded][src]")).forEach(e=>{e.setAttribute("data-src",e.getAttribute("src")),e.removeAttribute("src")}),n(e.querySelectorAll("video[data-lazy-loaded] source[src], audio source[src]")).forEach(e=>{e.setAttribute("data-src",e.getAttribute("src")),e.removeAttribute("src")})}formatEmbeddedContent(){let e=(e,t,i)=>{n(this.Reveal.getSlidesElement().querySelectorAll("iframe["+e+'*="'+t+'Line truncated
|
||||
!function(e){var t={};function i(a){if(t[a])return t[a].exports;var s=t[a]={i:a,l:!1,exports:{}};return e[a].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=e,i.c=t,i.d=function(e,t,a){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(i.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(a,s,function(t){return e[t]}.bind(null,s));return a},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=0)}([function(e,t,i){"use strict";i.r(t);const a=/registerPlugin|registerKeyboardShortcut|addKeyBinding|addEventListener/,s=(e,t)=>{for(let i in t)e[i]=t[i];return e},n=e=>Array.prototype.slice.call(e),r=e=>{if("string"==typeof e){if("null"===e)return null;if("true"===e)return!0;if("false"===e)return!1;if(e.match(/^-?[\d\.]+$/))return parseFloat(e)}return e},o=(e,t)=>{e.style.transform=t},l=(e,t)=>{let i=e.parentNode;for(;i;){let e=i.matches||i.matchesSelector||i.msMatchesSelector;if(e&&e.call(i,t))return i;i=i.parentNode}return null},d=e=>{let t=document.createElement("style");return t.type="text/css",e&&e.length>0&&(t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))),document.head.appendChild(t),t},c=()=>{let e={};location.search.replace(/[A-Z0-9]+?=([\w\.%-]*)/gi,t=>{e[t.split("=").shift()]=t.split("=").pop()});for(let t in e){let i=e[t];e[t]=r(unescape(i))}return void 0!==e.dependencies&&delete e.dependencies,e},h=navigator.userAgent,u=document.createElement("div"),g=/(iphone|ipod|ipad|android)/gi.test(h)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,v=/chrome/i.test(h)&&!/edge/i.test(h),p=/android/gi.test(h),m="zoom"in u.style&&!g&&(v||/Version\/[\d\.]+.*Safari/.test(h));class f{constructor(e){this.Reveal=e}shouldPreload(e){let t=this.Reveal.getConfig().preloadIframes;return"boolean"!=typeof t&&(t=e.hasAttribute("data-preload")),t}load(e,t={}){e.style.display=this.Reveal.getConfig().display,n(e.querySelectorAll("img[data-src], video[data-src], audio[data-src], iframe[data-src]")).forEach(e=>{("IFRAME"!==e.tagName||this.shouldPreload(e))&&(e.setAttribute("src",e.getAttribute("data-src")),e.setAttribute("data-lazy-loaded",""),e.removeAttribute("data-src"))}),n(e.querySelectorAll("video, audio")).forEach(e=>{let t=0;n(e.querySelectorAll("source[data-src]")).forEach(e=>{e.setAttribute("src",e.getAttribute("data-src")),e.removeAttribute("data-src"),e.setAttribute("data-lazy-loaded",""),t+=1}),t>0&&e.load()});let i=e.slideBackgroundElement;if(i){i.style.display="block";let a=e.slideBackgroundContentElement,s=e.getAttribute("data-background-iframe");if(!1===i.hasAttribute("data-loaded")){i.setAttribute("data-loaded","true");let n=e.getAttribute("data-background-image"),r=e.getAttribute("data-background-video"),o=e.hasAttribute("data-background-video-loop"),l=e.hasAttribute("data-background-video-muted");if(n)a.style.backgroundImage="url("+encodeURI(n)+")";else if(r&&!this.Reveal.isSpeakerNotes()){let e=document.createElement("video");o&&e.setAttribute("loop",""),l&&(e.muted=!0),g&&(e.muted=!0,e.autoplay=!0,e.setAttribute("playsinline","")),r.split(",").forEach(t=>{e.innerHTML+='<source src="'+t+'">'}),a.appendChild(e)}else if(s&&!0!==t.excludeIframes){let e=document.createElement("iframe");e.setAttribute("allowfullscreen",""),e.setAttribute("mozallowfullscreen",""),e.setAttribute("webkitallowfullscreen",""),e.setAttribute("allow","autoplay"),e.setAttribute("data-src",s),e.style.width="100%",e.style.height="100%",e.style.maxHeight="100%",e.style.maxWidth="100%",a.appendChild(e)}}let n=a.querySelector("iframe[data-src]");n&&this.shouldPreload(i)&&!/autoplay=(1|true|yes)/gi.test(s)&&n.getAttribute("src")!==s&&n.setAttribute("src",s)}}unload(e){e.style.display="none";let t=this.Reveal.getSlideBackground(e);t&&(t.style.display="none",n(t.querySelectorAll("iframe[src]")).forEach(e=>{e.removeAttribute("src")})),n(e.querySelectorAll("video[data-lazy-loaded][src], audio[data-lazy-loaded][src], iframe[data-lazy-loaded][src]")).forEach(e=>{e.setAttribute("data-src",e.getAttribute("src")),e.removeAttribute("src")}),n(e.querySelectorAll("video[data-lazy-loaded] source[src], audio source[src]")).forEach(e=>{e.setAttribute("data-src",e.getAttribute("src")),e.removeAttribute("src")})}formatEmbeddedContent(){let e=(e,t,i)=>{n(this.Reveal.getSlidesElement().querySelectorAll("iframe["+e+'*="'+t+'"]')).forEach(t=>{let a=t.getAttribute(e);a&&-1===a.indexOf(i)&&t.setAttribute(e,a+(/\?/.test(a)?"&":"?")+i)})};e("src","youtube.com/embed/","enablejsapi=1"),e("data-src","youtube.com/embed/","enablejsapiLine truncated
|
||||
@@ -26,11 +26,17 @@ const license = `/*!
|
||||
*/\n`
|
||||
|
||||
|
||||
const swallowError = function(error) {
|
||||
console.log(error.toString())
|
||||
this.emit('end')
|
||||
}
|
||||
|
||||
gulp.task('js', () => gulp.src(['./js/index.js'])
|
||||
.pipe(babel({ presets: ['@babel/preset-env'] }))
|
||||
.pipe(webpack({
|
||||
mode: 'production'
|
||||
}))
|
||||
.on('error', swallowError)
|
||||
.pipe(header(license, {pkg: pkg}))
|
||||
.pipe(rename('reveal.min.js'))
|
||||
.pipe(gulp.dest('./dist')))
|
||||
|
||||
Vendored
+11
-2
@@ -1,8 +1,17 @@
|
||||
import { toArray } from '../utils/util.js'
|
||||
import { isMobile, isAndroid } from '../utils/device.js'
|
||||
import { isAndroid } from '../utils/device.js'
|
||||
|
||||
/**
|
||||
*
|
||||
* Manages our presentation controls. This includes both
|
||||
* the built-in control arrows as well as event monitoring
|
||||
* of any elements within the presentation with either of the
|
||||
* following helper classes:
|
||||
* - .navigate-up
|
||||
* - .navigate-right
|
||||
* - .navigate-down
|
||||
* - .navigate-left
|
||||
* - .navigate-next
|
||||
* - .navigate-prev
|
||||
*/
|
||||
export default class Controls {
|
||||
|
||||
|
||||
@@ -332,8 +332,7 @@ export default class Fragments {
|
||||
}
|
||||
|
||||
this.Reveal.controls.update();
|
||||
|
||||
this.Reveal.updateProgress();
|
||||
this.Reveal.progress.update();
|
||||
|
||||
if( this.Reveal.getConfig().fragmentInURL ) {
|
||||
this.Reveal.location.writeURL();
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* Creates a visual progress bar for the presentation.
|
||||
*/
|
||||
export default class Progress {
|
||||
|
||||
constructor( Reveal ) {
|
||||
|
||||
this.Reveal = Reveal;
|
||||
|
||||
this.onProgressClicked = this.onProgressClicked.bind( this );
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
this.element = document.createElement( 'div' );
|
||||
this.element.className = 'progress';
|
||||
this.Reveal.getRevealElement().appendChild( this.element );
|
||||
|
||||
this.bar = document.createElement( 'span' );
|
||||
this.element.appendChild( this.bar );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the reveal.js config is updated.
|
||||
*/
|
||||
configure( config, oldConfig ) {
|
||||
|
||||
this.element.style.display = config.progress ? 'block' : 'none';
|
||||
|
||||
}
|
||||
|
||||
bind() {
|
||||
|
||||
if( this.Reveal.getConfig().progress && this.element ) {
|
||||
this.element.addEventListener( 'click', this.onProgressClicked, false );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
unbind() {
|
||||
|
||||
if ( this.Reveal.getConfig().progress && this.element ) {
|
||||
this.element.removeEventListener( 'click', this.onProgressClicked, false );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the progress bar to reflect the current slide.
|
||||
*/
|
||||
update() {
|
||||
|
||||
// Update progress if enabled
|
||||
if( this.Reveal.getConfig().progress && this.bar ) {
|
||||
|
||||
this.bar.style.width = this.Reveal.getProgress() * this.getMaxWidth() + 'px';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getMaxWidth() {
|
||||
|
||||
return this.Reveal.getRevealElement().offsetWidth;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicking on the progress bar results in a navigation to the
|
||||
* closest approximate horizontal slide using this equation:
|
||||
*
|
||||
* ( clickX / presentationWidth ) * numberOfSlides
|
||||
*
|
||||
* @param {object} event
|
||||
*/
|
||||
onProgressClicked( event ) {
|
||||
|
||||
this.Reveal.onUserInput( event );
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
let slidesTotal = this.Reveal.getHorizontalSlides().length;
|
||||
let slideIndex = Math.floor( ( event.clientX / this.getMaxWidth() ) * slidesTotal );
|
||||
|
||||
if( this.Reveal.getConfig().rtl ) {
|
||||
slideIndex = slidesTotal - slideIndex;
|
||||
}
|
||||
|
||||
this.Reveal.slide( slideIndex );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+10
-58
@@ -7,6 +7,7 @@ import Overview from './controllers/overview.js'
|
||||
import Keyboard from './controllers/keyboard.js'
|
||||
import Location from './controllers/location.js'
|
||||
import Controls from './controllers/controls.js'
|
||||
import Progress from './controllers/progress.js'
|
||||
import Plugins from './controllers/plugins.js'
|
||||
import Print from './controllers/print.js'
|
||||
import Touch from './controllers/touch.js'
|
||||
@@ -84,6 +85,7 @@ export default function( revealElement, options ) {
|
||||
keyboard = new Keyboard( Reveal ),
|
||||
location = new Location( Reveal ),
|
||||
controls = new Controls( Reveal ),
|
||||
progress = new Progress( Reveal ),
|
||||
plugins = new Plugins( Reveal ),
|
||||
print = new Print( Reveal ),
|
||||
touch = new Touch( Reveal ),
|
||||
@@ -227,14 +229,10 @@ export default function( revealElement, options ) {
|
||||
dom.wrapper.classList.remove( 'no-hover' );
|
||||
}
|
||||
|
||||
|
||||
// Progress bar
|
||||
dom.progress = createSingletonNode( dom.wrapper, 'div', 'progress', '<span></span>' );
|
||||
dom.progressbar = dom.progress.querySelector( 'span' );
|
||||
|
||||
backgrounds.render();
|
||||
slideNumber.render();
|
||||
controls.render();
|
||||
progress.render();
|
||||
notes.render();
|
||||
|
||||
// Overlay graphic which is displayed during the paused mode
|
||||
@@ -404,8 +402,6 @@ export default function( revealElement, options ) {
|
||||
dom.wrapper.setAttribute( 'data-transition-speed', config.transitionSpeed );
|
||||
dom.wrapper.setAttribute( 'data-background-transition', config.backgroundTransition );
|
||||
|
||||
dom.progress.style.display = config.progress ? 'block' : 'none';
|
||||
|
||||
if( config.shuffle ) {
|
||||
shuffle();
|
||||
}
|
||||
@@ -489,6 +485,7 @@ export default function( revealElement, options ) {
|
||||
|
||||
notes.configure( config, oldConfig );
|
||||
controls.configure( config, oldConfig );
|
||||
progress.configure( config, oldConfig );
|
||||
keyboard.configure( config, oldConfig );
|
||||
fragments.configure( config, oldConfig );
|
||||
slideNumber.configure( config, oldConfig );
|
||||
@@ -510,10 +507,7 @@ export default function( revealElement, options ) {
|
||||
if( config.touch ) touch.bind();
|
||||
if( config.keyboard ) keyboard.bind();
|
||||
controls.bind();
|
||||
|
||||
if( config.progress && dom.progress ) {
|
||||
dom.progress.addEventListener( 'click', onProgressClicked, false );
|
||||
}
|
||||
progress.bind();
|
||||
|
||||
dom.pauseOverlay.addEventListener( 'click', resume, false );
|
||||
|
||||
@@ -533,16 +527,13 @@ export default function( revealElement, options ) {
|
||||
touch.unbind();
|
||||
keyboard.unbind();
|
||||
controls.unbind();
|
||||
progress.unbind();
|
||||
|
||||
window.removeEventListener( 'hashchange', onWindowHashChange, false );
|
||||
window.removeEventListener( 'resize', onWindowResize, false );
|
||||
|
||||
dom.pauseOverlay.removeEventListener( 'click', resume, false );
|
||||
|
||||
if ( config.progress && dom.progress ) {
|
||||
dom.progress.removeEventListener( 'click', onProgressClicked, false );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -911,7 +902,7 @@ export default function( revealElement, options ) {
|
||||
}
|
||||
}
|
||||
|
||||
updateProgress();
|
||||
progress.update();
|
||||
backgrounds.updateParallax();
|
||||
|
||||
if( overview.isActive() ) {
|
||||
@@ -1349,8 +1340,8 @@ export default function( revealElement, options ) {
|
||||
// Announce the current slide contents to screen readers
|
||||
announceStatus( getStatusText( currentSlide ) );
|
||||
|
||||
updateProgress();
|
||||
|
||||
progress.update();
|
||||
controls.update();
|
||||
notes.update();
|
||||
backgrounds.update();
|
||||
@@ -1414,8 +1405,8 @@ export default function( revealElement, options ) {
|
||||
fragments.sortAll();
|
||||
|
||||
controls.update();
|
||||
progress.update();
|
||||
|
||||
updateProgress();
|
||||
updateSlidesVisibility();
|
||||
|
||||
notes.update();
|
||||
@@ -1709,20 +1700,6 @@ export default function( revealElement, options ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the progress bar to reflect the current slide.
|
||||
*/
|
||||
function updateProgress() {
|
||||
|
||||
// Update progress if enabled
|
||||
if( config.progress && dom.progressbar ) {
|
||||
|
||||
dom.progressbar.style.width = getProgress() * dom.wrapper.offsetWidth + 'px';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine what available routes there are for navigation.
|
||||
*
|
||||
@@ -2375,31 +2352,6 @@ export default function( revealElement, options ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicking on the progress bar results in a navigation to the
|
||||
* closest approximate horizontal slide using this equation:
|
||||
*
|
||||
* ( clickX / presentationWidth ) * numberOfSlides
|
||||
*
|
||||
* @param {object} event
|
||||
*/
|
||||
function onProgressClicked( event ) {
|
||||
|
||||
onUserInput( event );
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
let slidesTotal = getHorizontalSlides().length;
|
||||
let slideIndex = Math.floor( ( event.clientX / dom.wrapper.offsetWidth ) * slidesTotal );
|
||||
|
||||
if( config.rtl ) {
|
||||
slideIndex = slidesTotal - slideIndex;
|
||||
}
|
||||
|
||||
slide( slideIndex );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for the window level 'hashchange' event.
|
||||
*
|
||||
@@ -2668,6 +2620,7 @@ export default function( revealElement, options ) {
|
||||
getStatusText,
|
||||
|
||||
print,
|
||||
progress,
|
||||
controls,
|
||||
location,
|
||||
overview,
|
||||
@@ -2677,7 +2630,6 @@ export default function( revealElement, options ) {
|
||||
|
||||
onUserInput,
|
||||
closeOverlay,
|
||||
updateProgress,
|
||||
updateSlidesVisibility,
|
||||
layoutSlideContents,
|
||||
transformSlides,
|
||||
|
||||
Reference in new issue
Block a user