MCPcopy Create free account
hub / github.com/OpenIntroStat/ims / initSizing

Function initSizing

libs/htmlwidgets-1.5.3/htmlwidgets.js:270–315  ·  view source on GitHub ↗
(el)

Source from the content-addressed store, hash-verified

268 }
269
270 function initSizing(el) {
271 var sizing = sizingPolicy(el);
272 if (!sizing)
273 return;
274
275 var cel = document.getElementById("htmlwidget_container");
276 if (!cel)
277 return;
278
279 if (typeof(sizing.padding) !== "undefined") {
280 document.body.style.margin = "0";
281 document.body.style.padding = paddingToCss(unpackPadding(sizing.padding));
282 }
283
284 if (sizing.fill) {
285 document.body.style.overflow = "hidden";
286 document.body.style.width = "100%";
287 document.body.style.height = "100%";
288 document.documentElement.style.width = "100%";
289 document.documentElement.style.height = "100%";
290 if (cel) {
291 cel.style.position = "absolute";
292 var pad = unpackPadding(sizing.padding);
293 cel.style.top = pad.top + "px";
294 cel.style.right = pad.right + "px";
295 cel.style.bottom = pad.bottom + "px";
296 cel.style.left = pad.left + "px";
297 el.style.width = "100%";
298 el.style.height = "100%";
299 }
300
301 return {
302 getWidth: function() { return cel.offsetWidth; },
303 getHeight: function() { return cel.offsetHeight; }
304 };
305
306 } else {
307 el.style.width = px(sizing.width);
308 el.style.height = px(sizing.height);
309
310 return {
311 getWidth: function() { return el.offsetWidth; },
312 getHeight: function() { return el.offsetHeight; }
313 };
314 }
315 }
316
317 // Default implementations for methods
318 var defaults = {

Callers 1

htmlwidgets.jsFile · 0.85

Calls 4

sizingPolicyFunction · 0.85
paddingToCssFunction · 0.85
unpackPaddingFunction · 0.85
pxFunction · 0.85

Tested by

no test coverage detected