Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clientdata): Add viewport and scrollable size values to clientdata #4147

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
20 changes: 16 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 @@ -25412,6 +25418,9 @@
});
(0, import_jquery39.default)(document.body).on("shown.sendImageSize", "*", sendImageSizeFns.regular);
(0, import_jquery39.default)(document.body).on("shown.sendOutputHiddenState hidden.sendOutputHiddenState", "*", sendOutputHiddenState);
sendImageSizeFns.setImageSend(inputBatchSender, doSendWindowSize);
sendImageSizeFns.regular();
window.addEventListener("resize", sendImageSizeFns.transitioned);
initialValues[".clientdata_pixelratio"] = pixelRatio();
(0, import_jquery39.default)(window).resize(function() {
inputs.setInput(".clientdata_pixelratio", pixelRatio());
Expand All @@ -25420,6 +25429,9 @@
initialValues[".clientdata_url_hostname"] = window.location.hostname;
initialValues[".clientdata_url_port"] = window.location.port;
initialValues[".clientdata_url_pathname"] = window.location.pathname;
initialValues[".clientdata_user_agent"] = navigator.userAgent;
initialValues[".clientdata_is_mobile"] = /Mobi|Android/i.test(navigator.userAgent);
initialValues[".clientdata_is_desktop"] = !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
initialValues[".clientdata_url_search"] = window.location.search;
(0, import_jquery39.default)(window).on("pushstate", function(e4) {
inputs.setInput(".clientdata_url_search", window.location.search);
Expand Down Expand Up @@ -25455,7 +25467,7 @@
(0, import_jquery39.default)(document).one("shiny:sessioninitialized", function() {
_this2.initializedPromise.resolve();
});
case 69:
case 76:
case "end":
return _context3.stop();
}
Expand Down
Loading