From a52e42703c4ccc15c0d6ad4dcd864bddf28d850a Mon Sep 17 00:00:00 2001 From: Paul Harrison Date: Thu, 2 Nov 2023 08:48:17 +1100 Subject: [PATCH] Completely ignore size given by htmlwidgets --- inst/htmlwidgets/langevitour.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/inst/htmlwidgets/langevitour.js b/inst/htmlwidgets/langevitour.js index 3c2d584..3c426d0 100644 --- a/inst/htmlwidgets/langevitour.js +++ b/inst/htmlwidgets/langevitour.js @@ -4,16 +4,16 @@ HTMLWidgets.widget({ factory: function(el, width, height) { // Supplied width and height are based on getBoundingClientRect. // Wrong eg when using revealjs and slide is scaled. - // Ignore if we seem to be scaled. - let trustSize = () => { - let rect = el.getBoundingClientRect(); - return rect.width == el.offsetWidth && rect.height == el.offsetHeight; - }; + //let trustSize = () => { + // let rect = el.getBoundingClientRect(); + // return rect.width == el.offsetWidth && rect.height == el.offsetHeight; + //}; - if (!trustSize()) { - width = el.offsetWidth; - height = el.offsetHeight; - } + // May as will just never trust the width and height we are given. + //if (!trustSize()) { + width = el.offsetWidth; + height = el.offsetHeight; + //} let tour = new langevitour.Langevitour(el, width, height); @@ -139,9 +139,15 @@ HTMLWidgets.widget({ // Supplied width and height are based on getBoundingClientRect. // Wrong eg when using revealjs and slide is scaled. // Spurious events also happen if we are full screen. - if (!trustSize() || tour.fullscreen || document.fullscreenElement) + if (tour.fullscreen || document.fullscreenElement) return; + // May as will just never trust the width and height we are given. + //if (!trustSize()) { + width = el.offsetWidth; + height = el.offsetHeight; + //} + tour.resize(width, height); } };