1
0
Fork 0

Modified Zoom

Block dimension calculation is not accurate, so zoom is made on mouse coordinates
Change default modifier to ctrl - alt don't work on Linux
New parameter zoomLevel: default 2
This commit is contained in:
linux-man 2017-05-21 19:13:41 +01:00
parent e3a3d3aa0a
commit 9c3a65744c
1 changed files with 6 additions and 23 deletions

View File

@ -3,31 +3,17 @@
var isEnabled = true; var isEnabled = true;
document.querySelector( '.reveal .slides' ).addEventListener( 'mousedown', function( event ) { document.querySelector( '.reveal .slides' ).addEventListener( 'mousedown', function( event ) {
var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : 'alt' ) + 'Key'; var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : 'ctrl' ) + 'Key';//cl
var zoomLevel = ( Reveal.getConfig().zoomLevel ? Reveal.getConfig().zoomLevel : 2 );
var zoomPadding = 20;
var revealScale = Reveal.getScale();
if( event[ modifier ] && isEnabled ) { if( event[ modifier ] && isEnabled ) {
event.preventDefault(); 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({ zoom.to({
x: ( bounds.left * revealScale ) - zoomPadding, x: event.clientX - window.innerWidth / (zoomLevel * 2),//cl
y: ( bounds.top * revealScale ) - zoomPadding, y: event.clientY - window.innerHeight / (zoomLevel * 2),
width: ( bounds.width * revealScale ) + ( zoomPadding * 2 ), width: window.innerWidth / zoomLevel,
height: ( bounds.height * revealScale ) + ( zoomPadding * 2 ), height: window.innerHeight / zoomLevel,
pan: false pan: false
}); });
} }
@ -283,6 +269,3 @@ var zoom = (function(){
} }
})(); })();