@yuneta/gobj-ui 7.23.77 → 7.23.78

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.
package/README.md CHANGED
@@ -1250,7 +1250,12 @@ a level or two, with a count on every cut.
1250
1250
  - **The toolbar's fold pair** (the same two chevrons as the JSON graph):
1251
1251
  *expand all* opens every hook on all its children — the reader asking for
1252
1252
  the pile on purpose — and *collapse all* leaves the roots. *Refresh* is the
1253
- way back to the default depth.
1253
+ way back to the default depth. **Neither moves the zoom** (since `7.23.78`):
1254
+ a fold is not a reason to change the scale the reader chose, and until then
1255
+ both fitted the whole graph — opening everything zoomed out to a strip and
1256
+ closing it zoomed in on the roots, every time. The camera holds the anchor
1257
+ still when there is one, else the first root: the top of the tree, which is
1258
+ where a JSON viewer keeps the eye when it opens or closes everything.
1254
1259
  - **`dagre` reads LEFT TO RIGHT** now, with explicit `nodesep`/`ranksep`: the
1255
1260
  children of a node are a column beside it and the graph reads like a file
1256
1261
  tree. The ports move to the sides with it (fkeys on the left edge, hooks
@@ -60275,11 +60275,36 @@ function ac_expand_all$1(gobj, event, kw, src) {
60275
60275
  (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: expand all with no tree loaded`);
60276
60276
  return -1;
60277
60277
  }
60278
+ let keep = fold_keep_node(gobj);
60279
+ let vp = yui_graph_viewport_of(priv.graph, keep);
60278
60280
  fold_expand_all(priv._fold_model, priv._fold_state);
60279
- reconcile_fold(gobj, { fit: true });
60281
+ reconcile_fold(gobj, {
60282
+ keep,
60283
+ keep_vp: vp
60284
+ });
60280
60285
  return 0;
60281
60286
  }
60282
60287
  /************************************************************
60288
+ * The node the camera holds still across a GLOBAL fold: the
60289
+ * anchor when there is one, else the first root -- the top of
60290
+ * the tree, which is where a JSON viewer keeps the eye when it
60291
+ * opens or closes everything. The zoom does not move either way:
60292
+ * a fold is not a reason to change the scale the reader chose,
60293
+ * and until 7.23.78 both buttons fitted the whole graph, so
60294
+ * opening everything zoomed out to a strip and closing it zoomed
60295
+ * in on the roots, every time.
60296
+ ************************************************************/
60297
+ function fold_keep_node(gobj) {
60298
+ let priv = gobj.priv;
60299
+ if (priv.anchor_state === "on" && priv.anchor_id) return priv.anchor_id;
60300
+ let model = priv._fold_model;
60301
+ for (let topic_name of model.topics) {
60302
+ let roots = model.groups.get(fold_root_group_key(topic_name)) || [];
60303
+ if (roots.length) return node_id_of_key(gobj, roots[0]);
60304
+ }
60305
+ return "";
60306
+ }
60307
+ /************************************************************
60283
60308
  * The roots alone.
60284
60309
  ************************************************************/
60285
60310
  function ac_collapse_all$1(gobj, event, kw, src) {
@@ -60288,8 +60313,13 @@ function ac_collapse_all$1(gobj, event, kw, src) {
60288
60313
  (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: collapse all with no tree loaded`);
60289
60314
  return -1;
60290
60315
  }
60316
+ let keep = fold_keep_node(gobj);
60317
+ let vp = yui_graph_viewport_of(priv.graph, keep);
60291
60318
  fold_collapse_all(priv._fold_model, priv._fold_state);
60292
- reconcile_fold(gobj, { fit: true });
60319
+ reconcile_fold(gobj, {
60320
+ keep,
60321
+ keep_vp: vp
60322
+ });
60293
60323
  return 0;
60294
60324
  }
60295
60325
  /************************************************************
@@ -60270,11 +60270,36 @@ function ac_expand_all$1(gobj, event, kw, src) {
60270
60270
  log_error(`${gobj_short_name(gobj)}: expand all with no tree loaded`);
60271
60271
  return -1;
60272
60272
  }
60273
+ let keep = fold_keep_node(gobj);
60274
+ let vp = yui_graph_viewport_of(priv.graph, keep);
60273
60275
  fold_expand_all(priv._fold_model, priv._fold_state);
60274
- reconcile_fold(gobj, { fit: true });
60276
+ reconcile_fold(gobj, {
60277
+ keep,
60278
+ keep_vp: vp
60279
+ });
60275
60280
  return 0;
60276
60281
  }
60277
60282
  /************************************************************
60283
+ * The node the camera holds still across a GLOBAL fold: the
60284
+ * anchor when there is one, else the first root -- the top of
60285
+ * the tree, which is where a JSON viewer keeps the eye when it
60286
+ * opens or closes everything. The zoom does not move either way:
60287
+ * a fold is not a reason to change the scale the reader chose,
60288
+ * and until 7.23.78 both buttons fitted the whole graph, so
60289
+ * opening everything zoomed out to a strip and closing it zoomed
60290
+ * in on the roots, every time.
60291
+ ************************************************************/
60292
+ function fold_keep_node(gobj) {
60293
+ let priv = gobj.priv;
60294
+ if (priv.anchor_state === "on" && priv.anchor_id) return priv.anchor_id;
60295
+ let model = priv._fold_model;
60296
+ for (let topic_name of model.topics) {
60297
+ let roots = model.groups.get(fold_root_group_key(topic_name)) || [];
60298
+ if (roots.length) return node_id_of_key(gobj, roots[0]);
60299
+ }
60300
+ return "";
60301
+ }
60302
+ /************************************************************
60278
60303
  * The roots alone.
60279
60304
  ************************************************************/
