@xuda.io/runtime-bundle 1.0.858 → 1.0.860

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2759,7 +2759,7 @@ var SCREEN_BLOCKER_OBJ = {};
2759
2759
  var IS_PROGRESS_SCREEN_OPEN = null;
2760
2760
  // var UI_ENGINE_OBJ = null;
2761
2761
 
2762
- var UI_WORKER_OBJ = { jobs: [], num: 9000, cache: {}, viewport_info: {} };
2762
+ var UI_WORKER_OBJ = { jobs: [], num: 9000, cache: {}, viewport_height_set_ids: [], pending_for_viewport_render: {} };
2763
2763
 
2764
2764
  glb.html5_events_handler = [
2765
2765
  'onabort',
@@ -8764,13 +8764,16 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
8764
8764
  const ret = await func.UI.screen.render_ui_tree(SESSION_ID, $div, nodeP.children[key], parent_infoP, paramsP, jobNoP, is_skeleton, Number(key), null, nodeP, null, $root_container);
8765
8765
  }
8766
8766
 
8767
- if (!UI_WORKER_OBJ.viewport_info[$div.parent().attr('xu-ui-id')]) {
8768
- UI_WORKER_OBJ.viewport_info[$div.parent().attr('xu-ui-id')] = { $elm: $div.parent(), height: $div.height() };
8767
+ const parent_id = $div.parent().attr('xu-ui-id');
8768
+ if (!UI_WORKER_OBJ.viewport_height_set_ids.includes(parent_id)) {
8769
+ UI_WORKER_OBJ.viewport_height_set_ids.push(parent_id);
8769
8770
  func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'set_viewport_height', { $elm: $div.parent(), height: $div.height() }, null, null, paramsP.dsSessionP);
8770
8771
  }
8771
- // if (!$div.parent().data().xuData.viewport_elm_height) {
8772
- // $div.parent().data().xuData.viewport_elm_height = $div.height();
8773
- // }
8772
+
8773
+ if ($div.hasClass('viewport_height')) {
8774
+ $div.addClass('viewport_height');
8775
+ $div.css('height', 'unset');
8776
+ }
8774
8777
  }
8775
8778
 
8776
8779
  return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
@@ -8778,9 +8781,13 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
8778
8781
  set_viewport_height: async function () {
8779
8782
  const { $elm, height } = queue_obj?.paramsP || {};
8780
8783
 
8781
- // for (const [parent_elm_xu_ui_id, val] of Object.entries(UI_WORKER_OBJ.viewport_info)) {
8782
- $elm.children().css(height, height);
8783
- // }
8784
+ $elm.children().css('height', height);
8785
+
8786
+ $.each($elm.children(), function (key, elm) {
8787
+ if (!$(elm).height() && !$(elm).children()) {
8788
+ $(elm).css('height', height).addClass('viewport_height');
8789
+ }
8790
+ });
8784
8791
 
8785
8792
  return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
8786
8793
  },
@@ -9222,20 +9229,12 @@ func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callin
9222
9229
  fix_svg();
9223
9230
  }, 200);
9224
9231
 
9225
- // if ($div.parent().data().xuData.viewport_elm_height) {
9226
- // $div.css(height, $div.parent().data().xuData.viewport_elm_height);
9227
- // }
9228
-
9229
- // for (const [parent_elm_xu_ui_id, val] of Object.entries(UI_WORKER_OBJ.viewport_info)) {
9230
- // val.$elm.children().css(height, val.height);
9231
- // }
9232
-
9233
- // for (const item of UI_WORKER_OBJ.viewport_info) {
9234
- // item.children().css(innerHeight, item.height);
9235
- // }
9236
-
9237
9232
  func.UI.utils.indicator.screen.normal();
9238
9233
 
9234
+ for (const [container_xu_ui_id, data] of Object.entries(UI_WORKER_OBJ.pending_for_viewport_render)) {
9235
+ debugger;
9236
+ }
9237
+
9239
9238
  let ret_screen_loading = await func.UI.screen.screen_loading_done(SESSION_ID, params, ret_render_$container, jobNoP);
9240
9239
  return ret_screen_loading;
9241
9240
  }
@@ -12475,83 +12474,95 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
12475
12474
  if (ret.abort || nodeP.tagName === 'svg') return await done();
12476
12475
  // check if iterator made to prevent children render
12477
12476
 
