@yuneta/gobj-ui 7.23.163 → 7.23.164

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", {
@@ -57670,6 +57677,7 @@ var PRIVATE_DATA$4 = {
57670
57677
  _on_pointerdown_focus: null,
57671
57678
  _on_native_contextmenu: null,
57672
57679
  _uninstall_long_press: null,
57680
+ _unforward_wheel: null,
57673
57681
  toolbar_collapsed: true,
57674
57682
  _toolbars_could_collapse: null,
57675
57683
  _on_focusout_restore: null,
@@ -57788,6 +57796,10 @@ function mt_destroy$4(gobj) {
57788
57796
  priv._uninstall_long_press();
57789
57797
  priv._uninstall_long_press = null;
57790
57798
  }
57799
+ if (priv._unforward_wheel) {
57800
+ priv._unforward_wheel();
57801
+ priv._unforward_wheel = null;
57802
+ }
57791
57803
  if (priv.graph) {
57792
57804
  priv.graph.destroy();
57793
57805
  priv.graph = null;
@@ -57897,6 +57909,7 @@ function build_graph$1(gobj) {
57897
57909
  plugins: []
57898
57910
  });
57899
57911
  graph.setTheme(priv.theme);
57912
+ priv._unforward_wheel = yui_graph_forward_wheel(graph, priv.$container, { selector: ".TREEDB_CARD, .TREEDB_PILLS" });
57900
57913
  graph.setLayout(layout);
57901
57914
  priv.graph_rendered = false;
57902
57915
  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", {
@@ -57665,6 +57672,7 @@ var PRIVATE_DATA$4 = {
57665
57672
  _on_pointerdown_focus: null,
57666
57673
  _on_native_contextmenu: null,
57667
57674
  _uninstall_long_press: null,
57675
+ _unforward_wheel: null,
57668
57676
  toolbar_collapsed: true,
57669
57677
  _toolbars_could_collapse: null,
57670
57678
  _on_focusout_restore: null,
@@ -57783,6 +57791,10 @@ function mt_destroy$4(gobj) {
57783
57791
  priv._uninstall_long_press();
57784
57792
  priv._uninstall_long_press = null;
57785
57793
  }
57794
+ if (priv._unforward_wheel) {
57795
+ priv._unforward_wheel();
57796
+ priv._unforward_wheel = null;
57797
+ }
57786
57798
  if (priv.graph) {
57787
57799
  priv.graph.destroy();
57788
57800
  priv.graph = null;
@@ -57892,6 +57904,7 @@ function build_graph$1(gobj) {
57892
57904
  plugins: []
57893
57905
  });
57894
57906
  graph.setTheme(priv.theme);
57907
+ priv._unforward_wheel = yui_graph_forward_wheel(graph, priv.$container, { selector: ".TREEDB_CARD, .TREEDB_PILLS" });
57895
57908
  graph.setLayout(layout);
57896
57909
  priv.graph_rendered = false;
57897
57910
  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.164",
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
 
@@ -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", {