From 89e74d33144ddf83d5eef3de52ac81222ddfbd97 Mon Sep 17 00:00:00 2001 From: tim-salabim Date: Sat, 1 May 2021 13:48:28 +0200 Subject: [PATCH] if minWidth not provided via ... append to dotlist to ensure proper popup container width. #15 --- R/addPopupImages.R | 16 ++++++++++++++-- inst/htmlwidgets/popup.js | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/R/addPopupImages.R b/R/addPopupImages.R index c869fbe..9ff87c6 100644 --- a/R/addPopupImages.R +++ b/R/addPopupImages.R @@ -115,7 +115,14 @@ addPopupImages = function(map, height = height } - return(list(nm = nm, width = width, height = height, src = src)) + return( + list( + nm = nm + , width = width + , height = height + , src = src + ) + ) }) @@ -160,7 +167,12 @@ addPopupImages = function(map, } map$dependencies = map$dependencies[!duplicated(map$dependencies)] - dotlist = utils::modifyList(list("maxWidth" = 2000), list(...)) + dotlist = utils::modifyList( + list( + "maxWidth" = 2000 + ) + , list(...) + ) leaflet::invokeMethod( map, diff --git a/inst/htmlwidgets/popup.js b/inst/htmlwidgets/popup.js index 6ab3f4c..47b8b63 100644 --- a/inst/htmlwidgets/popup.js +++ b/inst/htmlwidgets/popup.js @@ -40,6 +40,9 @@ LeafletWidget.methods.imagePopup = function(image, group, width, height, src, na lay.eachLayer(function (layer) { wdth = width[imgid]; hght = height[imgid]; + if (dotlist.minWidth === undefined) { + dotlist.minWidth = wdth; + } if (imgid <= image.length) { popimg = ""; poporig = layer.getPopup();