plotboilerplate 1.20.0 → 1.20.2

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.
Files changed (89) hide show
  1. package/README.md +17 -0
  2. package/dist/index.esm.js +101 -50
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm.min.js +1 -1
  5. package/dist/index.esm.min.js.map +1 -1
  6. package/dist/plotboilerplate.browser.min.js +1 -1
  7. package/dist/plotboilerplate.browser.min.js.map +1 -1
  8. package/dist/plotboilerplate.js +102 -50
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +2 -1
  11. package/src/cjs/BezierPath.js +2 -3
  12. package/src/cjs/BezierPath.js.map +1 -1
  13. package/src/cjs/PlotBoilerplate.d.ts +7 -1
  14. package/src/cjs/PlotBoilerplate.js +76 -33
  15. package/src/cjs/PlotBoilerplate.js.map +1 -1
  16. package/src/cjs/Triangle.js +1 -0
  17. package/src/cjs/Triangle.js.map +1 -1
  18. package/src/cjs/draw.d.ts +6 -5
  19. package/src/cjs/draw.js +4 -3
  20. package/src/cjs/draw.js.map +1 -1
  21. package/src/cjs/drawgl.d.ts +7 -6
  22. package/src/cjs/drawgl.js +5 -4
  23. package/src/cjs/drawgl.js.map +1 -1
  24. package/src/cjs/drawutilssvg.d.ts +8 -6
  25. package/src/cjs/drawutilssvg.js +14 -7
  26. package/src/cjs/drawutilssvg.js.map +1 -1
  27. package/src/cjs/interfaces/DrawLib.d.ts +4 -3
  28. package/src/cjs/interfaces/DrawLib.js +1 -0
  29. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  30. package/src/cjs/interfaces/core.d.ts +33 -30
  31. package/src/cjs/interfaces/core.js +1 -0
  32. package/src/cjs/interfaces/core.js.map +1 -1
  33. package/src/cjs/utils/datastructures/Color.d.ts +3 -1
  34. package/src/cjs/utils/datastructures/Color.js +12 -1
  35. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  36. package/src/cjs/utils/module.js +4 -2
  37. package/src/cjs/utils/parsers/svg/parseSVGPathData.d.ts +2 -1
  38. package/src/cjs/utils/parsers/svg/parseSVGPathData.js +228 -205
  39. package/src/cjs/utils/parsers/svg/parseSVGPathData.js.map +1 -1
  40. package/src/cjs/utils/parsers/svg/splitSVGPathData.js +6 -2
  41. package/src/cjs/utils/parsers/svg/splitSVGPathData.js.map +1 -1
  42. package/src/cjs/utils/parsers/svg/types.d.ts +29 -9
  43. package/src/cjs/utils/parsers/svg/types.js +4 -3
  44. package/src/cjs/utils/parsers/svg/types.js.map +1 -1
  45. package/src/esm/BezierPath.js +2 -3
  46. package/src/esm/BezierPath.js.map +1 -1
  47. package/src/esm/PlotBoilerplate.d.ts +7 -1
  48. package/src/esm/PlotBoilerplate.js +75 -33
  49. package/src/esm/PlotBoilerplate.js.map +1 -1
  50. package/src/esm/Triangle.js +1 -0
  51. package/src/esm/Triangle.js.map +1 -1
  52. package/src/esm/draw.d.ts +6 -5
  53. package/src/esm/draw.js +4 -3
  54. package/src/esm/draw.js.map +1 -1
  55. package/src/esm/drawgl.d.ts +7 -6
  56. package/src/esm/drawgl.js +5 -4
  57. package/src/esm/drawgl.js.map +1 -1
  58. package/src/esm/drawutilssvg.d.ts +8 -6
  59. package/src/esm/drawutilssvg.js +14 -7
  60. package/src/esm/drawutilssvg.js.map +1 -1
  61. package/src/esm/interfaces/DrawLib.d.ts +4 -3
  62. package/src/esm/interfaces/DrawLib.js +1 -0
  63. package/src/esm/interfaces/DrawLib.js.map +1 -1
  64. package/src/esm/interfaces/core.d.ts +33 -30
  65. package/src/esm/interfaces/core.js +1 -0
  66. package/src/esm/interfaces/core.js.map +1 -1
  67. package/src/esm/utils/datastructures/Color.d.ts +3 -1
  68. package/src/esm/utils/datastructures/Color.js +12 -1
  69. package/src/esm/utils/datastructures/Color.js.map +1 -1
  70. package/src/esm/utils/parsers/svg/parseSVGPathData.d.ts +2 -1
  71. package/src/esm/utils/parsers/svg/parseSVGPathData.js +228 -205
  72. package/src/esm/utils/parsers/svg/parseSVGPathData.js.map +1 -1
  73. package/src/esm/utils/parsers/svg/splitSVGPathData.js +6 -2
  74. package/src/esm/utils/parsers/svg/splitSVGPathData.js.map +1 -1
  75. package/src/esm/utils/parsers/svg/types.d.ts +29 -9
  76. package/src/esm/utils/parsers/svg/types.js +4 -3
  77. package/src/esm/utils/parsers/svg/types.js.map +1 -1
  78. package/src/ts/BezierPath.ts +2 -3
  79. package/src/ts/PlotBoilerplate.ts +75 -32
  80. package/src/ts/Triangle.ts +2 -1
  81. package/src/ts/draw.ts +6 -5
  82. package/src/ts/drawgl.ts +9 -8
  83. package/src/ts/drawutilssvg.ts +23 -16
  84. package/src/ts/interfaces/DrawLib.ts +4 -3
  85. package/src/ts/interfaces/core.ts +33 -30
  86. package/src/ts/utils/datastructures/Color.ts +13 -1
  87. package/src/ts/utils/parsers/svg/parseSVGPathData.ts +271 -212
  88. package/src/ts/utils/parsers/svg/splitSVGPathData.ts +6 -2
  89. package/src/ts/utils/parsers/svg/types.ts +29 -9