12478
- const observer_inViewport = new IntersectionObserver(
12479
- function (entries) {
12480
- entries.forEach((entry) => {
12481
- if (entry.isIntersecting) {
12482
- // Element is in viewport - trigger custom event
12483
- // console.log('trigger>>', 'inViewport_' + $(entry.target).attr('xu-ui-id'));
12477
+ if (nodeP?.attributes?.['xu-viewport'] == 'true') {
12478
+ const xu_viewport = async function () {
12479
+ const data = { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
12480
+ const container_id = $container.attr('xu-ui-id');
12481
+ if (!UI_WORKER_OBJ.pending_for_viewport_render[container_id]) {
12482
+ UI_WORKER_OBJ.pending_for_viewport_render[container_id] = [];
12483
+ await iterate_child($div, nodeP, parent_infoP, $root_container);
12484
+ }
12485
+ UI_WORKER_OBJ.pending_for_viewport_render[container_id].push(data);
12486
+
12487
+ // if (!$div.children().length) {
12488
+ // // render the first element to determine height
12489
+ // await iterate_child($div, nodeP, parent_infoP, $root_container);
12490
+ // // hover_in($div);
12491
+ // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
12492
+ // } else {
12493
+ // }
12494
+ };
12495
+ const xu_viewport_old = function () {
12496
+ const observer_inViewport = new IntersectionObserver(
12497
+ function (entries) {
12498
+ entries.forEach((entry) => {
12499
+ if (entry.isIntersecting) {
12500
+ // Element is in viewport - trigger custom event
12501
+ // console.log('trigger>>', 'inViewport_' + $(entry.target).attr('xu-ui-id'));
12502
+
12503
+ // $(entry.target).trigger('inViewport_' + $(entry.target).attr('xu-ui-id'));
12504
+ $(entry.target).trigger('inViewport');
12505
+
12506
+ // Optional: stop observing once triggered
12507
+ observer_inViewport.unobserve(entry.target);
12508
+ }
12509
+ });
12510
+ },
12511
+ {
12512
+ threshold: 0.1, // Trigger when 10% of element is visible
12513
+ },
12514
+ );
12484
12515
 
12485
- // $(entry.target).trigger('inViewport_' + $(entry.target).attr('xu-ui-id'));
12486
- $(entry.target).trigger('inViewport');
12516
+ const observer_outViewport = new IntersectionObserver(
12517
+ function (entries) {
12518
+ entries.forEach((entry) => {
12519
+ if (!entry.isIntersecting) {
12520
+ // Element is OUT of viewport - trigger custom event
12521
+ $(entry.target).trigger('outViewport');
12487
12522
 
12488
- // Optional: stop observing once triggered
12489
- observer_inViewport.unobserve(entry.target);
12490
- }
12491
- });
12492
- },
12493
- {
12494
- threshold: 0.1, // Trigger when 10% of element is visible
12495
- },
12496
- );
12523
+ // Optional: stop observing once triggered
12524
+ // observer_outViewport.unobserve(entry.target);
12525
+ }
12526
+ });
12527
+ },
12528
+ {
12529
+ threshold: 0, // Trigger when element is completely out of view
12530
+ },
12531
+ );
12497
12532
 
12498
- const observer_outViewport = new IntersectionObserver(
12499
- function (entries) {
12500
- entries.forEach((entry) => {
12501
- if (!entry.isIntersecting) {
12502
- // Element is OUT of viewport - trigger custom event
12503
- $(entry.target).trigger('outViewport');
12533
+ // if ($div.parent().data().xuData.viewport_elm_height) {
12534
+ // $div.css(height, $div.parent().data().xuData.viewport_elm_height);
12535
+ // }
12504
12536
 
12505
- // Optional: stop observing once triggered
12506
- // observer_outViewport.unobserve(entry.target);
12537
+ $div.on('inViewport', function () {
12538
+ if ($div.children().length) {
12539
+ $div.removeClass('skeleton');
12540
+ return;
12507
12541
  }
12508
- });
12509
- },
12510
- {
12511
- threshold: 0, // Trigger when element is completely out of view
12512
- },
12513
- );
12514
-
12515
- if (nodeP?.attributes?.['xu-viewport'] == 'true') {
12516
- // if ($div.parent().data().xuData.viewport_elm_height) {
12517
- // $div.css(height, $div.parent().data().xuData.viewport_elm_height);
12518
- // }
12519
12542
 
12520
- $div.on('inViewport', function () {
12521
- if ($div.children().length) {
12522
- $div.removeClass('skeleton');
12523
- return;
12524
- }
12525
-
12526
- if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
12527
- $div.removeClass('skeleton');
12528
- $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
12529
- } else {
12530
- hover_in($div);
12531
- func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container }, null, null, paramsP.dsSessionP);
12532
- // //viewport_elm_height
12533
- // if (!$div.parent().data().xuData.viewport_elm_height) {
12534
- // setTimeout(() => {
12535
- // $div.parent().data().xuData.viewport_elm_height = $div.height();
12536
- // }, 2000);
12537
- // }
12538
- }
12539
- observer_outViewport.observe($div[0]);
12540
- });
12543
+ if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
12544
+ $div.removeClass('skeleton');
12545
+ $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
12546
+ } else {
12547
+ hover_in($div);
12548
+ func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container }, null, null, paramsP.dsSessionP);
12549
+ }
12550
+ observer_outViewport.observe($div[0]);
12551
+ });
12541
12552
 
12542
- $div.on('outViewport', function () {
12543
- if ($div.children().length) {
12544
- UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
12545
- $div.empty();
12546
- }
12547
- // $div.addClass('skeleton');
12553
+ $div.on('outViewport', function () {
12554
+ if ($div.children().length) {
12555
+ UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
12556
+ $div.empty();
12557
+ }
12558
+ // $div.addClass('skeleton');
12559
+ observer_inViewport.observe($div[0]);
12560
+ });
12561
+ $div.addClass('skeleton');
12548
12562
  observer_inViewport.observe($div[0]);
12549
- });
12550
- $div.addClass('skeleton');
12551
- observer_inViewport.observe($div[0]);
12552
- // observer_outViewport.observe($div[0]);
12563
+ };
12564
+ await xu_viewport();
12553
12565
  } else {
12554
- // await render_child();
12555
12566
  await iterate_child($div, nodeP, parent_infoP, $root_container);
12556
12567
  }
12557
12568