diff options
author | Hakim El Hattab | 2019-03-04 14:32:38 +0100 |
---|---|---|
committer | Hakim El Hattab | 2019-03-04 14:32:38 +0100 |
commit | c40e9819a24922dd1f16ea7b0bb809127978a21b (patch) | |
tree | f5c8802b12d7829e7f62d3a5ac4642b93490a3a2 /plugin/zoom-js | |
parent | d780352b7f78e16635ce9fabf2dbb53639610f18 (diff) |
highlight, math, notes and zoom plugins now register via Reveal.registerPlugin
Diffstat (limited to 'plugin/zoom-js')
-rw-r--r-- | plugin/zoom-js/zoom.js | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/plugin/zoom-js/zoom.js b/plugin/zoom-js/zoom.js index 8531790..1a731d3 100644 --- a/plugin/zoom-js/zoom.js +++ b/plugin/zoom-js/zoom.js @@ -1,29 +1,37 @@ // Custom reveal.js integration -(function(){ - var revealElement = document.querySelector( '.reveal' ); - if( revealElement ) { +var RevealZoom = (function(){ - revealElement.addEventListener( 'mousedown', function( event ) { - var defaultModifier = /Linux/.test( window.navigator.platform ) ? 'ctrl' : 'alt'; + return { + init: function() { - var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : defaultModifier ) + 'Key'; - var zoomLevel = ( Reveal.getConfig().zoomLevel ? Reveal.getConfig().zoomLevel : 2 ); + Reveal.getRevealElement().addEventListener( 'mousedown', function( event ) { + var defaultModifier = /Linux/.test( window.navigator.platform ) ? 'ctrl' : 'alt'; - if( event[ modifier ] && !Reveal.isOverview() ) { - event.preventDefault(); + var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : defaultModifier ) + 'Key'; + var zoomLevel = ( Reveal.getConfig().zoomLevel ? Reveal.getConfig().zoomLevel : 2 ); - zoom.to({ - x: event.clientX, - y: event.clientY, - scale: zoomLevel, - pan: false - }); - } - } ); + if( event[ modifier ] && !Reveal.isOverview() ) { + event.preventDefault(); + + zoom.to({ + x: event.clientX, + y: event.clientY, + scale: zoomLevel, + pan: false + }); + } + } ); + // lofi xbrowser Promise.resolve() + return { then: function( resolve ) { resolve(); }}; + + } } + })(); +Reveal.registerPlugin( 'zoom', RevealZoom ); + /*! * zoom.js 0.3 (modified for use with reveal.js) * http://lab.hakim.se/zoom-js |