@xuda.io/runtime-bundle 1.0.857 → 1.0.859

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,14 +8764,31 @@ 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);
8770
+ func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'set_viewport_height', { $elm: $div.parent(), height: $div.height() }, null, null, paramsP.dsSessionP);
8771
+ }
8772
+
8773
+ if ($div.hasClass('viewport_height')) {
8774
+ $div.addClass('viewport_height');
8775
+ $div.css('height', 'unset');
8769
8776
  }
8770
- // if (!$div.parent().data().xuData.viewport_elm_height) {
8771
- // $div.parent().data().xuData.viewport_elm_height = $div.height();
8772
- // }
8773
8777
  }
8774
8778
 
8779
+ return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
8780
+ },
8781
+ set_viewport_height: async function () {
8782
+ const { $elm, height } = queue_obj?.paramsP || {};
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
+ });
8791
+
8775
8792
  return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
8776
8793
  },
8777
8794
  };
@@ -9212,20 +9229,12 @@ func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callin
9212
9229
  fix_svg();
9213
9230
  }, 200);
9214
9231
 
9215
- // if ($div.parent().data().xuData.viewport_elm_height) {
9216
- // $div.css(height, $div.parent().data().xuData.viewport_elm_height);
9217
- // }
9232
+ func.UI.utils.indicator.screen.normal();
9218
9233
 
9219
- for (const [parent_elm_xu_ui_id, val] of Object.entries(UI_WORKER_OBJ.viewport_info)) {
9220
- val.$elm.children().css(innerHeight, val.height);
9234
+ for (const [container_xu_ui_id, data] of Object.entries(UI_WORKER_OBJ.pending_for_viewport_render)) {
9235
+ debugger;
9221
9236
  }
9222
9237
 
9223
- // for (const item of UI_WORKER_OBJ.viewport_info) {
9224
- // item.children().css(innerHeight, item.height);
9225
- // }
9226
-
9227
- func.UI.utils.indicator.screen.normal();
9228
-
9229
9238
  let ret_screen_loading = await func.UI.screen.screen_loading_done(SESSION_ID, params, ret_render_$container, jobNoP);
9230
9239
  return ret_screen_loading;
9231
9240
  }
@@ -12465,83 +12474,95 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
12465
12474
  if (ret.abort || nodeP.tagName === 'svg') return await done();
12466
12475
  // check if iterator made to prevent children render
12467
12476
 
12468
- const observer_inViewport = new IntersectionObserver(
12469
- function (entries) {
12470
- entries.forEach((entry) => {
12471
- if (entry.isIntersecting) {
12472
- // Element is in viewport - trigger custom event
12473
- // 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) {
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
+ );
12474
12515
 
12475
- // $(entry.target).trigger('inViewport_' + $(entry.target).attr('xu-ui-id'));
12476
- $(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');
12477
12522
 
12478
- // Optional: stop observing once triggered
12479
- observer_inViewport.unobserve(entry.target);
12480
- }
12481
- });
12482
- },
12483
- {
12484
- threshold: 0.1, // Trigger when 10% of element is visible
12485
- },
12486
- );
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
+ );
12487
12532
 
12488
- const observer_outViewport = new IntersectionObserver(
12489
- function (entries) {
12490
- entries.forEach((entry) => {
12491
- if (!entry.isIntersecting) {
12492
- // Element is OUT of viewport - trigger custom event
12493
- $(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
+ // }
12494
12536
 
12495
- // Optional: stop observing once triggered
12496
- // observer_outViewport.unobserve(entry.target);
12537
+ $div.on('inViewport', function () {
12538
+ if ($div.children().length) {
12539
+ $div.removeClass('skeleton');
12540
+ return;
12497
12541
  }
12498
- });
12499
- },
12500
- {
12501
- threshold: 0, // Trigger when element is completely out of view
12502
- },
12503
- );
12504
-
12505
- if (nodeP?.attributes?.['xu-viewport'] == 'true') {
12506
- // if ($div.parent().data().xuData.viewport_elm_height) {
12507
- // $div.css(height, $div.parent().data().xuData.viewport_elm_height);
12508
- // }
12509
12542
 
12510
- $div.on('inViewport', function () {
12511
- if ($div.children().length) {
12512
- $div.removeClass('skeleton');
12513
- return;
12514
- }
12515
-
12516
- if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
12517
- $div.removeClass('skeleton');
12518
- $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
12519
- } else {
12520
- hover_in($div);
12521
- 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);
12522
- // //viewport_elm_height
12523
- // if (!$div.parent().data().xuData.viewport_elm_height) {
12524
- // setTimeout(() => {
12525
- // $div.parent().data().xuData.viewport_elm_height = $div.height();
12526
- // }, 2000);
12527
- // }
12528
- }
12529
- observer_outViewport.observe($div[0]);
12530
- });
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
+ });
12531
12552
 
12532
- $div.on('outViewport', function () {
12533
- if ($div.children().length) {
12534
- UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
12535
- $div.empty();
12536
- }
12537
- // $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');
12538
12562
  observer_inViewport.observe($div[0]);
12539
- });
12540
- $div.addClass('skeleton');
12541
- observer_inViewport.observe($div[0]);
12542
- // observer_outViewport.observe($div[0]);
12563
+ };
12564
+ await xu_viewport();
12543
12565
  } else {
12544
- // await render_child();
12545
12566
  await iterate_child($div, nodeP, parent_infoP, $root_container);
12546
12567
  }
12547
12568