Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

* When spinners and the pulse busy indicators are enabled, Shiny now shows the pulse indicator when dynamic UI elements are recalculating if no other spinners are present in the app. (#4137)

* Capture and send client window size and scroll dimensions to the server which can be accessed via `session$clientData`. (#4147)

## Bug fixes

* Fixed a bug in `conditionalPanel()` that would cause the panel to repeatedly show/hide itself when the provided condition was not boolean. (@kamilzyla, #4127)
Expand Down
19 changes: 15 additions & 4 deletions inst/www/shared/shiny.js
Original file line number Diff line number Diff line change
Expand Up @@ -25132,11 +25132,17 @@
value: function() {
var _initialize = _asyncToGenerator14(/* @__PURE__ */ _regeneratorRuntime14().mark(function _callee3() {
var _this2 = this;
var shinyapp, inputBatchSender, inputsNoResend, inputsEvent, inputsRate, inputsDefer, target, inputs, inputBindings, outputBindings, shinyBindCtx, initializeInputs, getIdFromEl, initialValues, getComputedBgColor, getComputedFont, maybeAddThemeObserver, doSendTheme, doSendImageSize, isHidden, lastKnownVisibleOutputs, doSendOutputHiddenState, sendOutputHiddenStateDebouncer, sendOutputHiddenState, filterEventsByNamespace, bs3classes, singletonText, dependencyText;
var shinyapp, inputBatchSender, inputsNoResend, inputsEvent, inputsRate, inputsDefer, target, inputs, inputBindings, outputBindings, shinyBindCtx, initializeInputs, getIdFromEl, initialValues, getComputedBgColor, getComputedFont, maybeAddThemeObserver, doSendTheme, doSendImageSize, isHidden, lastKnownVisibleOutputs, doSendOutputHiddenState, sendOutputHiddenStateDebouncer, sendOutputHiddenState, filterEventsByNamespace, bs3classes, doSendWindowSize, singletonText, dependencyText;
return _regeneratorRuntime14().wrap(function _callee3$(_context3) {
while (1)
switch (_context3.prev = _context3.next) {
case 0:
doSendWindowSize = function _doSendWindowSize() {
inputs.setInput(".clientdata_window_width", window.innerWidth);
inputs.setInput(".clientdata_window_height", window.innerHeight);
inputs.setInput(".clientdata_scroll_width", document.documentElement.scrollWidth);
inputs.setInput(".clientdata_scroll_height", document.documentElement.scrollHeight);
};
filterEventsByNamespace = function _filterEventsByNamesp(namespace, handler) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
Expand Down Expand Up @@ -25364,9 +25370,9 @@
this.initializeInputs = initializeInputs;
initializeInputs(document.documentElement);
_context3.t0 = mapValues;
_context3.next = 34;
_context3.next = 35;
return _bindAll(shinyBindCtx(), document.documentElement);
case 34:
case 35:
_context3.t1 = _context3.sent;
_context3.t2 = function(x2) {
return x2.value;
Expand Down Expand Up @@ -25438,6 +25444,11 @@
return;
e4;
});
initialValues[".clientdata_window_width"] = window.innerWidth;
initialValues[".clientdata_window_height"] = window.innerHeight;
initialValues[".clientdata_scroll_width"] = document.documentElement.scrollWidth;
initialValues[".clientdata_scroll_height"] = document.documentElement.scrollHeight;
(0, import_jquery39.default)(window).resize(debounce(500, doSendWindowSize));
singletonText = initialValues[".clientdata_singletons"] = (0, import_jquery39.default)('script[type="application/shiny-singletons"]').text();
registerNames(singletonText.split(/,/));
dependencyText = (0, import_jquery39.default)('script[type="application/html-dependencies"]').text();
Expand All @@ -25455,7 +25466,7 @@
(0, import_jquery39.default)(document).one("shiny:sessioninitialized", function() {
_this2.initializedPromise.resolve();
});
case 69:
case 75:
case "end":
return _context3.stop();
}
Expand Down
4 changes: 2 additions & 2 deletions inst/www/shared/shiny.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/www/shared/shiny.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions inst/www/shared/shiny.min.js.map

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions srcts/src/shiny/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,27 @@ class ShinyClass {
e;
});

initialValues[".clientdata_window_width"] = window.innerWidth;
initialValues[".clientdata_window_height"] = window.innerHeight;
initialValues[".clientdata_scroll_width"] =
document.documentElement.scrollWidth;
initialValues[".clientdata_scroll_height"] =
document.documentElement.scrollHeight;

function doSendWindowSize() {
inputs.setInput(".clientdata_window_width", window.innerWidth);
inputs.setInput(".clientdata_window_height", window.innerHeight);
inputs.setInput(
".clientdata_scroll_width",
document.documentElement.scrollWidth
);
inputs.setInput(
".clientdata_scroll_height",
document.documentElement.scrollHeight
);
}

$(window).resize(debounce(500, doSendWindowSize));
// The server needs to know what singletons were rendered as part of
// the page loading
const singletonText = (initialValues[".clientdata_singletons"] = $(
Expand Down