sense-react-timeline-editor 1.0.15 → 1.0.17

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.
@@ -68,6 +68,7 @@ export declare const useRowDrag: (options: UseRowDragOptions) => {
68
68
  lastWidth?: number;
69
69
  lastTop?: number;
70
70
  lastHeight?: number;
71
+ gap?: number;
71
72
  }) => void;
72
73
  onDragEnd: (params?: {
73
74
  actionId: string;
package/dist/index.esm.js CHANGED
@@ -2000,7 +2000,7 @@ var Cursor = function Cursor(_ref) {
2000
2000
  }) - scrollLeft);
2001
2001
  }
2002
2002
  }, [cursorTime, startLeft, scaleWidth, scale, scrollLeft], {
2003
- wait: 800
2003
+ wait: 10
2004
2004
  });
2005
2005
  var clientHeight = ((_document$querySelect = document.querySelector("#time-editor-container")) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.clientHeight) || 0;
2006
2006
  return /*#__PURE__*/React.createElement(RowDnd, {
@@ -2168,6 +2168,12 @@ var EditActionO = function EditActionO(_ref) {
2168
2168
  _action$movable = action.movable,
2169
2169
  movable = _action$movable === void 0 ? true : _action$movable,
2170
2170
  effectId = action.effectId;
2171
+ var originStart = start;
2172
+ parserTimeToPixel(originStart, {
2173
+ startLeft: startLeft,
2174
+ scale: scale,
2175
+ scaleWidth: scaleWidth
2176
+ });
2171
2177
  var handleDeltaScrollTop = function handleDeltaScrollTop(delta) {
2172
2178
  if (containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) {
2173
2179
  containerRef.current.scrollTop += delta * 2;
@@ -2294,6 +2300,16 @@ var EditActionO = function EditActionO(_ref) {
2294
2300
  }),
2295
2301
  _start = _parserTransformToTim.start,
2296
2302
  _end = _parserTransformToTim.end;
2303
+ var g1 = parserTimeToPixel(originStart, {
2304
+ startLeft: startLeft,
2305
+ scale: scale,
2306
+ scaleWidth: scaleWidth
2307
+ });
2308
+ var g2 = parserTimeToPixel(_start, {
2309
+ startLeft: startLeft,
2310
+ scale: scale,
2311
+ scaleWidth: scaleWidth
2312
+ });
2297
2313
  var result = onActionMoving(_objectSpread2({
2298
2314
  action: action,
2299
2315
  row: row,
@@ -2301,7 +2317,8 @@ var EditActionO = function EditActionO(_ref) {
2301
2317
  end: _end,
2302
2318
  left: left,
2303
2319
  width: width,
2304
- top: top
2320
+ top: top,
2321
+ offsetX: g2 - g1
2305
2322
  }, args));
2306
2323
  if (result === false) return false;
2307
2324
  }
@@ -2869,17 +2886,17 @@ var EditActionO = function EditActionO(_ref) {
2869
2886
  style: {
2870
2887
  height: rowHeight
2871
2888
  }
2872
- }, getActionRender && getActionRender(nowAction, nowRow), flexible && /*#__PURE__*/React.createElement("div", {
2889
+ }, getActionRender && getActionRender(nowAction, nowRow), flexible && (/*#__PURE__*/React.createElement("div", {
2873
2890
  className: prefix('action-left-stretch')
2874
2891
  }, /*#__PURE__*/React.createElement("img", {
2875
2892
  src: stretchIcon,
2876
2893
  alt: ""
2877
- })), flexible && /*#__PURE__*/React.createElement("div", {
2894
+ }))), flexible && (/*#__PURE__*/React.createElement("div", {
2878
2895
  className: prefix('action-right-stretch')
2879
2896
  }, /*#__PURE__*/React.createElement("img", {
2880
2897
  src: stretchIcon,
2881
2898
  alt: ""
2882
- }))));
2899
+ })))));
2883
2900
  };
2884
2901
  var EditAction = /*#__PURE__*/React.memo(EditActionO);
2885
2902
 
