@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.
@@ -24718,7 +24718,7 @@ var SCREEN_BLOCKER_OBJ = {};
24718
24718
  var IS_PROGRESS_SCREEN_OPEN = null;
24719
24719
  // var UI_ENGINE_OBJ = null;
24720
24720
 
24721
- var UI_WORKER_OBJ = { jobs: [], num: 9000, cache: {}, viewport_info: {} };
24721
+ var UI_WORKER_OBJ = { jobs: [], num: 9000, cache: {}, viewport_height_set_ids: [], pending_for_viewport_render: {} };
24722
24722
 
24723
24723
  glb.html5_events_handler = [
24724
24724
  'onabort',
@@ -27853,14 +27853,31 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
27853
27853
  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);
27854
27854
  }
27855
27855
 
27856
- if (!UI_WORKER_OBJ.viewport_info[$div.parent().attr('xu-ui-id')]) {
27857
- UI_WORKER_OBJ.viewport_info[$div.parent().attr('xu-ui-id')] = { $elm: $div.parent(), height: $div.height() };
27856
+ const parent_id = $div.parent().attr('xu-ui-id');
27857
+ if (!UI_WORKER_OBJ.viewport_height_set_ids.includes(parent_id)) {
27858
+ UI_WORKER_OBJ.viewport_height_set_ids.push(parent_id);
27859
+ func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'set_viewport_height', { $elm: $div.parent(), height: $div.height() }, null, null, paramsP.dsSessionP);
27860
+ }
27861
+
27862
+ if ($div.hasClass('viewport_height')) {
27863
+ $div.addClass('viewport_height');
27864
+ $div.css('height', 'unset');
27858
27865
  }
27859
- // if (!$div.parent().data().xuData.viewport_elm_height) {
27860
- // $div.parent().data().xuData.viewport_elm_height = $div.height();
27861
- // }
27862
27866
  }
27863
27867
 
27868
+ return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
27869
+ },
27870
+ set_viewport_height: async function () {
27871
+ const { $elm, height } = queue_obj?.paramsP || {};
27872
+
27873
+ $elm.children().css('height', height);
27874
+
27875
+ $.each($elm.children(), function (key, elm) {
27876
+ if (!$(elm).height() && !$(elm).children()) {
27877
+ $(elm).css('height', height).addClass('viewport_height');
27878
+ }
27879
+ });
27880
+
27864
27881
  return func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
27865
27882
  },
27866
27883
  };
@@ -31171,20 +31188,12 @@ func.UI.screen.init = async function (SESSION_ID, prog_id, sourceScreenP, callin
31171
31188
  fix_svg();
31172
31189
  }, 200);
31173
31190
 
31174
- // if ($div.parent().data().xuData.viewport_elm_height) {
31175
- // $div.css(height, $div.parent().data().xuData.viewport_elm_height);
31176
- // }
31191
+ func.UI.utils.indicator.screen.normal();
31177
31192
 
31178
- for (const [parent_elm_xu_ui_id, val] of Object.entries(UI_WORKER_OBJ.viewport_info)) {
31179
- val.$elm.children().css(innerHeight, val.height);
31193
+ for (const [container_xu_ui_id, data] of Object.entries(UI_WORKER_OBJ.pending_for_viewport_render)) {
31194
+ debugger;
31180
31195
  }
31181
31196
 
31182
- // for (const item of UI_WORKER_OBJ.viewport_info) {
31183
- // item.children().css(innerHeight, item.height);
31184
- // }
31185
-
31186
- func.UI.utils.indicator.screen.normal();
31187
-
31188
31197
  let ret_screen_loading = await func.UI.screen.screen_loading_done(SESSION_ID, params, ret_render_$container, jobNoP);
31189
31198
  return ret_screen_loading;
31190
31199
  }
@@ -34424,83 +34433,95 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
34424
34433
  if (ret.abort || nodeP.tagName === 'svg') return await done();
34425
34434
  // check if iterator made to prevent children render
34426
34435
 
