awesome-timeline-react 0.4.3 → 0.5.0

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/dist/index.mjs CHANGED
@@ -434,6 +434,7 @@ var DEFAULT_THEME = {
434
434
  eventStroke: "#000000",
435
435
  eventTextColor: "#000000",
436
436
  staticEventFill: "#e0e0e0",
437
+ overlapStripeColor: "rgba(15,23,42,0.6)",
437
438
  gridColor: "#e4dcdc",
438
439
  timeBarBorder: "yellow",
439
440
  timeBarTextColor: "white",
@@ -944,6 +945,43 @@ var defaultDrawEvent = (ctx, event, rect, view, font, barRadius) => {
944
945
  ctx.restore();
945
946
  }
946
947
  };
948
+ var STRIPE_STEP = 6;
949
+ var STRIPE_WIDTH = 2;
950
+ var STRIPE_WASH_ALPHA = 0.18;
951
+ var paintOverlapStripes = (ctx, event, rect, rowStatics, windowStart, tick, color) => {
952
+ const barRight = rect.x + rect.width;
953
+ for (const band of rowStatics) {
954
+ const overlapStart = Math.max(event.startTime, band.startTime);
955
+ const overlapEnd = Math.min(event.endTime, band.endTime);
956
+ if (overlapEnd <= overlapStart) continue;
957
+ const x0 = Math.max(timeToX(overlapStart, windowStart, tick), rect.x);
958
+ const x1 = Math.min(
959
+ timeToX(overlapStart, windowStart, tick) + timeToWidth(overlapStart, overlapEnd, tick),
960
+ barRight
961
+ );
962
+ const width = x1 - x0;
963
+ if (width <= 0) continue;
964
+ const { y, height } = rect;
965
+ ctx.save();
966
+ ctx.beginPath();
967
+ ctx.rect(x0, y, width, height);
968
+ ctx.clip();
969
+ const baseAlpha = ctx.globalAlpha;
970
+ ctx.globalAlpha = baseAlpha * STRIPE_WASH_ALPHA;
971
+ ctx.fillStyle = color;
972
+ ctx.fillRect(x0, y, width, height);
973
+ ctx.globalAlpha = baseAlpha;
974
+ ctx.strokeStyle = color;
975
+ ctx.lineWidth = STRIPE_WIDTH;
976
+ for (let sx = x0 - height; sx < x1; sx += STRIPE_STEP) {
977
+ ctx.beginPath();
978
+ ctx.moveTo(sx, y + height);
979
+ ctx.lineTo(sx + height, y);
980
+ ctx.stroke();
981
+ }
982
+ ctx.restore();
983
+ }
984
+ };
947
985
  var drawEvents = (ctx, view, scene, font, animator) => {
948
986
  var _a;
949
987
  if (view.tick === null) return;
@@ -956,7 +994,7 @@ var drawEvents = (ctx, view, scene, font, animator) => {
956
994
  const selectedIds = view.selectedEventIds;
957
995
  const hasSelection = selectedIds.size > 0;
958
996
  const deferred = [];
959
- const paintEvent = (event, rect, state, opts) => {
997
+ const paintEvent = (event, rect, state, opts, rowStatics) => {
960
998
  var _a2, _b, _c, _d, _e;
961
999
  ctx.save();
962
1000
  ctx.globalAlpha = 1;
@@ -973,6 +1011,17 @@ var drawEvents = (ctx, view, scene, font, animator) => {
973
1011
  if (!drawn) {
974
1012
  defaultDrawEvent(ctx, event, rect, view, font, geometry.barRadius);
975
1013
  }
1014
+ if (view.stripeOverlap && rowStatics.length > 0) {
1015
+ paintOverlapStripes(
1016
+ ctx,
1017
+ event,
1018
+ rect,
1019
+ rowStatics,
1020
+ windowStart,
1021
+ tick,
1022
+ view.theme.overlapStripeColor
1023
+ );
1024
+ }
976
1025
  if (canResizeEvent(event, view.eventsResize)) {
977
1026
  const alpha = animator.handleAlpha(
978
1027
  event.id,
@@ -998,11 +1047,12 @@ var drawEvents = (ctx, view, scene, font, animator) => {
998
1047
  if (rowY + rowHeight < 0) continue;
999
1048
  if (rowY > view.height) break;
1000
1049
  const lanes = scene.getLanes(rowId, windowStart, windowEnd);
1001
- for (const event of cullToWindow(
1050
+ const rowStatics = cullToWindow(
1002
1051
  scene.getRowStaticEvents(rowId),
1003
1052
  windowStart,
1004
1053
  windowEnd
1005
- )) {
1054
+ );
1055
+ for (const event of rowStatics) {
1006
1056
  const x = timeToX(event.startTime, windowStart, tick);
1007
1057
  const width = timeToWidth(event.startTime, event.endTime, tick);
1008
1058
  ctx.fillStyle = view.theme.staticEventFill;
@@ -1047,10 +1097,16 @@ var drawEvents = (ctx, view, scene, font, animator) => {
1047
1097
  };
1048
1098
  if (selected) {
1049
1099
  deferred.push(
1050
- () => paintEvent(event, rect, state, { dim: false, elevate: true })
1100
+ () => paintEvent(event, rect, state, { dim: false, elevate: true }, rowStatics)
1051
1101
  );
1052
1102
  } else {
1053
- paintEvent(event, rect, state, { dim: hasSelection, elevate: false });
1103
+ paintEvent(
1104
+ event,
1105
+ rect,
1106
+ state,
1107
+ { dim: hasSelection, elevate: false },
1108
+ rowStatics
1109
+ );
1054
1110
  }
1055
1111
  }
1056
1112
  }
@@ -1073,6 +1129,7 @@ var TimelineRenderer = class {
1073
1129
  theme: DEFAULT_THEME,
1074
1130
  drawEvent: void 0,
1075
1131
  eventsResize: true,
1132
+ stripeOverlap: false,
1076
1133
  hoveredEventId: null,
1077
1134
  draggedEventId: null,
1078
1135
  resizePreview: null,
@@ -1948,6 +2005,7 @@ var CanvasBoard = forwardRef2(
1948
2005
  onEventClick,
1949
2006
  onEventHover,
1950
2007
  eventsResize,
2008
+ stripeOverlap,
1951
2009
  panZoom,
1952
2010
  animations,
1953
2011
  selectable,
@@ -1986,7 +2044,8 @@ var CanvasBoard = forwardRef2(
1986
2044
  cellWidth,
1987
2045
  theme,
1988
2046
  drawEvent,
1989
- eventsResize
2047
+ eventsResize,
2048
+ stripeOverlap
1990
2049
  });
1991
2050
  }, [
1992
2051
  windowTime,
@@ -1995,6 +2054,7 @@ var CanvasBoard = forwardRef2(
1995
2054
  theme,
1996
2055
  drawEvent,
1997
2056
  eventsResize,
2057
+ stripeOverlap,
1998
2058
  animations,
1999
2059
  rendererRef
2000
2060
  ]);
@@ -2721,6 +2781,7 @@ var Timeline = forwardRef3(
2721
2781
  additionalClassNames,
2722
2782
  showRTIndicator = true,
2723
2783
  eventsResize = true,
2784
+ stripeOverlap = false,
2724
2785
  eventPromptTemplate,
2725
2786
  showEventPrompt = true,
2726
2787
  panZoom,
@@ -2962,6 +3023,7 @@ var Timeline = forwardRef3(
2962
3023
  onEventClick,
2963
3024
  onEventHover,
2964
3025
  eventsResize,
3026
+ stripeOverlap,
2965
3027
  panZoom,
2966
3028
  animations: resolvedAnimations,
2967
3029
  selectable,