@yuneta/gobj-ui 7.23.163 → 7.23.165

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
@@ -1016,7 +1016,22 @@ priv.unforward_wheel();
1016
1016
 
1017
1017
  An element that must scroll by itself inside the graph (a popover) stops the
1018
1018
  wheel with `stopPropagation()` before it reaches `$host`.
1019
- `C_YUI_TREEDB_SCHEMA` uses it; `C_G6_NODES_TREE` does not yet.
1019
+
1020
+ A graph that puts other DOM in its container, such as its own toolbars or a
1021
+ legend, passes `opts.selector`. Then only a wheel whose target is inside a
1022
+ matching element is forwarded, and a wheel over the rest keeps its own
1023
+ behaviour:
1024
+
1025
+ ```js
1026
+ priv._unforward_wheel = yui_graph_forward_wheel(graph, priv.$container, {
1027
+ selector: ".TREEDB_CARD, .TREEDB_PILLS"
1028
+ });
1029
+ ```
1030
+
1031
+ `C_YUI_TREEDB_SCHEMA` forwards every wheel (its container holds only the
1032
+ cards). `C_G6_NODES_TREE` forwards only the wheels over its cards and pill
1033
+ strips (since `7.23.164`), so Ctrl + wheel over its toolbar does not zoom the
1034
+ graph.
1020
1035
 
1021
1036
  ### The anchor: one element the camera holds
1022
1037
 
