diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2016-04-29 09:24:25 +0200 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2016-04-29 09:24:25 +0200 |
commit | 2d54bc6823fd308d72b4d4dee5437c858d0c380b (patch) | |
tree | e586de2570a2549b1b5e21eb00a2ae6294a44fdb | |
parent | 9b11915c3a409aa456c64e9d386ac15598a4fa6b (diff) | |
parent | a0e6da6a9cf4372c20230e1c7e076375539bd8d5 (diff) | |
download | fosdem-2018-presentation-2d54bc6823fd308d72b4d4dee5437c858d0c380b.tar fosdem-2018-presentation-2d54bc6823fd308d72b4d4dee5437c858d0c380b.tar.gz |
Merge pull request #1572 from jesstelford/zoom-content-size
More natural zooming on block level elements
-rw-r--r-- | plugin/zoom-js/zoom.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/plugin/zoom-js/zoom.js b/plugin/zoom-js/zoom.js index 95093e0..efccad6 100644 --- a/plugin/zoom-js/zoom.js +++ b/plugin/zoom-js/zoom.js @@ -11,7 +11,17 @@ if( event[ modifier ] && isEnabled ) { event.preventDefault(); - var bounds = event.target.getBoundingClientRect(); + 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: ( bounds.left * revealScale ) - zoomPadding, |