hyperprop-charting-library 0.1.91 → 0.1.92

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.
@@ -4855,6 +4855,22 @@ function createChart(element, options = {}) {
4855
4855
  canvas.addEventListener("wheel", onWheel, { passive: false });
4856
4856
  canvas.addEventListener("dblclick", onDoubleClick);
4857
4857
  canvas.addEventListener("contextmenu", onContextMenu);
4858
+ const onModifierKeyChange = (event) => {
4859
+ const active = event.metaKey || event.ctrlKey;
4860
+ if (active !== magnetModifierActive) {
4861
+ magnetModifierActive = active;
4862
+ if (draftDrawing) draw();
4863
+ }
4864
+ };
4865
+ const onWindowBlurMagnet = () => {
4866
+ magnetModifierActive = false;
4867
+ };
4868
+ const hasWindow = typeof window !== "undefined";
4869
+ if (hasWindow) {
4870
+ window.addEventListener("keydown", onModifierKeyChange);
4871
+ window.addEventListener("keyup", onModifierKeyChange);
4872
+ window.addEventListener("blur", onWindowBlurMagnet);
4873
+ }
4858
4874
  const updateOptions = (nextOptions) => {
4859
4875
  const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
4860
4876
  const previousWidth = width;
@@ -5171,6 +5187,11 @@ function createChart(element, options = {}) {
5171
5187
  canvas.removeEventListener("wheel", onWheel);
5172
5188
  canvas.removeEventListener("dblclick", onDoubleClick);
5173
5189
  canvas.removeEventListener("contextmenu", onContextMenu);
5190
+ if (hasWindow) {
5191
+ window.removeEventListener("keydown", onModifierKeyChange);
5192
+ window.removeEventListener("keyup", onModifierKeyChange);
5193
+ window.removeEventListener("blur", onWindowBlurMagnet);
5194
+ }
5174
5195
  element.innerHTML = "";
5175
5196
  };
5176
5197
  draw();
@@ -4829,6 +4829,22 @@ function createChart(element, options = {}) {
4829
4829
  canvas.addEventListener("wheel", onWheel, { passive: false });
4830
4830
  canvas.addEventListener("dblclick", onDoubleClick);
4831
4831
  canvas.addEventListener("contextmenu", onContextMenu);
4832
+ const onModifierKeyChange = (event) => {
4833
+ const active = event.metaKey || event.ctrlKey;
4834
+ if (active !== magnetModifierActive) {
4835
+ magnetModifierActive = active;
4836
+ if (draftDrawing) draw();
4837
+ }
4838
+ };
4839
+ const onWindowBlurMagnet = () => {
4840
+ magnetModifierActive = false;
4841
+ };
4842
+ const hasWindow = typeof window !== "undefined";
4843
+ if (hasWindow) {
4844
+ window.addEventListener("keydown", onModifierKeyChange);
4845
+ window.addEventListener("keyup", onModifierKeyChange);
4846
+ window.addEventListener("blur", onWindowBlurMagnet);
4847
+ }
4832
4848
  const updateOptions = (nextOptions) => {
4833
4849
  const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
4834
4850
  const previousWidth = width;
@@ -5145,6 +5161,11 @@ function createChart(element, options = {}) {
5145
5161
  canvas.removeEventListener("wheel", onWheel);
5146
5162
  canvas.removeEventListener("dblclick", onDoubleClick);
5147
5163
  canvas.removeEventListener("contextmenu", onContextMenu);
5164
+ if (hasWindow) {
5165
+ window.removeEventListener("keydown", onModifierKeyChange);
5166
+ window.removeEventListener("keyup", onModifierKeyChange);
5167
+ window.removeEventListener("blur", onWindowBlurMagnet);
5168
+ }
5148
5169
  element.innerHTML = "";
5149
5170
  };
5150
5171
  draw();
package/dist/index.cjs CHANGED
@@ -4855,6 +4855,22 @@ function createChart(element, options = {}) {
4855
4855
  canvas.addEventListener("wheel", onWheel, { passive: false });
4856
4856
  canvas.addEventListener("dblclick", onDoubleClick);
4857
4857
  canvas.addEventListener("contextmenu", onContextMenu);
4858
+ const onModifierKeyChange = (event) => {
4859
+ const active = event.metaKey || event.ctrlKey;
4860
+ if (active !== magnetModifierActive) {
4861
+ magnetModifierActive = active;
4862
+ if (draftDrawing) draw();
4863
+ }
4864
+ };
4865
+ const onWindowBlurMagnet = () => {
4866
+ magnetModifierActive = false;
4867
+ };
4868
+ const hasWindow = typeof window !== "undefined";
4869
+ if (hasWindow) {
4870
+ window.addEventListener("keydown", onModifierKeyChange);
4871
+ window.addEventListener("keyup", onModifierKeyChange);
4872
+ window.addEventListener("blur", onWindowBlurMagnet);
4873
+ }
4858
4874
  const updateOptions = (nextOptions) => {
4859
4875
  const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
4860
4876
  const previousWidth = width;
@@ -5171,6 +5187,11 @@ function createChart(element, options = {}) {
5171
5187
  canvas.removeEventListener("wheel", onWheel);
5172
5188
  canvas.removeEventListener("dblclick", onDoubleClick);
5173
5189
  canvas.removeEventListener("contextmenu", onContextMenu);
5190
+ if (hasWindow) {
5191
+ window.removeEventListener("keydown", onModifierKeyChange);
5192
+ window.removeEventListener("keyup", onModifierKeyChange);
5193
+ window.removeEventListener("blur", onWindowBlurMagnet);
5194
+ }
5174
5195
  element.innerHTML = "";
5175
5196
  };
5176
5197
  draw();
package/dist/index.js CHANGED
@@ -4829,6 +4829,22 @@ function createChart(element, options = {}) {
4829
4829
  canvas.addEventListener("wheel", onWheel, { passive: false });
4830
4830
  canvas.addEventListener("dblclick", onDoubleClick);
4831
4831
  canvas.addEventListener("contextmenu", onContextMenu);
4832
+ const onModifierKeyChange = (event) => {
4833
+ const active = event.metaKey || event.ctrlKey;
4834
+ if (active !== magnetModifierActive) {
4835
+ magnetModifierActive = active;
4836
+ if (draftDrawing) draw();
4837
+ }
4838
+ };
4839
+ const onWindowBlurMagnet = () => {
4840
+ magnetModifierActive = false;
4841
+ };
4842
+ const hasWindow = typeof window !== "undefined";
4843
+ if (hasWindow) {
4844
+ window.addEventListener("keydown", onModifierKeyChange);
4845
+ window.addEventListener("keyup", onModifierKeyChange);
4846
+ window.addEventListener("blur", onWindowBlurMagnet);
4847
+ }
4832
4848
  const updateOptions = (nextOptions) => {
4833
4849
  const wasTickerSmoothingEnabled = mergedOptions.tickerLine?.smoothing ?? false;
4834
4850
  const previousWidth = width;
@@ -5145,6 +5161,11 @@ function createChart(element, options = {}) {
5145
5161
  canvas.removeEventListener("wheel", onWheel);
5146
5162
  canvas.removeEventListener("dblclick", onDoubleClick);
5147
5163
  canvas.removeEventListener("contextmenu", onContextMenu);
5164
+ if (hasWindow) {
5165
+ window.removeEventListener("keydown", onModifierKeyChange);
5166
+ window.removeEventListener("keyup", onModifierKeyChange);
5167
+ window.removeEventListener("blur", onWindowBlurMagnet);
5168
+ }
5148
5169
  element.innerHTML = "";
5149
5170
  };
5150
5171
  draw();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.91",
3
+ "version": "0.1.92",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",