hyperprop-charting-library 0.1.109 → 0.1.110

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.
@@ -3944,13 +3944,14 @@ function createChart(element, options = {}) {
3944
3944
  }
3945
3945
  return { index: barIndex, price: nearest };
3946
3946
  };
3947
- const drawingPointFromCanvas = (x, y) => {
3947
+ const drawingPointFromCanvas = (x, y, snap = true) => {
3948
3948
  if (!drawState) {
3949
3949
  return null;
3950
3950
  }
3951
3951
  const ratio = clamp((x - drawState.chartLeft) / drawState.chartWidth, 0, 1);
3952
3952
  const rawIndex = drawState.xStart + ratio * drawState.xSpan - 0.5;
3953
- const snapped = applyMagnet(y, rawIndex, priceFromCanvasY(y));
3953
+ const rawPrice = priceFromCanvasY(y);
3954
+ const snapped = snap ? applyMagnet(y, rawIndex, rawPrice) : { index: rawIndex, price: rawPrice };
3954
3955
  const nearestIndex = Math.round(snapped.index);
3955
3956
  const time = getTimeForIndex(nearestIndex);
3956
3957
  return {
@@ -4480,7 +4481,7 @@ function createChart(element, options = {}) {
4480
4481
  if (!drawingDragState) {
4481
4482
  return false;
4482
4483
  }
4483
- const currentPoint = drawingPointFromCanvas(x, y);
4484
+ const currentPoint = drawingPointFromCanvas(x, y, drawingDragState.target === "handle");
4484
4485
  if (!currentPoint) {
4485
4486
  return true;
4486
4487
  }
@@ -4679,7 +4680,7 @@ function createChart(element, options = {}) {
4679
4680
  y: point.y
4680
4681
  });
4681
4682
  if (!drawingHit.drawing.locked) {
4682
- const startCanvasPoint = drawingPointFromCanvas(point.x, point.y);
4683
+ const startCanvasPoint = drawingPointFromCanvas(point.x, point.y, false);
4683
4684
  if (startCanvasPoint) {
4684
4685
  drawingDragState = {
4685
4686
  drawingId: drawingHit.drawing.id,
@@ -3918,13 +3918,14 @@ function createChart(element, options = {}) {
3918
3918
  }
3919
3919
  return { index: barIndex, price: nearest };
3920
3920
  };
3921
- const drawingPointFromCanvas = (x, y) => {
3921
+ const drawingPointFromCanvas = (x, y, snap = true) => {
3922
3922
  if (!drawState) {
3923
3923
  return null;
3924
3924
  }
3925
3925
  const ratio = clamp((x - drawState.chartLeft) / drawState.chartWidth, 0, 1);
3926
3926
  const rawIndex = drawState.xStart + ratio * drawState.xSpan - 0.5;
3927
- const snapped = applyMagnet(y, rawIndex, priceFromCanvasY(y));
3927
+ const rawPrice = priceFromCanvasY(y);
3928
+ const snapped = snap ? applyMagnet(y, rawIndex, rawPrice) : { index: rawIndex, price: rawPrice };
3928
3929
  const nearestIndex = Math.round(snapped.index);
3929
3930
  const time = getTimeForIndex(nearestIndex);
3930
3931
  return {
@@ -4454,7 +4455,7 @@ function createChart(element, options = {}) {
4454
4455
  if (!drawingDragState) {
4455
4456
  return false;
4456
4457
  }
4457
- const currentPoint = drawingPointFromCanvas(x, y);
4458
+ const currentPoint = drawingPointFromCanvas(x, y, drawingDragState.target === "handle");
4458
4459
  if (!currentPoint) {
4459
4460
  return true;
4460
4461
  }
@@ -4653,7 +4654,7 @@ function createChart(element, options = {}) {
4653
4654
  y: point.y
4654
4655
  });
4655
4656
  if (!drawingHit.drawing.locked) {
4656
- const startCanvasPoint = drawingPointFromCanvas(point.x, point.y);
4657
+ const startCanvasPoint = drawingPointFromCanvas(point.x, point.y, false);
4657
4658
  if (startCanvasPoint) {
4658
4659
  drawingDragState = {
4659
4660
  drawingId: drawingHit.drawing.id,
package/dist/index.cjs CHANGED
@@ -3944,13 +3944,14 @@ function createChart(element, options = {}) {
3944
3944
  }
3945
3945
  return { index: barIndex, price: nearest };
3946
3946
  };
3947
- const drawingPointFromCanvas = (x, y) => {
3947
+ const drawingPointFromCanvas = (x, y, snap = true) => {
3948
3948
  if (!drawState) {
3949
3949
  return null;
3950
3950
  }
3951
3951
  const ratio = clamp((x - drawState.chartLeft) / drawState.chartWidth, 0, 1);
3952
3952
  const rawIndex = drawState.xStart + ratio * drawState.xSpan - 0.5;
3953
- const snapped = applyMagnet(y, rawIndex, priceFromCanvasY(y));
3953
+ const rawPrice = priceFromCanvasY(y);
3954
+ const snapped = snap ? applyMagnet(y, rawIndex, rawPrice) : { index: rawIndex, price: rawPrice };
3954
3955
  const nearestIndex = Math.round(snapped.index);
3955
3956
  const time = getTimeForIndex(nearestIndex);
3956
3957
  return {
@@ -4480,7 +4481,7 @@ function createChart(element, options = {}) {
4480
4481
  if (!drawingDragState) {
4481
4482
  return false;
4482
4483
  }
4483
- const currentPoint = drawingPointFromCanvas(x, y);
4484
+ const currentPoint = drawingPointFromCanvas(x, y, drawingDragState.target === "handle");
4484
4485
  if (!currentPoint) {
4485
4486
  return true;
4486
4487
  }
@@ -4679,7 +4680,7 @@ function createChart(element, options = {}) {
4679
4680
  y: point.y
4680
4681
  });
4681
4682
  if (!drawingHit.drawing.locked) {
4682
- const startCanvasPoint = drawingPointFromCanvas(point.x, point.y);
4683
+ const startCanvasPoint = drawingPointFromCanvas(point.x, point.y, false);
4683
4684
  if (startCanvasPoint) {
4684
4685
  drawingDragState = {
4685
4686
  drawingId: drawingHit.drawing.id,
package/dist/index.js CHANGED
@@ -3918,13 +3918,14 @@ function createChart(element, options = {}) {
3918
3918
  }
3919
3919
  return { index: barIndex, price: nearest };
3920
3920
  };
3921
- const drawingPointFromCanvas = (x, y) => {
3921
+ const drawingPointFromCanvas = (x, y, snap = true) => {
3922
3922
  if (!drawState) {
3923
3923
  return null;
3924
3924
  }
3925
3925
  const ratio = clamp((x - drawState.chartLeft) / drawState.chartWidth, 0, 1);
3926
3926
  const rawIndex = drawState.xStart + ratio * drawState.xSpan - 0.5;
3927
- const snapped = applyMagnet(y, rawIndex, priceFromCanvasY(y));
3927
+ const rawPrice = priceFromCanvasY(y);
3928
+ const snapped = snap ? applyMagnet(y, rawIndex, rawPrice) : { index: rawIndex, price: rawPrice };
3928
3929
  const nearestIndex = Math.round(snapped.index);
3929
3930
  const time = getTimeForIndex(nearestIndex);
3930
3931
  return {
@@ -4454,7 +4455,7 @@ function createChart(element, options = {}) {
4454
4455
  if (!drawingDragState) {
4455
4456
  return false;
4456
4457
  }
4457
- const currentPoint = drawingPointFromCanvas(x, y);
4458
+ const currentPoint = drawingPointFromCanvas(x, y, drawingDragState.target === "handle");
4458
4459
  if (!currentPoint) {
4459
4460
  return true;
4460
4461
  }
@@ -4653,7 +4654,7 @@ function createChart(element, options = {}) {
4653
4654
  y: point.y
4654
4655
  });
4655
4656
  if (!drawingHit.drawing.locked) {
4656
- const startCanvasPoint = drawingPointFromCanvas(point.x, point.y);
4657
+ const startCanvasPoint = drawingPointFromCanvas(point.x, point.y, false);
4657
4658
  if (startCanvasPoint) {
4658
4659
  drawingDragState = {
4659
4660
  drawingId: drawingHit.drawing.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.109",
3
+ "version": "0.1.110",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",