Skip to content

Commit

Permalink
Completely ignore size given by htmlwidgets
Browse files Browse the repository at this point in the history
  • Loading branch information
pfh committed Nov 1, 2023
1 parent 0d2d0a1 commit a52e427
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions inst/htmlwidgets/langevitour.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
};
Expand Down

0 comments on commit a52e427

Please sign in to comment.