34427
- const observer_inViewport = new IntersectionObserver(
34428
- function (entries) {
34429
- entries.forEach((entry) => {
34430
- if (entry.isIntersecting) {
34431
- // Element is in viewport - trigger custom event
34432
- // console.log('trigger>>', 'inViewport_' + $(entry.target).attr('xu-ui-id'));
34436
+ if (nodeP?.attributes?.['xu-viewport'] == 'true') {
34437
+ const xu_viewport = async function () {
34438
+ const data = { $div, nodeP, parent_infoP, $root_container, paramsP, jobNoP, is_skeleton, keyP, refreshed_ds, parent_nodeP, check_existP, $container };
34439
+ const container_id = $container.attr('xu-ui-id');
34440
+ if (!UI_WORKER_OBJ.pending_for_viewport_render) {
34441
+ UI_WORKER_OBJ.pending_for_viewport_render[container_id] = [];
34442
+ await iterate_child($div, nodeP, parent_infoP, $root_container);
34443
+ }
34444
+ UI_WORKER_OBJ.pending_for_viewport_render[container_id].push(data);
34445
+
34446
+ // if (!$div.children().length) {
34447
+ // // render the first element to determine height
34448
+ // await iterate_child($div, nodeP, parent_infoP, $root_container);
34449
+ // // hover_in($div);
34450
+ // // func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'render_viewport', data, null, null, paramsP.dsSessionP);
34451
+ // } else {
34452
+ // }
34453
+ };
34454
+ const xu_viewport_old = function () {
34455
+ const observer_inViewport = new IntersectionObserver(
34456
+ function (entries) {
34457
+ entries.forEach((entry) => {
34458
+ if (entry.isIntersecting) {
34459
+ // Element is in viewport - trigger custom event
34460
+ // console.log('trigger>>', 'inViewport_' + $(entry.target).attr('xu-ui-id'));
34461
+
34462
+ // $(entry.target).trigger('inViewport_' + $(entry.target).attr('xu-ui-id'));
34463
+ $(entry.target).trigger('inViewport');
34464
+
34465
+ // Optional: stop observing once triggered
34466
+ observer_inViewport.unobserve(entry.target);
34467
+ }
34468
+ });
34469
+ },
34470
+ {
34471
+ threshold: 0.1, // Trigger when 10% of element is visible
34472
+ },
34473
+ );
34433
34474
 
34434
- // $(entry.target).trigger('inViewport_' + $(entry.target).attr('xu-ui-id'));
34435
- $(entry.target).trigger('inViewport');
34475
+ const observer_outViewport = new IntersectionObserver(
34476
+ function (entries) {
34477
+ entries.forEach((entry) => {
34478
+ if (!entry.isIntersecting) {
34479
+ // Element is OUT of viewport - trigger custom event
34480
+ $(entry.target).trigger('outViewport');
34436
34481
 
34437
- // Optional: stop observing once triggered
34438
- observer_inViewport.unobserve(entry.target);
34439
- }
34440
- });
34441
- },
34442
- {
34443
- threshold: 0.1, // Trigger when 10% of element is visible
34444
- },
34445
- );
34482
+ // Optional: stop observing once triggered
34483
+ // observer_outViewport.unobserve(entry.target);
34484
+ }
34485
+ });
34486
+ },
34487
+ {
34488
+ threshold: 0, // Trigger when element is completely out of view
34489
+ },
34490
+ );
34446
34491
 
34447
- const observer_outViewport = new IntersectionObserver(
34448
- function (entries) {
34449
- entries.forEach((entry) => {
34450
- if (!entry.isIntersecting) {
34451
- // Element is OUT of viewport - trigger custom event
34452
- $(entry.target).trigger('outViewport');
34492
+ // if ($div.parent().data().xuData.viewport_elm_height) {
34493
+ // $div.css(height, $div.parent().data().xuData.viewport_elm_height);
34494
+ // }
34453
34495
 
34454
- // Optional: stop observing once triggered
34455
- // observer_outViewport.unobserve(entry.target);
34496
+ $div.on('inViewport', function () {
34497
+ if ($div.children().length) {
34498
+ $div.removeClass('skeleton');
34499
+ return;
34456
34500
  }
34457
- });
34458
- },
34459
- {
34460
- threshold: 0, // Trigger when element is completely out of view
34461
- },
34462
- );
34463
-
34464
- if (nodeP?.attributes?.['xu-viewport'] == 'true') {
34465
- // if ($div.parent().data().xuData.viewport_elm_height) {
34466
- // $div.css(height, $div.parent().data().xuData.viewport_elm_height);
34467
- // }
34468
34501
 
34469
- $div.on('inViewport', function () {
34470
- if ($div.children().length) {
34471
- $div.removeClass('skeleton');
34472
- return;
34473
- }
34474
-
34475
- if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
34476
- $div.removeClass('skeleton');
34477
- $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
34478
- } else {
34479
- hover_in($div);
34480
- 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);
34481
- // //viewport_elm_height
34482
- // if (!$div.parent().data().xuData.viewport_elm_height) {
34483
- // setTimeout(() => {
34484
- // $div.parent().data().xuData.viewport_elm_height = $div.height();
34485
- // }, 2000);
34486
- // }
34487
- }
34488
- observer_outViewport.observe($div[0]);
34489
- });
34502
+ if (UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]) {
34503
+ $div.removeClass('skeleton');
34504
+ $div.html(UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')]);
34505
+ } else {
34506
+ hover_in($div);
34507
+ 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);
34508
+ }
34509
+ observer_outViewport.observe($div[0]);
34510
+ });
34490
34511
 
34491
- $div.on('outViewport', function () {
34492
- if ($div.children().length) {
34493
- UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
34494
- $div.empty();
34495
- }
34496
- // $div.addClass('skeleton');
34512
+ $div.on('outViewport', function () {
34513
+ if ($div.children().length) {
34514
+ UI_WORKER_OBJ.cache[$div.attr('xu-ui-id')] = $div.children().clone(true);
34515
+ $div.empty();
34516
+ }
34517
+ // $div.addClass('skeleton');
34518
+ observer_inViewport.observe($div[0]);
34519
+ });
34520
+ $div.addClass('skeleton');
34497
34521
  observer_inViewport.observe($div[0]);
34498
- });
34499
- $div.addClass('skeleton');
34500
- observer_inViewport.observe($div[0]);
34501
- // observer_outViewport.observe($div[0]);
34522
+ };
34523
+ await xu_viewport();
34502
34524
  } else {
34503
- // await render_child();
34504
34525
  await iterate_child($div, nodeP, parent_infoP, $root_container);
34505
34526
  }
34506
34527