package/README.md CHANGED
@@ -153,6 +153,10 @@ For a guide of how to [Getting Started click here](https://github.com/IkarosKapp
153
153
 
154
154
  A full working demo repository about the [Usage with Typescript is here](https://github.com/IkarosKappler/plotboilerplate-typescript-example "usage with Typescript is here").
155
155
 
156
+ ### Codepen Demos
157
+
158
+ [Basic Setup in a Codepen.io demo](https://codepen.io/ikaroskappler/pen/ZEjamVb)
159
+
156
160
  ### Screenshot
157
161
 
158
162
  ![Simple Demo](https://plotboilerplate.io/repo/screenshots/screenshot-20190220_3_simpledemo.png "The simple demo")
@@ -354,6 +358,14 @@ var pb = new PlotBoilerplate({
354
358
  // Indicates if the application should handle mouse wheelevents for you.
355
359
  enableMouseWheel: true,
356
360
 
361
+ // boolean (default true)
362
+ // Use this to disable panning completely.
363
+ enablePan: true,
364
+
365
+ // boolean (default true)
366
+ // Use this to disable zooming completely.
367
+ enableZoom: true,
368
+
357
369
  // Indicates if the SVG export should be enabled (default is true).
358
370
  enableSVGExport: true,
359
371
 
@@ -542,6 +554,8 @@ new MouseHandler(document.getElementById("mycanvas"))
542
554
  - [jburkardt](https://people.sc.fsu.edu/~jburkardt/data/obj/obj.html "jburkardt") for the obj test files.
543
555
  - [@veltman](https://noahveltman.com/) for the awesome [geometric skeletonization article](https://observablehq.com/@veltman/centerline-labeling)
544
556
  - [girih-tiles-spatial.jpg from Lund University, Architecture, Spatial Experiments, 2016.](https://spatialexperiments.wordpress.com/2016/09/19/islamic-geometry/girih-tiles-4/)
557
+ - [Josh Frank's regular expression for parsing SVG path data.](https://javascript.plainenglish.io/june-3-parsing-and-validating-svg-paths-with-regex-7bd0e245115)
558
+ - [Rick Moore for the useful javascript-synthesizer howto](https://medium.com/geekculture/building-a-modular-synth-with-web-audio-api-and-javascript-d38ccdeca9ea)
545
559
 
546
560
  ## Todos
547
561
 
@@ -554,3 +568,6 @@ new MouseHandler(document.getElementById("mycanvas"))
554
568
  - The minifid BBTree and BBTreeCollection files do not export anything. The un-minified does. Why that?
555
569
  - Arcs and ellipses break when non-uniform scaling (scalex!=scaley) is applied. Convert them to Bézier curves before drawing.
556
570
  - Currently no more known. Please report bugs.
571
+
572
+ Oh look, a cat
573
+ ᓚᘏᗢ
package/dist/index.esm.js CHANGED
@@ -3910,8 +3910,7 @@ class BezierPath {
3910
3910
  static fromReducedList(pointArray, adjustCircular) {
3911
3911
  // Convert to object
3912
3912
  var bezierPath = new BezierPath(null); // No points yet
3913
- // var firstStartPoint: Vertex;
3914
- var startPoint;
3913
+ var startPoint = new Vertex();
3915
3914
  var startControlPoint;
3916
3915
  var endControlPoint;
3917
3916
  var endPoint;
@@ -3933,7 +3932,7 @@ class BezierPath {
3933
3932
  startPoint = endPoint;
3934
3933
  i += 6;
3935
3934
  } while (i + 2 < pointArray.length);
3936
- bezierPath.adjustCircular = adjustCircular;
3935
+ bezierPath.adjustCircular = adjustCircular !== null && adjustCircular !== void 0 ? adjustCircular : false;
3937
3936
  if (adjustCircular) {
3938
3937
  bezierPath.bezierCurves[bezierPath.bezierCurves.length - 1].endPoint = bezierPath.bezierCurves[0].startPoint;
3939
3938
  }
@@ -4475,7 +4474,9 @@ CircleSector.circleSectorUtils = {
4475
4474
  * @modified 2022-03-26 Added the `texturedPoly` function to draw textures polygons.
4476
4475
  * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
4477
4476
  * @modified 2022-11-10 Tweaking some type issues.
4478
- * @version 1.6.2
4477
+ * @modified 2023-02-04 Fixed a typo in the CSS classname for cubic Bézier paths: cubicBezier (was cubierBezier).
4478
+ * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.
4479
+ * @version 1.6.4
4479
4480
  **/
4480
4481
  const RAD_TO_DEG = 180 / Math.PI;
4481
4482
  /**
@@ -4507,7 +4508,7 @@ class drawutilssvg {
4507
4508
  this.offset = new Vertex(0, 0).set(offset);
4508
4509
  this.scale = new Vertex(1, 1).set(scale);
4509
4510
  this.fillShapes = fillShapes;
4510
- this.isSecondary = isSecondary;
4511
+ this.isSecondary = Boolean(isSecondary);
4511
4512
  this.drawlibConfiguration = {};
4512
4513
  this.cache = new Map();
4513
4514
  this.setSize(canvasSize);
@@ -4537,6 +4538,8 @@ class drawutilssvg {
4537
4538
  // Which default styles to add? -> All from the DrawConfig.
4538
4539
  // Compare with DrawConfig interface
4539
4540
  const keys = {
4541
+ // "bezier": "CubicBezierCurve", // TODO: is this correct?
4542
+ "bezierPath": "BezierPath",
4540
4543
  "polygon": "Polygon",
4541
4544
  "triangle": "Triangle",
4542
4545
  "ellipse": "Ellipse",
@@ -4602,6 +4605,9 @@ class drawutilssvg {
4602
4605
  * @param {string} nodeName - The expected node name.
4603
4606
  */
4604
4607
  findElement(key, nodeName) {
4608
+ if (!key) {
4609
+ return null;
4610
+ }
4605
4611
  var node = this.cache.get(key);
4606
4612
  if (node && node.nodeName.toUpperCase() === nodeName.toUpperCase()) {
4607
4613
  this.cache.delete(key);
@@ -4676,8 +4682,8 @@ class drawutilssvg {
4676
4682
  else {
4677
4683
  node.setAttribute("class", className);
4678
4684
  }
4679
- node.setAttribute("fill", this.fillShapes ? color : "none");
4680
- node.setAttribute("stroke", this.fillShapes ? "none" : color);
4685
+ node.setAttribute("fill", this.fillShapes && color ? color : "none");
4686
+ node.setAttribute("stroke", this.fillShapes ? "none" : color || "none");
4681
4687
  node.setAttribute("stroke-width", `${lineWidth || 1}`);
4682
4688
  if (this.curId) {
4683
4689
  node.setAttribute("id", `${this.curId}`); // Maybe React-style 'key' would be better?
@@ -4728,7 +4734,7 @@ class drawutilssvg {
4728
4734
  *
4729
4735
  * @name setCurrentId
4730
4736
  * @method
4731
- * @param {UID} uid - A UID identifying the currently drawn element(s).
4737
+ * @param {UID|null} uid - A UID identifying the currently drawn element(s).
4732
4738
  * @instance
4733
4739
  * @memberof drawutilssvg
4734
4740
  **/
@@ -4741,7 +4747,7 @@ class drawutilssvg {
4741
4747
  *
4742
4748
  * @name setCurrentClassName
4743
4749
  * @method
4744
- * @param {string} className - A class name for further custom use cases.
4750
+ * @param {string|null} className - A class name for further custom use cases.
4745
4751
  * @instance
4746
4752
  * @memberof drawutilssvg
4747
4753
  **/
@@ -4991,7 +4997,7 @@ class drawutilssvg {
4991
4997
  this._y(endPoint.y)
4992
4998
  ];
4993
4999
  node.setAttribute("d", d.join(" "));
4994
- return this._bindFillDraw(node, "cubierBezier", color, lineWidth);
5000
+ return this._bindFillDraw(node, "cubicBezier", color, lineWidth);
4995
5001
  }
4996
5002
  /**
4997
5003
  * Draw the given (cubic) Bézier path.
@@ -5843,7 +5849,8 @@ drawutilssvg.HEAD_XML = [
5843
5849
  * @modified 2022-08-23 Fixed a type issue in the `polyline` function.
5844
5850
  * @modified 2022-08-23 Fixed a type issue in the `setConfiguration` function.
5845
5851
  * @modified 2022-08-23 Fixed a type issue in the `path` function.
5846
- * @version 1.12.3
5852
+ * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.
5853
+ * @version 1.12.4
5847
5854
  **/
5848
5855
  // Todo: rename this class to Drawutils?
5849
5856
  /**
@@ -5905,7 +5912,7 @@ class drawutils {
5905
5912
  *
5906
5913
  * @name setCurrentId
5907
5914
  * @method
5908
- * @param {UID} uid - A UID identifying the currently drawn element(s).
5915
+ * @param {UID|null} uid - A UID identifying the currently drawn element(s).
5909
5916
  **/
5910
5917
  setCurrentId(uid) {
5911
5918
  // NOOP
@@ -5916,7 +5923,7 @@ class drawutils {
5916
5923
  *
5917
5924
  * @name setCurrentClassName
5918
5925
  * @method
5919
- * @param {string} className - A class name for further custom use cases.
5926
+ * @param {string|null} className - A class name for further custom use cases.
5920
5927
  **/
5921
5928
  setCurrentClassName(className) {
5922
5929
  // NOOP
@@ -6782,7 +6789,8 @@ drawutils.helpers = {
6782
6789
  * @modified 2022-02-03 Added the `cross(...)` function.
6783
6790
  * @modified 2022-03-27 Added the `texturedPoly` function.
6784
6791
  * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
6785
- * @version 0.0.8
6792
+ * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.
6793
+ * @version 0.0.9
6786
6794
  **/
6787
6795
  /**
6788
6796
  * @classdesc A wrapper class for basic drawing operations. This is the WebGL
@@ -6800,7 +6808,7 @@ class drawutilsgl {
6800
6808
  *
6801
6809
  * @constructor
6802
6810
  * @name drawutils
6803
- * @param {WebGLRenderingContext} context - The drawing context.
6811
+ * @param {WebGLRenderingContext|null} context - The drawing context.
6804
6812
  * @param {boolean} fillShaped - Indicates if the constructed drawutils should fill all drawn shapes (if possible).
6805
6813
  **/
6806
6814
  constructor(context, fillShapes) {
@@ -6882,7 +6890,7 @@ class drawutilsgl {
6882
6890
  *
6883
6891
  * @name setCurrentId
6884
6892
  * @method
6885
- * @param {UID} uid - A UID identifying the currently drawn element(s).es.
6893
+ * @param {UID|null} uid - A UID identifying the currently drawn element(s).es.
6886
6894
  **/
6887
6895
  setCurrentId(uid) {
6888
6896
  // NOOP
@@ -6894,7 +6902,7 @@ class drawutilsgl {
6894
6902
  *
6895
6903
  * @name setCurrentClassName
6896
6904
  * @method
6897
- * @param {string} className - A class name for further custom use cases.
6905
+ * @param {string|null} className - A class name for further custom use cases.
6898
6906
  **/
6899
6907
  setCurrentClassName(className) {
6900
6908
  // NOOP
@@ -7823,6 +7831,7 @@ class Triangle {
7823
7831
  const lineC = new Line(this.c, this.a);
7824
7832
  const bisector1 = geomutils.nsectAngle(this.b, this.a, this.c, 2)[0]; // bisector of first angle (in b)
7825
7833
  const bisector2 = geomutils.nsectAngle(this.c, this.b, this.a, 2)[0]; // bisector of second angle (in c)
7834
+ // Cast to non-null here because we know there _is_ an intersection
7826
7835
  const intersection = bisector1.intersection(bisector2);
7827
7836
  // Find the closest points on one of the polygon lines (all have same distance by construction)
7828
7837
  const circleIntersA = lineA.getClosestPoint(intersection);
@@ -10146,7 +10155,11 @@ VEllipseSector.ellipseSectorUtils = {
10146
10155
  * @modified 2022-10-25 Added the `origin` to the default draw config.
10147
10156
  * @modified 2022-11-06 Adding an XML declaration to the SVG export routine.
10148
10157
  * @modified 2022-11-23 Added the `drawRaster` (default=true) option to the config/drawconfig.
10149
- * @version 1.17.0
10158
+ * @modified 2023-02-04 Fixed a bug in the `drawDrawable` function; fill's current classname was not set.
10159
+ * @modified 2023-02-10 Fixing an issue of the `style.position` setting when `fitToParent=true` from `absolute` to `static` (default).
10160
+ * @modified 2023-02-10 Cleaning up most type errors in the main class (mostly null checks).
10161
+ * @modified 2023-02-10 Adding `enableZoom` and `enablePan` (both default true) to have the option to disable these functions.
10162
+ * @version 1.17.2
10150
10163
  *
10151
10164
  * @file PlotBoilerplate
10152
10165
  * @fileoverview The main class.
@@ -10236,6 +10249,8 @@ class PlotBoilerplate {
10236
10249
  * @param {boolean=} [config.enableTouch=true] - Indicates if the application should handle touch events for you.
10237
10250
  * @param {boolean=} [config.enableKeys=true] - Indicates if the application should handle key events for you.
10238
10251
  * @param {boolean=} [config.enableMouseWheel=true] - Indicates if the application should handle mouse wheel events for you.
10252
+ * @param {boolean=} [config.enablePan=true] - (default true) Set to false if you want to disable panning completely.
10253
+ * @param {boolean=} [config.enableZoom=true] - (default true) Set to false if you want to disable zooming completely.
10239
10254
  * @param {boolean=} [config.enableGL=false] - Indicates if the application should use the experimental WebGL features (not recommended).
10240
10255
  * @param {boolean=} [config.enableSVGExport=true] - Indicates if the SVG export should be enabled (default is true).
10241
10256
  * Note that changes from the postDraw hook might not be visible in the export.
@@ -10316,6 +10331,8 @@ class PlotBoilerplate {
10316
10331
  enableTouch: f.bool(config, "enableTouch", true),
10317
10332
  enableKeys: f.bool(config, "enableKeys", true),
10318
10333
  enableMouseWheel: f.bool(config, "enableMouseWheel", true),
10334
+ enableZoom: f.bool(config, "enableZoom", true),
10335
+ enablePan: f.bool(config, "enablePan", true),
10319
10336
  // Experimental (and unfinished)
10320
10337
  enableGL: f.bool(config, "enableGL", false)
10321
10338
  }; // END confog
@@ -10980,7 +10997,7 @@ class PlotBoilerplate {
10980
10997
  this.draw.setCurrentId(d.uid);
10981
10998
  this.fill.setCurrentId(d.uid);
10982
10999
  this.draw.setCurrentClassName(d.className);
10983
- this.draw.setCurrentClassName(d.className);
11000
+ this.fill.setCurrentClassName(d.className);
10984
11001
  this.drawDrawable(d, renderTime, draw, fill);
10985
11002
  }
10986
11003
  }
@@ -11001,7 +11018,13 @@ class PlotBoilerplate {
11001
11018
  **/
11002
11019
  drawDrawable(d, renderTime, draw, fill) {
11003
11020
  if (d instanceof BezierPath) {
11021
+ var curveIndex = 0;
11004
11022
  for (var c in d.bezierCurves) {
11023
+ // Restore these settings again in each loop (will be overwritten)
11024
+ this.draw.setCurrentId(`${d.uid}-${curveIndex}`);
11025
+ this.fill.setCurrentId(`${d.uid}-${curveIndex}`);
11026
+ this.draw.setCurrentClassName(d.className);
11027
+ this.fill.setCurrentClassName(d.className);
11005
11028
  draw.cubicBezier(d.bezierCurves[c].startPoint, d.bezierCurves[c].endPoint, d.bezierCurves[c].startControlPoint, d.bezierCurves[c].endControlPoint, this.drawConfig.bezier.color, this.drawConfig.bezier.lineWidth);
11006
11029
  if (this.drawConfig.drawBezierHandlePoints && this.drawConfig.drawHandlePoints) {
11007
11030
  if (d.bezierCurves[c].startPoint.attr.visible) {
@@ -11058,7 +11081,8 @@ class PlotBoilerplate {
11058
11081
  draw.setCurrentClassName(`${d.className}-end-line`);
11059
11082
  draw.line(d.bezierCurves[c].endPoint, d.bezierCurves[c].endControlPoint, this.drawConfig.bezier.handleLine.color, this.drawConfig.bezier.handleLine.lineWidth);
11060
11083
  }
11061
- }
11084
+ curveIndex++;
11085
+ } // END for
11062
11086
  }
11063
11087
  else if (d instanceof Polygon) {
11064
11088
  draw.polygon(d, this.drawConfig.polygon.color, this.drawConfig.polygon.lineWidth);
@@ -11169,10 +11193,10 @@ class PlotBoilerplate {
11169
11193
  else {
11170
11194
  console.error("Cannot draw object. Unknown class.");
11171
11195
  }
11172
- draw.setCurrentClassName(undefined);
11173
- draw.setCurrentId(undefined);
11174
- fill.setCurrentClassName(undefined);
11175
- fill.setCurrentId(undefined);
11196
+ draw.setCurrentClassName(null);
11197
+ draw.setCurrentId(null);
11198
+ fill.setCurrentClassName(null);
11199
+ fill.setCurrentId(null);
11176
11200
  }
11177
11201
  /**
11178
11202
  * Draw the select-polygon (if there is one).
@@ -11262,8 +11286,8 @@ class PlotBoilerplate {
11262
11286
  this.drawSelectPolygon(draw);
11263
11287
  // Clear IDs and classnames (postDraw hook might draw somthing and the do not want
11264
11288
  // to interfered with that).
11265
- draw.setCurrentId(undefined);
11266
- draw.setCurrentClassName(undefined);
11289
+ draw.setCurrentId(null);
11290
+ draw.setCurrentClassName(null);
11267
11291
  } // END redraw
11268
11292
  /**
11269
11293
  * This function clears the canvas with the configured background color.<br>
@@ -11399,7 +11423,7 @@ class PlotBoilerplate {
11399
11423
  }
11400
11424
  else if (_self.config.fitToParent) {
11401
11425
  // Set editor size
11402
- _self.canvas.style.position = "absolute";
11426
+ _self.canvas.style.position = "static";
11403
11427
  const space = this.getAvailableContainerSpace();
11404
11428
  _self.canvas.style.width = ((_c = _self.config.canvasWidthFactor) !== null && _c !== void 0 ? _c : 1.0) * space.width + "px";
11405
11429
  _self.canvas.style.height = ((_d = _self.config.canvasHeightFactor) !== null && _d !== void 0 ? _d : 1.0) * space.height + "px";
@@ -11470,24 +11494,24 @@ class PlotBoilerplate {
11470
11494
  **/
11471
11495
  handleClick(e) {
11472
11496
  const _self = this;
11473
- var p = this.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));
11474
- if (p) {
11475
- _self.vertices[p.vindex].listeners.fireClickEvent(e);
11497
+ var point = this.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX || 1.0, _self.config.cssScaleY || 1.0));
11498
+ if (point) {
11499
+ _self.vertices[point.vindex].listeners.fireClickEvent(e);
11476
11500
  if (this.keyHandler && this.keyHandler.isDown("shift")) {
11477
- if (p.typeName == "bpath") {
11478
- let vert = _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid);
11501
+ if (point.typeName == "bpath") {
11502
+ let vert = _self.paths[point.pindex].bezierCurves[point.cindex].getPointByID(point.pid);
11479
11503
  if (vert.attr.selectable)
11480
11504
  vert.attr.isSelected = !vert.attr.isSelected;
11481
11505
  }
11482
- else if (p.typeName == "vertex") {
11483
- let vert = _self.vertices[p.vindex];
11506
+ else if (point.typeName == "vertex") {
11507
+ let vert = _self.vertices[point.vindex];
11484
11508
  if (vert.attr.selectable)
11485
11509
  vert.attr.isSelected = !vert.attr.isSelected;
11486
11510
  }
11487
11511
  _self.redraw();
11488
11512
  }
11489
- else if (this.keyHandler.isDown("y")) {
11490
- _self.vertices[p.vindex].attr.bezierAutoAdjust = !_self.vertices[p.vindex].attr.bezierAutoAdjust;
11513
+ else if (this.keyHandler && this.keyHandler.isDown("y")) {
11514
+ _self.vertices[point.vindex].attr.bezierAutoAdjust = !_self.vertices[point.vindex].attr.bezierAutoAdjust;
11491
11515
  _self.redraw();
11492
11516
  }
11493
11517
  }
@@ -11554,11 +11578,11 @@ class PlotBoilerplate {
11554
11578
  const _self = this;
11555
11579
  if (e.button != 0)
11556
11580
  return; // Only react on left mouse or touch events
11557
- var p = _self.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));
11558
- if (!p)
11581
+ var draggablePoint = _self.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));
11582
+ if (!draggablePoint)
11559
11583
  return;
11560
11584
  // Drag all selected elements?
11561
- if (p.typeName == "vertex" && _self.vertices[p.vindex].attr.isSelected) {
11585
+ if (draggablePoint.typeName == "vertex" && _self.vertices[draggablePoint.vindex].attr.isSelected) {
11562
11586
  // Multi drag
11563
11587
  // for( var i in _self.vertices ) {
11564
11588
  for (var i = 0; i < _self.vertices.length; i++) {
@@ -11570,13 +11594,15 @@ class PlotBoilerplate {
11570
11594
  }
11571
11595
  else {
11572
11596
  // Single drag
11573
- if (!_self.vertices[p.vindex].attr.draggable)
11597
+ if (!_self.vertices[draggablePoint.vindex].attr.draggable)
11574
11598
  return;
11575
- _self.draggedElements.push(p);
11576
- if (p.typeName == "bpath")
11577
- _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid).listeners.fireDragStartEvent(e);
11578
- else if (p.typeName == "vertex")
11579
- _self.vertices[p.vindex].listeners.fireDragStartEvent(e);
11599
+ _self.draggedElements.push(draggablePoint);
11600
+ if (draggablePoint.typeName == "bpath")
11601
+ _self.paths[draggablePoint.pindex].bezierCurves[draggablePoint.cindex]
11602
+ .getPointByID(draggablePoint.pid)
11603
+ .listeners.fireDragStartEvent(e);
11604
+ else if (draggablePoint.typeName == "vertex")
11605
+ _self.vertices[draggablePoint.vindex].listeners.fireDragStartEvent(e);
11580
11606
  }
11581
11607
  _self.redraw();
11582
11608
  }
@@ -11603,7 +11629,10 @@ class PlotBoilerplate {
11603
11629
  // not this one. So this tab will never receive any [Ctrl-down] events
11604
11630
  // until next keypress; the implication is, that [Ctrl] would still
11605
11631
  // considered to be pressed which is not true.
11606
- if (this.keyHandler.isDown("alt") || this.keyHandler.isDown("spacebar")) {
11632
+ if (this.keyHandler && (this.keyHandler.isDown("alt") || this.keyHandler.isDown("spacebar"))) {
11633
+ if (!this.config.enablePan) {
11634
+ return;
11635
+ }
11607
11636
  _self.setOffset(_self.draw.offset.clone().add(e.params.dragAmount));
11608
11637
  _self.redraw();
11609
11638
  }
@@ -11672,6 +11701,9 @@ class PlotBoilerplate {
11672
11701
  * @return {void}
11673
11702
  **/
11674
11703
  mouseWheelHandler(e) {
11704
+ if (!this.config.enableZoom) {
11705
+ return;
11706
+ }
11675
11707
  var zoomStep = 1.25; // Make configurable?
11676
11708
  // CHANGED replaced _self by this
11677
11709
  const _self = this;
@@ -11811,6 +11843,9 @@ class PlotBoilerplate {
11811
11843
  if (evt.touches.length == 1 && draggedElement) {
11812
11844
  evt.preventDefault();
11813
11845
  evt.stopPropagation();
11846
+ if (!touchDownPos || !touchMovePos) {
11847
+ return;
11848
+ }
11814
11849
  var rel = relPos({ x: evt.touches[0].clientX, y: evt.touches[0].clientY });
11815
11850
  var trans = _self.transformMousePosition(rel.x, rel.y);
11816
11851
  var diff = new Vertex(_self.transformMousePosition(touchMovePos.x, touchMovePos.y)).difference(trans);
@@ -11835,6 +11870,9 @@ class PlotBoilerplate {
11835
11870
  touchMovePos = new Vertex(rel);
11836
11871
  }
11837
11872
  else if (evt.touches.length == 2) {
11873
+ if (!this.config.enablePan) {
11874
+ return;
11875
+ }
11838
11876
  // If at least two fingers touch and move, then change the draw offset (panning).
11839
11877
  evt.preventDefault();
11840
11878
  evt.stopPropagation();
@@ -11847,6 +11885,9 @@ class PlotBoilerplate {
11847
11885
  touchEnd: (evt) => {
11848
11886
  // Note: e.touches.length is 0 here
11849
11887
  if (draggedElement && draggedElement.typeName == "vertex") {
11888
+ if (!touchDownPos) {
11889
+ return;
11890
+ }
11850
11891
  var draggingVertex = _self.vertices[draggedElement.vindex];
11851
11892
  var fakeEvent = {
11852
11893
  isTouchEvent: true,
@@ -11879,9 +11920,17 @@ class PlotBoilerplate {
11879
11920
  multiTouchStartScale = null;
11880
11921
  },
11881
11922
  pinch: (evt) => {
11923
+ if (!this.config.enableZoom) {
11924
+ return;
11925
+ }
11926
+ const touchItem0 = evt.touches.item(0);
11927
+ const touchItem1 = evt.touches.item(1);
11928
+ if (!evt.touches || !multiTouchStartScale || !touchItem0 || !touchItem1) {
11929
+ return;
11930
+ }
11882
11931
  // For pinching there must be at least two touch items
11883
- const fingerA = new Vertex(evt.touches.item(0).clientX, evt.touches.item(0).clientY);
11884
- const fingerB = new Vertex(evt.touches.item(1).clientX, evt.touches.item(1).clientY);
11932
+ const fingerA = new Vertex(touchItem0.clientX, touchItem0.clientY);
11933
+ const fingerB = new Vertex(touchItem1.clientX, touchItem1.clientY);
11885
11934
  const center = new Line(fingerA, fingerB).vertAt(0.5);
11886
11935
  _self.setZoom(multiTouchStartScale.x * evt.zoom, multiTouchStartScale.y * evt.zoom, center);
11887
11936
  _self.redraw();
@@ -12029,8 +12078,10 @@ PlotBoilerplate.utils = {
12029
12078
  **/
12030
12079
  setCSSscale: (element, scaleX, scaleY) => {
12031
12080
  element.style["transform-origin"] = "0 0";
12032
- if (scaleX == 1.0 && scaleY == 1.0)
12033
- element.style.transform = null;
12081
+ if (scaleX == 1.0 && scaleY == 1.0) {
12082
+ // element.style.transform = null;
12083
+ element.style.removeProperty("transform");
12084
+ }
12034
12085
  else
12035
12086
  element.style.transform = "scale(" + scaleX + "," + scaleY + ")";
12036
12087
  },