Skip to content

Commit

Permalink
highlight, math, notes and zoom plugins now register via Reveal.regis…
Browse files Browse the repository at this point in the history
…terPlugin
  • Loading branch information
hakimel committed Mar 4, 2019
1 parent d780352 commit c40e981
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 61 deletions.
2 changes: 1 addition & 1 deletion demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ <h1>THE END</h1>
dependencies: [
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/highlight/highlight.js', async: true },
{ src: 'plugin/search/search.js', async: true },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true }
Expand Down
51 changes: 31 additions & 20 deletions plugin/highlight/highlight.js

Large diffs are not rendered by default.

55 changes: 33 additions & 22 deletions plugin/math/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,6 @@ var RevealMath = window.RevealMath || (function(){
skipStartupTypeset: true
};

defaults( options, defaultOptions );
defaults( options.tex2jax, defaultOptions.tex2jax );
options.mathjax = options.config = null;

loadScript( url, function() {

MathJax.Hub.Config( options );

// Typeset followed by an immediate reveal.js layout since
// the typesetting process could affect slide height
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub ] );
MathJax.Hub.Queue( Reveal.layout );

// Reprocess equations in slides when they turn visible
Reveal.addEventListener( 'slidechanged', function( event ) {

MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, event.currentSlide ] );

} );

} );

function defaults( options, defaultOptions ) {

for ( var i in defaultOptions ) {
Expand Down Expand Up @@ -81,4 +59,37 @@ var RevealMath = window.RevealMath || (function(){

}

return {
init: function() {

defaults( options, defaultOptions );
defaults( options.tex2jax, defaultOptions.tex2jax );
options.mathjax = options.config = null;

loadScript( url, function() {

MathJax.Hub.Config( options );

// Typeset followed by an immediate reveal.js layout since
// the typesetting process could affect slide height
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub ] );
MathJax.Hub.Queue( Reveal.layout );

// Reprocess equations in slides when they turn visible
Reveal.addEventListener( 'slidechanged', function( event ) {

MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, event.currentSlide ] );

} );

} );

// lofi xbrowser Promise.resolve()
return { then: function( resolve ) { resolve(); }};

}
}

})();

Reveal.registerPlugin( 'math', RevealMath );
3 changes: 2 additions & 1 deletion plugin/notes/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ var RevealNotes = (function() {

}

return Promise.resolve();
// lofi xbrowser Promise.resolve()
return { then: function( resolve ) { resolve(); }};

},

Expand Down
42 changes: 25 additions & 17 deletions plugin/zoom-js/zoom.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit c40e981

Please sign in to comment.