diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2014-12-10 20:09:03 +0100 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2014-12-10 20:09:03 +0100 |
commit | 8524af73f678e1a135ab83290bea19edf1f7f50e (patch) | |
tree | be7821067f8e4aaeb409ec3fa3be823bcf88f5c9 /plugin/zoom-js | |
parent | dc215a244174b88587ca032a68c172010235d154 (diff) | |
download | perl-software-in-gnu-guix-8524af73f678e1a135ab83290bea19edf1f7f50e.tar perl-software-in-gnu-guix-8524af73f678e1a135ab83290bea19edf1f7f50e.tar.gz |
zoom plugin now works for scaled presentations
Diffstat (limited to 'plugin/zoom-js')
-rw-r--r-- | plugin/zoom-js/zoom.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/plugin/zoom-js/zoom.js b/plugin/zoom-js/zoom.js index a672af4..da2c10a 100644 --- a/plugin/zoom-js/zoom.js +++ b/plugin/zoom-js/zoom.js @@ -5,9 +5,21 @@ document.querySelector( '.reveal' ).addEventListener( 'mousedown', function( event ) { var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : 'alt' ) + 'Key'; + var zoomPadding = 20; + var revealScale = Reveal.getScale(); + if( event[ modifier ] && isEnabled ) { event.preventDefault(); - zoom.to({ element: event.target, pan: false }); + + var bounds = event.target.getBoundingClientRect(); + + 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 + }); } } ); |