@@ -3367,7 +3384,7 @@ var useRowDrag = function useRowDrag(options) {
3367
3384
  var selectedEls = getSelectedActionEls();
3368
3385
  if (selectedEls.length === 0) return;
3369
3386
  // 更新偏移量
3370
- state.offsetX = (state.offsetX || 0) + dx;
3387
+ state.offsetX = params.gap;
3371
3388
  state.offsetY = (state.offsetY || 0) + dy;
3372
3389
  // 遍历所有选中的元素,同步移动
3373
3390
  selectedEls.forEach(function (el) {
@@ -3377,8 +3394,8 @@ var useRowDrag = function useRowDrag(options) {
3377
3394
  var initialPos = state.initialElementPositions.get(elActionId);
3378
3395
  if (!initialPos) return;
3379
3396
  // 计算新位置 = 初始位置 + 总偏移量
3380
- var newX = state.offsetX;
3381
- var newY = state.offsetY;
3397
+ var newX = initialPos.x + state.offsetX;
3398
+ var newY = initialPos.y + state.offsetY;
3382
3399
  // 更新元素位置
3383
3400
  el.style.transform = "translate(".concat(newX, "px, ").concat(newY, "px)");
3384
3401
  // 存储当前位置数据
@@ -3981,7 +3998,8 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
3981
3998
  lastLeft: data.lastLeft,
3982
3999
  lastWidth: data.lastWidth,
3983
4000
  lastTop: data.lastTop,
3984
- lastHeight: data.lastHeight
4001
+ lastHeight: data.lastHeight,
4002
+ gap: data.offsetX || 0
3985
4003
  });
3986
4004
  return _onActionMoving && _onActionMoving(data);
3987
4005
  },
@@ -4097,7 +4115,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
4097
4115
  height: height,
4098
4116
  rowHeight: function rowHeight(_ref4) {
4099
4117
  var index = _ref4.index;
4100
- return heights[index] || _rowHeight;
4118
+ return heights[index] || _rowHeight || 0;
4101
4119
  },
4102
4120
  overscanRowCount: 10,
4103
4121
  overscanColumnCount: 0,
@@ -4220,12 +4238,16 @@ var TimeArea = function TimeArea(_ref) {
4220
4238
  height = _ref3.height;
4221
4239
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Grid, {
4222
4240
  ref: gridRef,
4241
+ containerStyle: {
4242
+ width: timelineWidth + 10,
4243
+ maxWidth: timelineWidth + 10
4244
+ },
4223
4245
  columnCount: showUnit ? scaleCount * scaleSplitCount + 1 : scaleCount,
4224
4246
  columnWidth: getColumnWidth,
4225
4247
  estimatedColumnSize: estColumnWidth,
4226
4248
  rowCount: 1,
4227
4249
  rowHeight: height,
4228
- width: timelineWidth,
4250
+ width: timelineWidth + 10,
4229
4251
  // width={width}
4230
4252
  height: height,
4231
4253
  overscanRowCount: 0,
@@ -4465,7 +4487,7 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4465
4487
  if (areaRef.current) {
4466
4488
  var resizeObserver = new ResizeObserver(function () {
4467
4489
  if (!areaRef.current) return;
4468
- setWidth(areaRef.current.getBoundingClientRect().width);
4490
+ setWidth(areaRef.current.getBoundingClientRect().width + 10);
4469
4491
  });
4470
4492
  resizeObserver.observe(areaRef.current);
4471
4493
  return function () {
package/dist/index.js CHANGED
@@ -2009,7 +2009,7 @@ var Cursor = function Cursor(_ref) {
2009
2009
  }) - scrollLeft);
2010
2010
  }
2011
2011
  }, [cursorTime, startLeft, scaleWidth, scale, scrollLeft], {
2012
- wait: 800
2012
+ wait: 10
2013
2013
  });
2014
2014
  var clientHeight = ((_document$querySelect = document.querySelector("#time-editor-container")) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.clientHeight) || 0;
2015
2015
  return /*#__PURE__*/React__default['default'].createElement(RowDnd, {
@@ -2177,6 +2177,12 @@ var EditActionO = function EditActionO(_ref) {
2177
2177
  _action$movable = action.movable,
2178
2178
  movable = _action$movable === void 0 ? true : _action$movable,
2179
2179
  effectId = action.effectId;
2180
+ var originStart = start;
2181
+ parserTimeToPixel(originStart, {
2182
+ startLeft: startLeft,
2183
+ scale: scale,
2184
+ scaleWidth: scaleWidth
2185
+ });
2180
2186
  var handleDeltaScrollTop = function handleDeltaScrollTop(delta) {
2181
2187
  if (containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) {
2182
2188
  containerRef.current.scrollTop += delta * 2;
@@ -2303,6 +2309,16 @@ var EditActionO = function EditActionO(_ref) {
2303
2309
  }),
2304
2310
  _start = _parserTransformToTim.start,
2305
2311
  _end = _parserTransformToTim.end;
2312
+ var g1 = parserTimeToPixel(originStart, {
2313
+ startLeft: startLeft,
2314
+ scale: scale,
2315
+ scaleWidth: scaleWidth
2316
+ });
2317
+ var g2 = parserTimeToPixel(_start, {
2318
+ startLeft: startLeft,
2319
+ scale: scale,
2320
+ scaleWidth: scaleWidth
2321
+ });
2306
2322
  var result = onActionMoving(_objectSpread2({
2307
2323
  action: action,
2308
2324
  row: row,
@@ -2310,7 +2326,8 @@ var EditActionO = function EditActionO(_ref) {
2310
2326
  end: _end,
2311
2327
  left: left,
2312
2328
  width: width,
2313
- top: top
2329
+ top: top,
2330
+ offsetX: g2 - g1
2314
2331
  }, args));
2315
2332
  if (result === false) return false;
2316
2333
  }
@@ -2878,17 +2895,17 @@ var EditActionO = function EditActionO(_ref) {
2878
2895
  style: {
2879
2896
  height: rowHeight
2880
2897
  }
2881
- }, getActionRender && getActionRender(nowAction, nowRow), flexible && /*#__PURE__*/React__default['default'].createElement("div", {
2898
+ }, getActionRender && getActionRender(nowAction, nowRow), flexible && (/*#__PURE__*/React__default['default'].createElement("div", {
2882
2899
  className: prefix('action-left-stretch')
2883
2900
  }, /*#__PURE__*/React__default['default'].createElement("img", {
2884
2901
  src: stretchIcon,
2885
2902
  alt: ""
2886
- })), flexible && /*#__PURE__*/React__default['default'].createElement("div", {
2903
+ }))), flexible && (/*#__PURE__*/React__default['default'].createElement("div", {
2887
2904
  className: prefix('action-right-stretch')
2888
2905
  }, /*#__PURE__*/React__default['default'].createElement("img", {
2889
2906
  src: stretchIcon,
2890
2907
  alt: ""
2891
- }))));
2908
+ })))));
2892
2909
  };