60280
60305
  function ac_collapse_all$1(gobj, event, kw, src) {
@@ -60283,8 +60308,13 @@ function ac_collapse_all$1(gobj, event, kw, src) {
60283
60308
  log_error(`${gobj_short_name(gobj)}: collapse all with no tree loaded`);
60284
60309
  return -1;
60285
60310
  }
60311
+ let keep = fold_keep_node(gobj);
60312
+ let vp = yui_graph_viewport_of(priv.graph, keep);
60286
60313
  fold_collapse_all(priv._fold_model, priv._fold_state);
60287
- reconcile_fold(gobj, { fit: true });
60314
+ reconcile_fold(gobj, {
60315
+ keep,
60316
+ keep_vp: vp
60317
+ });
60288
60318
  return 0;
60289
60319
  }
60290
60320
  /************************************************************
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.77",
3
+ "version": "7.23.78",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -124,6 +124,7 @@ import {
124
124
  fold_pending_groups,
125
125
  fold_node_key,
126
126
  fold_split_group_key,
127
+ fold_root_group_key,
127
128
  } from "./treedb_fold_model.js";
128
129
  import {layout_tree, layout_radial} from "./treedb_layout.js";
129
130
 
@@ -9079,12 +9080,41 @@ function ac_expand_all(gobj, event, kw, src)
9079
9080
  log_error(`${gobj_short_name(gobj)}: expand all with no tree loaded`);
9080
9081
  return -1;
9081
9082
  }
9083
+ let keep = fold_keep_node(gobj);
9084
+ let vp = yui_graph_viewport_of(priv.graph, keep);
9082
9085
  fold_expand_all(priv._fold_model, priv._fold_state);
9083
- reconcile_fold(gobj, {fit: true});
9086
+ reconcile_fold(gobj, {keep: keep, keep_vp: vp});
9084
9087
 
9085
9088
  return 0;
9086
9089
  }
9087
9090
 
9091
+ /************************************************************
9092
+ * The node the camera holds still across a GLOBAL fold: the
9093
+ * anchor when there is one, else the first root -- the top of
9094
+ * the tree, which is where a JSON viewer keeps the eye when it
9095
+ * opens or closes everything. The zoom does not move either way:
9096
+ * a fold is not a reason to change the scale the reader chose,
9097
+ * and until 7.23.78 both buttons fitted the whole graph, so
9098
+ * opening everything zoomed out to a strip and closing it zoomed
9099
+ * in on the roots, every time.
9100
+ ************************************************************/
9101
+ function fold_keep_node(gobj)
9102
+ {
9103
+ let priv = gobj.priv;
9104
+
9105
+ if(priv.anchor_state === "on" && priv.anchor_id) {
9106
+ return priv.anchor_id;
9107
+ }
9108
+ let model = priv._fold_model;
9109
+ for(let topic_name of model.topics) {
9110
+ let roots = model.groups.get(fold_root_group_key(topic_name)) || [];
9111
+ if(roots.length) {
9112
+ return node_id_of_key(gobj, roots[0]);
9113
+ }
9114
+ }
9115
+ return "";
9116
+ }
9117
+
9088
9118
  /************************************************************
9089
9119
  * The roots alone.
9090
9120
  ************************************************************/
@@ -9096,8 +9126,10 @@ function ac_collapse_all(gobj, event, kw, src)
9096
9126
  log_error(`${gobj_short_name(gobj)}: collapse all with no tree loaded`);
9097
9127
  return -1;
9098
9128
  }
9129
+ let keep = fold_keep_node(gobj);
9130
+ let vp = yui_graph_viewport_of(priv.graph, keep);
9099
9131
  fold_collapse_all(priv._fold_model, priv._fold_state);
9100
- reconcile_fold(gobj, {fit: true});
9132
+ reconcile_fold(gobj, {keep: keep, keep_vp: vp});
9101
9133
 
9102
9134
  return 0;
9103
9135
  }