histropediajs 1.5.0 → 1.5.1

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- HistropediaJS v1.5.0 | Histropedia Ltd. (c) 2026 | https://js.histropedia.com
2
+ HistropediaJS v1.5.1 | Histropedia Ltd. (c) 2026 | https://js.histropedia.com
3
3
  Use of this software is subject to our End User Licence Agreement: https://js.histropedia.com/licence.html
4
4
  */
5
5
  var __defProp = Object.defineProperty;
@@ -6801,6 +6801,20 @@ function getElasticOverflowDays(timeline, overflowDays) {
6801
6801
  return resistedPixels / pixelsPerDay;
6802
6802
  }
6803
6803
  __name(getElasticOverflowDays, "getElasticOverflowDays");
6804
+ function getUnresistedElasticOverflowDays(timeline, overflowDays) {
6805
+ const pixelsPerDay = getPixelsPerDay(timeline);
6806
+ if (!pixelsPerDay || !Number.isFinite(overflowDays) || overflowDays <= 0) {
6807
+ return 0;
6808
+ }
6809
+ const width = Math.max(1, timeline.getWidth());
6810
+ const maxElasticPixels = Math.max(32, width * 0.22);
6811
+ const resistedPixels = overflowDays * pixelsPerDay;
6812
+ if (resistedPixels >= maxElasticPixels) {
6813
+ return Number.MAX_SAFE_INTEGER / pixelsPerDay;
6814
+ }
6815
+ return maxElasticPixels * resistedPixels / (maxElasticPixels - resistedPixels) / pixelsPerDay;
6816
+ }
6817
+ __name(getUnresistedElasticOverflowDays, "getUnresistedElasticOverflowDays");
6804
6818
  function setElasticBoundedViewportStartDay(timeline, targetStartDayNumber, viewportSpanDays) {
6805
6819
  const bounds = getTimelineDateBounds(timeline);
6806
6820
  let nextStartDayNumber = targetStartDayNumber;
@@ -7434,10 +7448,7 @@ Timeline.prototype.enableDragging = /* @__PURE__ */ __name(function enableDraggi
7434
7448
  __name(onPointerMove, "onPointerMove");
7435
7449
  function onPointerEnd(evt, tracker) {
7436
7450
  if (me.isPinching && tracker.list.length < 2) {
7437
- if (tracker.list.length === 1) {
7438
- const primary = getPrimary(tracker);
7439
- me.dragStartX = primary.x;
7440
- }
7451
+ const remainingPointer = tracker.list.length === 1 ? getPrimary(tracker) : null;
7441
7452
  const endScale = pinch.scale || 1;
7442
7453
  const actualEndZoom = me.timescaleManager.zoom;
7443
7454
  const endTotalZoomDelta = actualEndZoom - pinch.initial.zoom;
@@ -7459,9 +7470,18 @@ Timeline.prototype.enableDragging = /* @__PURE__ */ __name(function enableDraggi
7459
7470
  }),
7460
7471
  evt
7461
7472
  );
7462
- me.settleDateBounds?.();
7463
- if (!me.isPanning) {
7464
- me._flushTimelineStateChange?.();
7473
+ if (remainingPointer) {
7474
+ if (me.isDragging) {
7475
+ me.resetDragTracking(remainingPointer);
7476
+ }
7477
+ } else if (me.isDragging) {
7478
+ me.resetDragTracking(getPoint(evt));
7479
+ me.endDragging(evt);
7480
+ } else {
7481
+ me.settleDateBounds?.();
7482
+ if (!me.isPanning) {
7483
+ me._flushTimelineStateChange?.();
7484
+ }
7465
7485
  }
7466
7486
  return;
7467
7487
  }
@@ -7523,31 +7543,43 @@ Timeline.prototype.startDragging = /* @__PURE__ */ __name(function startDragging
7523
7543
  this.stopZoomAnimation?.();
7524
7544
  this.isDragging = true;
7525
7545
  const page = getPoint(evt);
7546
+ Timeline.prototype.resetDragTracking.call(this, page);
7547
+ this.trigger(
7548
+ "viewport-drag-start",
7549
+ makeViewportDragPayload({
7550
+ startToken: this.timescaleManager.startToken,
7551
+ offsetX: this.repositionWindow
7552
+ }),
7553
+ evt
7554
+ );
7555
+ }, "startDragging");
7556
+ Timeline.prototype.resetDragTracking = /* @__PURE__ */ __name(function resetDragTracking(page) {
7526
7557
  this.dragOrigin = { left: page.x, top: page.y };
7527
7558
  this.dragStartX = page.x;
7528
7559
  this.dragStartY = page.y;
7529
7560
  this.dragMomentumSamples = [{ time: Date.now(), x: page.x }];
7530
7561
  this.dragDateBoundsState = null;
7531
7562
  const bounds = getTimelineDateBounds(this);
7532
- const pixelsPerDay = getPixelsPerDay(this);
7533
- if (bounds?.overflow === "elastic" && pixelsPerDay) {
7534
- const leftDayNumber = getDayNumberAtPixel(this, 0);
7535
- const rightDayNumber = getDayNumberAtPixel(this, this.getWidth());
7563
+ if (bounds?.overflow === "elastic") {
7564
+ const pixelsPerDay = getPixelsPerDay(this);
7565
+ if (!pixelsPerDay) {
7566
+ return;
7567
+ }
7568
+ const viewport = getViewportDayRange(this);
7569
+ const viewportSpanDays = viewport.end - viewport.start;
7570
+ let leftDayNumber = viewport.start;
7571
+ if (bounds.minDay != null && viewport.start < bounds.minDay) {
7572
+ leftDayNumber = bounds.minDay - getUnresistedElasticOverflowDays(this, bounds.minDay - viewport.start);
7573
+ } else if (bounds.maxDay != null && viewport.end > bounds.maxDay) {
7574
+ leftDayNumber = bounds.maxDay + getUnresistedElasticOverflowDays(this, viewport.end - bounds.maxDay) - viewportSpanDays;
7575
+ }
7536
7576
  this.dragDateBoundsState = {
7537
7577
  leftDayNumber,
7538
7578
  pixelsPerDay,
7539
- viewportSpanDays: rightDayNumber - leftDayNumber
7579
+ viewportSpanDays
7540
7580
  };
7541
7581
  }
7542
- this.trigger(
7543
- "viewport-drag-start",
7544
- makeViewportDragPayload({
7545
- startToken: this.timescaleManager.startToken,
7546
- offsetX: this.repositionWindow
7547
- }),
7548
- evt
7549
- );
7550
- }, "startDragging");
7582
+ }, "resetDragTracking");
7551
7583
  Timeline.prototype.endDragging = /* @__PURE__ */ __name(function endDragging(evt) {
7552
7584
  this.isDragging = false;
7553
7585
  const page = getPoint(evt);
@@ -1,5 +1,5 @@
1
1
  /*!
2
- HistropediaJS v1.5.0 | Histropedia Ltd. (c) 2026 | https://js.histropedia.com
2
+ HistropediaJS v1.5.1 | Histropedia Ltd. (c) 2026 | https://js.histropedia.com
3
3
  Use of this software is subject to our End User Licence Agreement: https://js.histropedia.com/licence.html
4
4
  */
5
5
  (function(global, factory) {
@@ -6849,6 +6849,20 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
6849
6849
  return resistedPixels / pixelsPerDay;
6850
6850
  }
6851
6851
  __name(getElasticOverflowDays, "getElasticOverflowDays");
6852
+ function getUnresistedElasticOverflowDays(timeline, overflowDays) {
6853
+ const pixelsPerDay = getPixelsPerDay(timeline);
6854
+ if (!pixelsPerDay || !Number.isFinite(overflowDays) || overflowDays <= 0) {
6855
+ return 0;
6856
+ }
6857
+ const width = Math.max(1, timeline.getWidth());
6858
+ const maxElasticPixels = Math.max(32, width * 0.22);
6859
+ const resistedPixels = overflowDays * pixelsPerDay;
6860
+ if (resistedPixels >= maxElasticPixels) {
6861
+ return Number.MAX_SAFE_INTEGER / pixelsPerDay;
6862
+ }
6863
+ return maxElasticPixels * resistedPixels / (maxElasticPixels - resistedPixels) / pixelsPerDay;
6864
+ }
6865
+ __name(getUnresistedElasticOverflowDays, "getUnresistedElasticOverflowDays");
6852
6866
  function setElasticBoundedViewportStartDay(timeline, targetStartDayNumber, viewportSpanDays) {
6853
6867
  const bounds = getTimelineDateBounds(timeline);
6854
6868
  let nextStartDayNumber = targetStartDayNumber;
@@ -7488,10 +7502,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7488
7502
  function onPointerEnd(evt, tracker) {
7489
7503
  var _a, _b, _c;
7490
7504
  if (me.isPinching && tracker.list.length < 2) {
7491
- if (tracker.list.length === 1) {
7492
- const primary = getPrimary(tracker);
7493
- me.dragStartX = primary.x;
7494
- }
7505
+ const remainingPointer = tracker.list.length === 1 ? getPrimary(tracker) : null;
7495
7506
  const endScale = pinch.scale || 1;
7496
7507
  const actualEndZoom = me.timescaleManager.zoom;
7497
7508
  const endTotalZoomDelta = actualEndZoom - pinch.initial.zoom;
@@ -7513,9 +7524,18 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7513
7524
  }),
7514
7525
  evt
7515
7526
  );
7516
- (_a = me.settleDateBounds) == null ? void 0 : _a.call(me);
7517
- if (!me.isPanning) {
7518
- (_b = me._flushTimelineStateChange) == null ? void 0 : _b.call(me);
7527
+ if (remainingPointer) {
7528
+ if (me.isDragging) {
7529
+ me.resetDragTracking(remainingPointer);
7530
+ }
7531
+ } else if (me.isDragging) {
7532
+ me.resetDragTracking(getPoint(evt));
7533
+ me.endDragging(evt);
7534
+ } else {
7535
+ (_a = me.settleDateBounds) == null ? void 0 : _a.call(me);
7536
+ if (!me.isPanning) {
7537
+ (_b = me._flushTimelineStateChange) == null ? void 0 : _b.call(me);
7538
+ }
7519
7539
  }
7520
7540
  return;
7521
7541
  }
@@ -7578,31 +7598,43 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7578
7598
  (_b = this.stopZoomAnimation) == null ? void 0 : _b.call(this);
7579
7599
  this.isDragging = true;
7580
7600
  const page = getPoint(evt);
7601
+ Timeline.prototype.resetDragTracking.call(this, page);
7602
+ this.trigger(
7603
+ "viewport-drag-start",
7604
+ makeViewportDragPayload({
7605
+ startToken: this.timescaleManager.startToken,
7606
+ offsetX: this.repositionWindow
7607
+ }),
7608
+ evt
7609
+ );
7610
+ }, "startDragging");
7611
+ Timeline.prototype.resetDragTracking = /* @__PURE__ */ __name(function resetDragTracking(page) {
7581
7612
  this.dragOrigin = { left: page.x, top: page.y };
7582
7613
  this.dragStartX = page.x;
7583
7614
  this.dragStartY = page.y;
7584
7615
  this.dragMomentumSamples = [{ time: Date.now(), x: page.x }];
7585
7616
  this.dragDateBoundsState = null;
7586
7617
  const bounds = getTimelineDateBounds(this);
7587
- const pixelsPerDay = getPixelsPerDay(this);
7588
- if ((bounds == null ? void 0 : bounds.overflow) === "elastic" && pixelsPerDay) {
7589
- const leftDayNumber = getDayNumberAtPixel(this, 0);
7590
- const rightDayNumber = getDayNumberAtPixel(this, this.getWidth());
7618
+ if ((bounds == null ? void 0 : bounds.overflow) === "elastic") {
7619
+ const pixelsPerDay = getPixelsPerDay(this);
7620
+ if (!pixelsPerDay) {
7621
+ return;
7622
+ }
7623
+ const viewport = getViewportDayRange(this);
7624
+ const viewportSpanDays = viewport.end - viewport.start;
7625
+ let leftDayNumber = viewport.start;
7626
+ if (bounds.minDay != null && viewport.start < bounds.minDay) {
7627
+ leftDayNumber = bounds.minDay - getUnresistedElasticOverflowDays(this, bounds.minDay - viewport.start);
7628
+ } else if (bounds.maxDay != null && viewport.end > bounds.maxDay) {
7629
+ leftDayNumber = bounds.maxDay + getUnresistedElasticOverflowDays(this, viewport.end - bounds.maxDay) - viewportSpanDays;
7630
+ }
7591
7631
  this.dragDateBoundsState = {
7592
7632
  leftDayNumber,
7593
7633
  pixelsPerDay,
7594
- viewportSpanDays: rightDayNumber - leftDayNumber
7634
+ viewportSpanDays
7595
7635
  };
7596
7636
  }
7597
- this.trigger(
7598
- "viewport-drag-start",
7599
- makeViewportDragPayload({
7600
- startToken: this.timescaleManager.startToken,
7601
- offsetX: this.repositionWindow
7602
- }),
7603
- evt
7604
- );
7605
- }, "startDragging");
7637
+ }, "resetDragTracking");
7606
7638
  Timeline.prototype.endDragging = /* @__PURE__ */ __name(function endDragging(evt) {
7607
7639
  var _a, _b, _c;
7608
7640
  this.isDragging = false;