@@ -11526,9 +11526,15 @@ function yui_graph_camera_behaviors() {
11526
11526
  * element that must scroll by itself (a popover) stops the
11527
11527
  * wheel before it gets here.
11528
11528
  *
11529
+ * `opts.selector` narrows it to the wheels whose target is
11530
+ * inside an element that matches, e.g. the root class of the
11531
+ * cards. A graph that puts other DOM in its container -- its
11532
+ * own toolbars, a legend -- passes one, so a wheel over those
11533
+ * is left to them instead of scrolling the graph.
11534
+ *
11529
11535
  * Returns the function that removes the listener.
11530
11536
  ************************************************************/
11531
- function yui_graph_forward_wheel(graph, $host) {
11537
+ function yui_graph_forward_wheel(graph, $host, opts = {}) {
11532
11538
  if (!graph || !$host) return () => {};
11533
11539
  const on_wheel = (e) => {
11534
11540
  let dom = null;
@@ -11538,6 +11544,7 @@ function yui_graph_forward_wheel(graph, $host) {
11538
11544
  return;
11539
11545
  }
11540
11546
  if (!dom || e.target === dom) return;
11547
+ if (opts.selector && !(e.target instanceof Element && e.target.closest(opts.selector))) return;
11541
11548
  e.preventDefault();
11542
11549
  e.stopPropagation();
11543
11550
  dom.dispatchEvent(new WheelEvent("wheel", {
@@ -24544,10 +24551,16 @@ function ac_select_topic_card(gobj, event, kw, src) {
24544
24551
  * Falls back to an in-view flip only when no routes were supplied.
24545
24552
  ************************************************************/
24546
24553
  function ac_toggle_landing_view(gobj, event, kw, src) {
24547
- let target = gobj.priv._landing_view === "schema" ? "cards" : "schema";
24554
+ let priv = gobj.priv;
24555
+ let target = priv._landing_view === "schema" ? "cards" : "schema";
24548
24556
  let routes = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "landing_routes");
24549
24557
  let href = (0, _yuneta_gobj_js.is_object)(routes) ? routes[target] : null;
24550
24558
  if (href && typeof window !== "undefined") {
24559
+ if (window.location.hash === href) {
24560
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: landing view '${priv._landing_view}' on screen under the '${target}' url (${href}): following the url`);
24561
+ set_landing_view(gobj, target);
24562
+ return 0;
24563
+ }
24551
24564
  window.location.hash = href;
24552
24565
  return 0;
24553
24566
  }
@@ -24573,6 +24586,12 @@ function ac_set_landing_view(gobj, event, kw, src) {
24573
24586
  * Back from a topic to the cards-landing grid (the section index).
24574
24587
  ************************************************************/
24575
24588
  function ac_back_to_topics(gobj, event, kw, src) {
24589
+ let routes = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "landing_routes");
24590
+ let href = (0, _yuneta_gobj_js.is_object)(routes) ? routes[gobj.priv._landing_view] : null;
24591
+ if (href && typeof window !== "undefined") {
24592
+ window.location.hash = href;
24593
+ return 0;
24594
+ }
24576
24595
  show_topics_landing(gobj);
24577
24596
  (0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_TOPIC_SELECTED", { topic: "" });
24578
24597
  return 0;
@@ -57670,6 +57689,7 @@ var PRIVATE_DATA$4 = {
57670
57689
  _on_pointerdown_focus: null,
57671
57690
  _on_native_contextmenu: null,
57672
57691
  _uninstall_long_press: null,
57692
+ _unforward_wheel: null,
57673
57693
  toolbar_collapsed: true,
57674
57694
  _toolbars_could_collapse: null,
57675
57695
  _on_focusout_restore: null,
@@ -57788,6 +57808,10 @@ function mt_destroy$4(gobj) {
57788
57808
  priv._uninstall_long_press();
57789
57809
  priv._uninstall_long_press = null;
57790
57810
  }
57811
+ if (priv._unforward_wheel) {
57812
+ priv._unforward_wheel();
57813
+ priv._unforward_wheel = null;
57814
+ }
57791
57815
  if (priv.graph) {
57792
57816
  priv.graph.destroy();
57793
57817
  priv.graph = null;
@@ -57897,6 +57921,7 @@ function build_graph$1(gobj) {
57897
57921
  plugins: []
57898
57922
  });
57899
57923
  graph.setTheme(priv.theme);
57924
+ priv._unforward_wheel = yui_graph_forward_wheel(graph, priv.$container, { selector: ".TREEDB_CARD, .TREEDB_PILLS" });
57900
57925
  graph.setLayout(layout);
57901
57926
  priv.graph_rendered = false;
57902
57927
  graph_render(gobj).then(() => {
@@ -11521,9 +11521,15 @@ function yui_graph_camera_behaviors() {
11521
11521
  * element that must scroll by itself (a popover) stops the
11522
11522
  * wheel before it gets here.
11523
11523
  *
11524
+ * `opts.selector` narrows it to the wheels whose target is
11525
+ * inside an element that matches, e.g. the root class of the
11526
+ * cards. A graph that puts other DOM in its container -- its
11527
+ * own toolbars, a legend -- passes one, so a wheel over those
11528
+ * is left to them instead of scrolling the graph.
11529
+ *
11524
11530
  * Returns the function that removes the listener.
11525
11531
  ************************************************************/
11526
- function yui_graph_forward_wheel(graph, $host) {
11532
+ function yui_graph_forward_wheel(graph, $host, opts = {}) {
11527
11533
  if (!graph || !$host) return () => {};
11528
11534
  const on_wheel = (e) => {
11529
11535
  let dom = null;
@@ -11533,6 +11539,7 @@ function yui_graph_forward_wheel(graph, $host) {
11533
11539
  return;
11534
11540
  }
11535
11541
  if (!dom || e.target === dom) return;
11542
+ if (opts.selector && !(e.target instanceof Element && e.target.closest(opts.selector))) return;
11536
11543
  e.preventDefault();
11537
11544
  e.stopPropagation();
11538
11545
  dom.dispatchEvent(new WheelEvent("wheel", {
@@ -24539,10 +24546,16 @@ function ac_select_topic_card(gobj, event, kw, src) {
24539
24546
  * Falls back to an in-view flip only when no routes were supplied.
24540
24547
  ************************************************************/
24541
24548
  function ac_toggle_landing_view(gobj, event, kw, src) {
24542
- let target = gobj.priv._landing_view === "schema" ? "cards" : "schema";
24549
+ let priv = gobj.priv;
24550
+ let target = priv._landing_view === "schema" ? "cards" : "schema";
24543
24551
  let routes = gobj_read_attr(gobj, "landing_routes");
24544
24552
  let href = is_object(routes) ? routes[target] : null;
24545
24553
  if (href && typeof window !== "undefined") {
24554
+ if (window.location.hash === href) {
24555
+ log_error(`${gobj_short_name(gobj)}: landing view '${priv._landing_view}' on screen under the '${target}' url (${href}): following the url`);
24556
+ set_landing_view(gobj, target);
24557
+ return 0;
24558
+ }
24546
24559
  window.location.hash = href;
24547
24560
  return 0;
24548
24561
  }
@@ -24568,6 +24581,12 @@ function ac_set_landing_view(gobj, event, kw, src) {
24568
24581
  * Back from a topic to the cards-landing grid (the section index).
24569
24582
  ************************************************************/
24570
24583
  function ac_back_to_topics(gobj, event, kw, src) {
24584
+ let routes = gobj_read_attr(gobj, "landing_routes");
24585
+ let href = is_object(routes) ? routes[gobj.priv._landing_view] : null;
24586
+ if (href && typeof window !== "undefined") {
24587
+ window.location.hash = href;
24588
+ return 0;
24589
+ }
24571
24590
  show_topics_landing(gobj);
24572
24591
  gobj_publish_event(gobj, "EV_TOPIC_SELECTED", { topic: "" });
24573
24592
  return 0;
@@ -57665,6 +57684,7 @@ var PRIVATE_DATA$4 = {
57665
57684
  _on_pointerdown_focus: null,
57666
57685
  _on_native_contextmenu: null,
57667
57686
  _uninstall_long_press: null,
57687
+ _unforward_wheel: null,
57668
57688
  toolbar_collapsed: true,
57669
57689
  _toolbars_could_collapse: null,
57670
57690
  _on_focusout_restore: null,
@@ -57783,6 +57803,10 @@ function mt_destroy$4(gobj) {
57783
57803
  priv._uninstall_long_press();
57784
57804
  priv._uninstall_long_press = null;
57785
57805
  }
57806
+ if (priv._unforward_wheel) {
57807
+ priv._unforward_wheel();
57808
+ priv._unforward_wheel = null;
57809
+ }
57786
57810
  if (priv.graph) {
57787
57811
  priv.graph.destroy();
57788
57812
  priv.graph = null;
@@ -57892,6 +57916,7 @@ function build_graph$1(gobj) {
57892
57916
  plugins: []
57893
57917
  });
57894
57918
  graph.setTheme(priv.theme);
57919
+ priv._unforward_wheel = yui_graph_forward_wheel(graph, priv.$container, { selector: ".TREEDB_CARD, .TREEDB_PILLS" });
57895
57920
  graph.setLayout(layout);
57896
57921
  priv.graph_rendered = false;
57897
57922
  graph_render(gobj).then(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.163",
3
+ "version": "7.23.165",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -112,6 +112,7 @@ import {
112
112
  yui_graph_center_on,
113
113
  yui_graph_viewport_of,
114
114
  yui_graph_camera_behaviors,
115
+ yui_graph_forward_wheel,
115
116
  yui_graph_place_at,
116
117
  } from "./yui_graph_camera.js";
117
118
  import {
@@ -531,6 +532,7 @@ let PRIVATE_DATA = {
531
532
  _on_pointerdown_focus: null, // listener keeping the keyboard on the canvas
532
533
  _on_native_contextmenu: null, // listener keeping the browser's menu out
533
534
  _uninstall_long_press: null, // touch door to the context menu
535
+ _unforward_wheel: null, // removes the wheel forwarding of the cards
534
536
  toolbar_collapsed: true, // floating toolbars folded (narrow only)
535
537
  _toolbars_could_collapse: null, // last answer, to notice it changed
536
538
  _on_focusout_restore: null, // ...and putting it back when it goes nowhere
@@ -743,6 +745,11 @@ function mt_destroy(gobj)
743
745
  priv._uninstall_long_press = null;
744
746
  }
745
747
 
748
+ if(priv._unforward_wheel) {
749
+ priv._unforward_wheel();
750
+ priv._unforward_wheel = null;
751
+ }
752
+
746
753
  if(priv.graph) {
747
754
  priv.graph.destroy();
748
755
  priv.graph = null;
@@ -994,6 +1001,14 @@ function build_graph(gobj)
994
1001
  */
995
1002
  graph.setTheme(priv.theme);
996
1003
 
1004
+ /* A card is an HTML node, and G6's HTML nodes do not pass the wheel
1005
+ * on: over a card the graph neither scrolled nor zoomed. Only a wheel
1006
+ * over a CARD is handed back to the canvas -- the toolbars and the
1007
+ * legend live in this container too, and keep their own wheel. */
1008
+ priv._unforward_wheel = yui_graph_forward_wheel(graph, priv.$container, {
1009
+ selector: ".TREEDB_CARD, .TREEDB_PILLS"
1010
+ });
1011
+
997
1012
  graph.setLayout(layout);
998
1013
  //show_positions(gobj);
999
1014
 
@@ -2185,6 +2185,17 @@ function ac_toggle_landing_view(gobj, event, kw, src)
2185
2185
  let routes = gobj_read_attr(gobj, "landing_routes");
2186
2186
  let href = is_object(routes) ? routes[target] : null;
2187
2187
  if(href && typeof window !== "undefined") {
2188
+ /* The url already says `target` while the screen shows the other
2189
+ * view: assigning the same hash fires no route change, so the
2190
+ * switch would never come and the button would do nothing. The
2191
+ * screen and the url disagreeing is a broken invariant -- said,
2192
+ * and then the screen follows the url. */
2193
+ if(window.location.hash === href) {
2194
+ log_error(`${gobj_short_name(gobj)}: landing view '${priv._landing_view}' ` +
2195
+ `on screen under the '${target}' url (${href}): following the url`);
2196
+ set_landing_view(gobj, target);
2197
+ return 0;
2198
+ }
2188
2199
  window.location.hash = href; /* push; route drives the switch */
2189
2200
  return 0;
2190
2201
  }
@@ -2217,9 +2228,25 @@ function ac_set_landing_view(gobj, event, kw, src)
2217
2228
  ************************************************************/
2218
2229
  function ac_back_to_topics(gobj, event, kw, src)
2219
2230
  {
2231
+ /* With host routes the landing is a POSITION, so Back GOES there, the
2232
+ * way the toggle does, and the route drives the switch.
2233
+ *
2234
+ * It used to paint the landing it remembered and tell the host "no
2235
+ * topic", which the host turns into the BARE route -- always the
2236
+ * cards. After a click on a node of the SCHEMA landing that left the
2237
+ * schema on screen under a cards url, and from then on the toggle
2238
+ * navigated to the url the page already had: no route change came and
2239
+ * the button did nothing. There was no way out of the schema. */
2240
+ let routes = gobj_read_attr(gobj, "landing_routes");
2241
+ let href = is_object(routes) ? routes[gobj.priv._landing_view] : null;
2242
+ if(href && typeof window !== "undefined") {
2243
+ window.location.hash = href; /* push; route drives the switch */
2244
+ return 0;
2245
+ }
2246
+
2247
+ /* Legacy: no routes. Paint it here, and tell the host the topic
2248
+ * segment is gone so a reload re-lands on the grid. */
2220
2249
  show_topics_landing(gobj);
2221
- /* Tell the host the topic segment is gone so a reload re-lands on the
2222
- * grid (empty topic ⇒ the host drops the <topic> from the URL). */
2223
2250
  gobj_publish_event(gobj, "EV_TOPIC_SELECTED", {topic: ""});
2224
2251
  return 0;
2225
2252
  }
@@ -171,9 +171,15 @@ export function yui_graph_camera_behaviors()
171
171
  * element that must scroll by itself (a popover) stops the
172
172
  * wheel before it gets here.
173
173
  *
174
+ * `opts.selector` narrows it to the wheels whose target is
175
+ * inside an element that matches, e.g. the root class of the
176
+ * cards. A graph that puts other DOM in its container -- its
177
+ * own toolbars, a legend -- passes one, so a wheel over those
178
+ * is left to them instead of scrolling the graph.
179
+ *
174
180
  * Returns the function that removes the listener.
175
181
  ************************************************************/
176
- export function yui_graph_forward_wheel(graph, $host)
182
+ export function yui_graph_forward_wheel(graph, $host, opts = {})
177
183
  {
178
184
  if(!graph || !$host) {
179
185
  return () => {};
@@ -188,6 +194,9 @@ export function yui_graph_forward_wheel(graph, $host)
188
194
  if(!dom || e.target === dom) {
189
195
  return;
190
196
  }
197
+ if(opts.selector && !(e.target instanceof Element && e.target.closest(opts.selector))) {
198
+ return; /* not over a card: that DOM keeps its own wheel */
199
+ }
191
200
  e.preventDefault();
192
201
  e.stopPropagation();
193
202
  dom.dispatchEvent(new WheelEvent("wheel", {