2893
2910
  var EditAction = /*#__PURE__*/React__default['default'].memo(EditActionO);
2894
2911
 
@@ -3376,7 +3393,7 @@ var useRowDrag = function useRowDrag(options) {
3376
3393
  var selectedEls = getSelectedActionEls();
3377
3394
  if (selectedEls.length === 0) return;
3378
3395
  // 更新偏移量
3379
- state.offsetX = (state.offsetX || 0) + dx;
3396
+ state.offsetX = params.gap;
3380
3397
  state.offsetY = (state.offsetY || 0) + dy;
3381
3398
  // 遍历所有选中的元素,同步移动
3382
3399
  selectedEls.forEach(function (el) {
@@ -3386,8 +3403,8 @@ var useRowDrag = function useRowDrag(options) {
3386
3403
  var initialPos = state.initialElementPositions.get(elActionId);
3387
3404
  if (!initialPos) return;
3388
3405
  // 计算新位置 = 初始位置 + 总偏移量
3389
- var newX = state.offsetX;
3390
- var newY = state.offsetY;
3406
+ var newX = initialPos.x + state.offsetX;
3407
+ var newY = initialPos.y + state.offsetY;
3391
3408
  // 更新元素位置
3392
3409
  el.style.transform = "translate(".concat(newX, "px, ").concat(newY, "px)");
3393
3410
  // 存储当前位置数据
@@ -3990,7 +4007,8 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
3990
4007
  lastLeft: data.lastLeft,
3991
4008
  lastWidth: data.lastWidth,
3992
4009
  lastTop: data.lastTop,
3993
- lastHeight: data.lastHeight
4010
+ lastHeight: data.lastHeight,
4011
+ gap: data.offsetX || 0
3994
4012
  });
3995
4013
  return _onActionMoving && _onActionMoving(data);
3996
4014
  },
@@ -4106,7 +4124,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
4106
4124
  height: height,
4107
4125
  rowHeight: function rowHeight(_ref4) {
4108
4126
  var index = _ref4.index;
4109
- return heights[index] || _rowHeight;
4127
+ return heights[index] || _rowHeight || 0;
4110
4128
  },
4111
4129
  overscanRowCount: 10,
4112
4130
  overscanColumnCount: 0,
@@ -4229,12 +4247,16 @@ var TimeArea = function TimeArea(_ref) {
4229
4247
  height = _ref3.height;
4230
4248
  return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(reactVirtualized.Grid, {
4231
4249
  ref: gridRef,
4250
+ containerStyle: {
4251
+ width: timelineWidth + 10,
4252
+ maxWidth: timelineWidth + 10
4253
+ },
4232
4254
  columnCount: showUnit ? scaleCount * scaleSplitCount + 1 : scaleCount,
4233
4255
  columnWidth: getColumnWidth,
4234
4256
  estimatedColumnSize: estColumnWidth,
4235
4257
  rowCount: 1,
4236
4258
  rowHeight: height,
4237
- width: timelineWidth,
4259
+ width: timelineWidth + 10,
4238
4260
  // width={width}
4239
4261
  height: height,
4240
4262
  overscanRowCount: 0,
@@ -4474,7 +4496,7 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
4474
4496
  if (areaRef.current) {
4475
4497
  var resizeObserver = new ResizeObserver(function () {
4476
4498
  if (!areaRef.current) return;
4477
- setWidth(areaRef.current.getBoundingClientRect().width);
4499
+ setWidth(areaRef.current.getBoundingClientRect().width + 10);
4478
4500
  });
4479
4501
  resizeObserver.observe(areaRef.current);
4480
4502
  return function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sense-react-timeline-editor",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "author": "xzdarcy",
5
5
  "license": "MIT",
6
6
  "keywords": [