@dcg-overseas/number-line 0.1.19 → 0.1.20
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/README.md +2 -2
- package/dist/index.cjs +5 -1
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -212,9 +212,9 @@ function App() {
|
|
|
212
212
|
| `onTogglePen` | `() => void` | 切换画笔工具 |
|
|
213
213
|
| `onToggleEraser` | `() => void` | 切换橡皮擦 |
|
|
214
214
|
| `onDelete` | `() => void` | 删除当前选中 |
|
|
215
|
-
| `onReset` | `() => void` |
|
|
215
|
+
| `onReset` | `() => void` | 清空所有笔迹与选中,并隐藏全部跳数弧线**及分组边界粗刻度**(重新设置 `groupSize/groupCount/min/max` 后恢复) |
|
|
216
216
|
| `onUndo` | `() => void` | 撤销上一步操作 |
|
|
217
|
-
| `showAllArcs` | `() => void` |
|
|
217
|
+
| `showAllArcs` | `() => void` | 重新显示全部跳数弧线**及分组边界粗刻度**(清空删除记录)。即使参数未变、或刚 `onReset` 隐藏后,也能强制把跳数显示出来,且不影响笔迹 |
|
|
218
218
|
|
|
219
219
|
#### 缩放 API(仅 `enableZoom=true` 时有效)
|
|
220
220
|
| 字段 | 类型 | 说明 |
|
package/dist/index.cjs
CHANGED
|
@@ -270,6 +270,7 @@ function NumberLineProvider({
|
|
|
270
270
|
const { min: domainMin, max: domainMax } = normalizeDomain(min, max);
|
|
271
271
|
const [selectedArcIndices, setSelectedArcIndices] = React.useState(/* @__PURE__ */ new Set());
|
|
272
272
|
const [deletedArcIndices, setDeletedArcIndices] = React.useState(/* @__PURE__ */ new Set());
|
|
273
|
+
const [groupTicksHidden, setGroupTicksHidden] = React.useState(false);
|
|
273
274
|
const { ref: svgRef, width: containerWidth, height: containerHeight } = useContainerSize();
|
|
274
275
|
const history = useHistory();
|
|
275
276
|
const drawing = useDrawing();
|
|
@@ -287,6 +288,7 @@ function NumberLineProvider({
|
|
|
287
288
|
React.useEffect(() => {
|
|
288
289
|
setDeletedArcIndices(/* @__PURE__ */ new Set());
|
|
289
290
|
setSelectedArcIndices(/* @__PURE__ */ new Set());
|
|
291
|
+
setGroupTicksHidden(false);
|
|
290
292
|
}, [domainMin, domainMax, groupSize, groupCount]);
|
|
291
293
|
const getLocalCoords = React.useCallback(
|
|
292
294
|
(e) => {
|
|
@@ -385,9 +387,11 @@ function NumberLineProvider({
|
|
|
385
387
|
const arcCount = Math.max(0, Math.ceil(Number(groupCount) || 0));
|
|
386
388
|
setDeletedArcIndices(new Set(Array.from({ length: arcCount }, (_, i) => i)));
|
|
387
389
|
setSelectedArcIndices(/* @__PURE__ */ new Set());
|
|
390
|
+
setGroupTicksHidden(true);
|
|
388
391
|
}, [drawing, history, groupCount]);
|
|
389
392
|
const showAllArcs = React.useCallback(() => {
|
|
390
393
|
setDeletedArcIndices((prev) => prev.size === 0 ? prev : /* @__PURE__ */ new Set());
|
|
394
|
+
setGroupTicksHidden(false);
|
|
391
395
|
}, []);
|
|
392
396
|
const onUndo = React.useCallback(() => {
|
|
393
397
|
const result = history.undo(drawing.strokes);
|
|
@@ -454,7 +458,7 @@ function NumberLineProvider({
|
|
|
454
458
|
groupCount,
|
|
455
459
|
tickStep,
|
|
456
460
|
arcColors,
|
|
457
|
-
showGroupTicks,
|
|
461
|
+
showGroupTicks: showGroupTicks && !groupTicksHidden,
|
|
458
462
|
showMajorTicks,
|
|
459
463
|
showMinorTicks,
|
|
460
464
|
showLabelStep,
|
package/dist/index.js
CHANGED
|
@@ -268,6 +268,7 @@ function NumberLineProvider({
|
|
|
268
268
|
const { min: domainMin, max: domainMax } = normalizeDomain(min, max);
|
|
269
269
|
const [selectedArcIndices, setSelectedArcIndices] = useState(/* @__PURE__ */ new Set());
|
|
270
270
|
const [deletedArcIndices, setDeletedArcIndices] = useState(/* @__PURE__ */ new Set());
|
|
271
|
+
const [groupTicksHidden, setGroupTicksHidden] = useState(false);
|
|
271
272
|
const { ref: svgRef, width: containerWidth, height: containerHeight } = useContainerSize();
|
|
272
273
|
const history = useHistory();
|
|
273
274
|
const drawing = useDrawing();
|
|
@@ -285,6 +286,7 @@ function NumberLineProvider({
|
|
|
285
286
|
useEffect(() => {
|
|
286
287
|
setDeletedArcIndices(/* @__PURE__ */ new Set());
|
|
287
288
|
setSelectedArcIndices(/* @__PURE__ */ new Set());
|
|
289
|
+
setGroupTicksHidden(false);
|
|
288
290
|
}, [domainMin, domainMax, groupSize, groupCount]);
|
|
289
291
|
const getLocalCoords = useCallback(
|
|
290
292
|
(e) => {
|
|
@@ -383,9 +385,11 @@ function NumberLineProvider({
|
|
|
383
385
|
const arcCount = Math.max(0, Math.ceil(Number(groupCount) || 0));
|
|
384
386
|
setDeletedArcIndices(new Set(Array.from({ length: arcCount }, (_, i) => i)));
|
|
385
387
|
setSelectedArcIndices(/* @__PURE__ */ new Set());
|
|
388
|
+
setGroupTicksHidden(true);
|
|
386
389
|
}, [drawing, history, groupCount]);
|
|
387
390
|
const showAllArcs = useCallback(() => {
|
|
388
391
|
setDeletedArcIndices((prev) => prev.size === 0 ? prev : /* @__PURE__ */ new Set());
|
|
392
|
+
setGroupTicksHidden(false);
|
|
389
393
|
}, []);
|
|
390
394
|
const onUndo = useCallback(() => {
|
|
391
395
|
const result = history.undo(drawing.strokes);
|
|
@@ -452,7 +456,7 @@ function NumberLineProvider({
|
|
|
452
456
|
groupCount,
|
|
453
457
|
tickStep,
|
|
454
458
|
arcColors,
|
|
455
|
-
showGroupTicks,
|
|
459
|
+
showGroupTicks: showGroupTicks && !groupTicksHidden,
|
|
456
460
|
showMajorTicks,
|
|
457
461
|
showMinorTicks,
|
|
458
462
|
showLabelStep,
|