@pallasoft/ps-mobile-components 1.8.0 → 1.8.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.
- package/dist/components/ps-sortable-grid/ps-sortable-grid.js +4 -5
- package/dist/components/ps-sortable-grid/ps-sortable-item-props.d.ts +1 -1
- package/dist/components/ps-sortable-grid/ps-sortable-item.js +1 -1
- package/dist/constants/ps-sortable-grid-config.d.ts +1 -0
- package/dist/constants/ps-sortable-grid-config.js +1 -0
- package/package.json +1 -1
|
@@ -33,8 +33,6 @@ export const PsSortableGrid = ({ getItemSpan, isDisabled = false, items, labels,
|
|
|
33
33
|
const rects = useMemo(() => PsSortableGridService.layout(order.map((item) => getItemSpan(item)), PsSortableGridService.heights(ids, measured), width), [getItemSpan, ids, measured, order, width]);
|
|
34
34
|
const extras = useMemo(() => PsSortableGridService.extras(rects, PsSortableGridService.heights(ids, measured)), [ids, measured, rects]);
|
|
35
35
|
const isReady = PsSortableGridService.isMeasured(ids, measured, width);
|
|
36
|
-
const applied = useRef({});
|
|
37
|
-
applied.current = Object.fromEntries(ids.map((id, index) => [id, isReady ? extras[index] : 0]));
|
|
38
36
|
const latest = useRef({ items, onReorder, order, rects, scroll, windowHeight, insets });
|
|
39
37
|
latest.current = { insets, items, onReorder, order, rects, scroll, windowHeight };
|
|
40
38
|
useEffect(() => {
|
|
@@ -134,9 +132,10 @@ export const PsSortableGrid = ({ getItemSpan, isDisabled = false, items, labels,
|
|
|
134
132
|
notify(next);
|
|
135
133
|
PsHapticService.play('selection', hasHaptics);
|
|
136
134
|
}, [hasHaptics]);
|
|
137
|
-
const measure = useCallback((id, total) => {
|
|
138
|
-
const natural = PsSortableGridService.natural(total,
|
|
139
|
-
setMeasured((current) => current[id] !== undefined &&
|
|
135
|
+
const measure = useCallback((id, total, renderedExtra) => {
|
|
136
|
+
const natural = PsSortableGridService.natural(total, renderedExtra);
|
|
137
|
+
setMeasured((current) => current[id] !== undefined &&
|
|
138
|
+
Math.abs(current[id] - natural) < PsSortableGridConfig.measureTolerance
|
|
140
139
|
? current
|
|
141
140
|
: { ...current, [id]: natural });
|
|
142
141
|
}, []);
|
|
@@ -16,7 +16,7 @@ export interface PsSortableItemProps {
|
|
|
16
16
|
label: string;
|
|
17
17
|
labels: PsSortableGridLabels;
|
|
18
18
|
onEnd: () => void;
|
|
19
|
-
onMeasure: (id: string, height: number) => void;
|
|
19
|
+
onMeasure: (id: string, height: number, renderedExtra: number) => void;
|
|
20
20
|
onMove: (id: string, delta: number) => void;
|
|
21
21
|
onStart: (id: string, absoluteY: number) => void;
|
|
22
22
|
onUpdate: (translationX: number, translationY: number, absoluteY: number) => void;
|
|
@@ -54,7 +54,7 @@ export const PsSortableItem = ({ canMoveDown, canMoveUp, children, dragX, dragY,
|
|
|
54
54
|
: [
|
|
55
55
|
...(canMoveUp ? [{ label: labels.moveUp, name: 'moveUp' }] : []),
|
|
56
56
|
...(canMoveDown ? [{ label: labels.moveDown, name: 'moveDown' }] : []),
|
|
57
|
-
], accessibilityLabel: label, accessible: !isDisabled, collapsable: false, onAccessibilityAction: (event) => onMove(id, event.nativeEvent.actionName === 'moveUp' ? -1 : 1), onLayout: (event) => onMeasure(id, event.nativeEvent.layout.height), style: [
|
|
57
|
+
], accessibilityLabel: label, accessible: !isDisabled, collapsable: false, onAccessibilityAction: (event) => onMove(id, event.nativeEvent.actionName === 'moveUp' ? -1 : 1), onLayout: (event) => onMeasure(id, event.nativeEvent.layout.height, isReady ? extra : 0), style: [
|
|
58
58
|
{
|
|
59
59
|
borderRadius: PsSortableGridConfig.radius,
|
|
60
60
|
opacity: isReady ? 1 : 0,
|
package/package.json
CHANGED