aboutsummaryrefslogtreecommitdiff
path: root/plugin/zoom-js/zoom.js
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/zoom-js/zoom.js')
-rw-r--r--plugin/zoom-js/zoom.js48
1 files changed, 16 insertions, 32 deletions
diff --git a/plugin/zoom-js/zoom.js b/plugin/zoom-js/zoom.js
index 8738083..8531790 100644
--- a/plugin/zoom-js/zoom.js
+++ b/plugin/zoom-js/zoom.js
@@ -1,40 +1,27 @@
// Custom reveal.js integration
(function(){
- var isEnabled = true;
+ var revealElement = document.querySelector( '.reveal' );
+ if( revealElement ) {
- document.querySelector( '.reveal .slides' ).addEventListener( 'mousedown', function( event ) {
- var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : 'alt' ) + 'Key';
+ revealElement.addEventListener( 'mousedown', function( event ) {
+ var defaultModifier = /Linux/.test( window.navigator.platform ) ? 'ctrl' : 'alt';
- var zoomPadding = 20;
- var revealScale = Reveal.getScale();
+ var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : defaultModifier ) + 'Key';
+ var zoomLevel = ( Reveal.getConfig().zoomLevel ? Reveal.getConfig().zoomLevel : 2 );
- if( event[ modifier ] && isEnabled ) {
- event.preventDefault();
+ if( event[ modifier ] && !Reveal.isOverview() ) {
+ event.preventDefault();
- var bounds;
- var originalDisplay = event.target.style.display;
-
- // Get the bounding rect of the contents, not the containing box
- if( window.getComputedStyle( event.target ).display === 'block' ) {
- event.target.style.display = 'inline-block';
- bounds = event.target.getBoundingClientRect();
- event.target.style.display = originalDisplay;
- } else {
- bounds = event.target.getBoundingClientRect();
+ zoom.to({
+ x: event.clientX,
+ y: event.clientY,
+ scale: zoomLevel,
+ pan: false
+ });
}
+ } );
- zoom.to({
- x: ( bounds.left * revealScale ) - zoomPadding,
- y: ( bounds.top * revealScale ) - zoomPadding,
- width: ( bounds.width * revealScale ) + ( zoomPadding * 2 ),
- height: ( bounds.height * revealScale ) + ( zoomPadding * 2 ),
- pan: false
- });
- }
- } );
-
- Reveal.addEventListener( 'overviewshown', function() { isEnabled = false; } );
- Reveal.addEventListener( 'overviewhidden', function() { isEnabled = true; } );
+ }
})();
/*!
@@ -283,6 +270,3 @@ var zoom = (function(){
}
})();
-
-
-