jspsych-tangram 0.0.16 → 0.0.18
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/construct/index.browser.js +23 -5
- package/dist/construct/index.browser.js.map +1 -1
- package/dist/construct/index.browser.min.js +8 -8
- package/dist/construct/index.browser.min.js.map +1 -1
- package/dist/construct/index.cjs +23 -5
- package/dist/construct/index.cjs.map +1 -1
- package/dist/construct/index.js +23 -5
- package/dist/construct/index.js.map +1 -1
- package/dist/grid/index.browser.js +17855 -0
- package/dist/grid/index.browser.js.map +1 -0
- package/dist/grid/index.browser.min.js +47 -0
- package/dist/grid/index.browser.min.js.map +1 -0
- package/dist/grid/index.cjs +547 -0
- package/dist/grid/index.cjs.map +1 -0
- package/dist/grid/index.d.ts +174 -0
- package/dist/grid/index.js +545 -0
- package/dist/grid/index.js.map +1 -0
- package/dist/index.cjs +548 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +187 -16
- package/dist/index.js +549 -15
- package/dist/index.js.map +1 -1
- package/dist/prep/index.browser.js +23 -5
- package/dist/prep/index.browser.js.map +1 -1
- package/dist/prep/index.browser.min.js +6 -6
- package/dist/prep/index.browser.min.js.map +1 -1
- package/dist/prep/index.cjs +23 -5
- package/dist/prep/index.cjs.map +1 -1
- package/dist/prep/index.js +23 -5
- package/dist/prep/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/components/board/GameBoard.tsx +12 -0
- package/src/core/io/InteractionTracker.ts +19 -7
- package/src/core/io/data-tracking.ts +5 -0
- package/src/index.ts +2 -1
- package/src/plugins/tangram-grid/GridApp.tsx +522 -0
- package/src/plugins/tangram-grid/index.ts +154 -0
- package/tangram-construct.min.js +8 -8
- package/tangram-prep.min.js +6 -6
package/dist/construct/index.cjs
CHANGED
|
@@ -2657,7 +2657,9 @@ function useClickController(controller, layout, pieces, clickMode, draggingId, s
|
|
|
2657
2657
|
|
|
2658
2658
|
class InteractionTracker {
|
|
2659
2659
|
constructor(controller, callbacks, trialParams) {
|
|
2660
|
-
this.
|
|
2660
|
+
this.completionTimes = [];
|
|
2661
|
+
// Sector centers (set by GameBoard after layout computation)
|
|
2662
|
+
this.sectorCenters = {};
|
|
2661
2663
|
// Interaction state
|
|
2662
2664
|
this.interactionIndex = 0;
|
|
2663
2665
|
this.currentPickup = null;
|
|
@@ -2667,14 +2669,13 @@ class InteractionTracker {
|
|
|
2667
2669
|
this.mouseTracking = [];
|
|
2668
2670
|
// Interaction history (for TrialEndData)
|
|
2669
2671
|
this.interactions = [];
|
|
2670
|
-
// Construction-specific tracking
|
|
2671
|
-
this.completionTimes = [];
|
|
2672
2672
|
// Prep-specific tracking
|
|
2673
2673
|
this.createdMacros = [];
|
|
2674
2674
|
this.controller = controller;
|
|
2675
2675
|
this.callbacks = callbacks;
|
|
2676
2676
|
this.trialParams = trialParams;
|
|
2677
2677
|
this.trialStartTime = Date.now();
|
|
2678
|
+
this.gridStep = CONFIG.layout.grid.stepPx;
|
|
2678
2679
|
this.controller.setTrackingCallbacks({
|
|
2679
2680
|
onSectorCompleted: (sectorId) => this.recordSectorCompletion(sectorId)
|
|
2680
2681
|
});
|
|
@@ -2804,7 +2805,13 @@ class InteractionTracker {
|
|
|
2804
2805
|
});
|
|
2805
2806
|
}
|
|
2806
2807
|
/**
|
|
2807
|
-
*
|
|
2808
|
+
* Set sector centers (for anchor alignment)
|
|
2809
|
+
*/
|
|
2810
|
+
setSectorCenters(centers) {
|
|
2811
|
+
this.sectorCenters = centers;
|
|
2812
|
+
}
|
|
2813
|
+
/**
|
|
2814
|
+
* Record a sector completion event
|
|
2808
2815
|
*/
|
|
2809
2816
|
recordSectorCompletion(sectorId) {
|
|
2810
2817
|
this.completionTimes.push({
|
|
@@ -2981,7 +2988,8 @@ class InteractionTracker {
|
|
|
2981
2988
|
sectorId: sector.id,
|
|
2982
2989
|
completed,
|
|
2983
2990
|
pieceCount: pieces.length,
|
|
2984
|
-
pieces
|
|
2991
|
+
pieces,
|
|
2992
|
+
center: this.sectorCenters[sector.id] ? this.toAnchorPoint(this.sectorCenters[sector.id]) : void 0
|
|
2985
2993
|
};
|
|
2986
2994
|
if (sectorState?.completedAt !== void 0) {
|
|
2987
2995
|
snapshot.completedAt = sectorState.completedAt;
|
|
@@ -3209,6 +3217,16 @@ function GameBoard(props) {
|
|
|
3209
3217
|
viewBox: { w: logicalBox.LOGICAL_W, h: logicalBox.LOGICAL_H }
|
|
3210
3218
|
};
|
|
3211
3219
|
}, [sectors, layoutMode, target, maxQuickstashSlots, primitives.length]);
|
|
3220
|
+
React.useEffect(() => {
|
|
3221
|
+
if (tracker && layout) {
|
|
3222
|
+
const centers = {};
|
|
3223
|
+
layout.sectors.forEach((s) => {
|
|
3224
|
+
const rect = rectForBand(layout, s, "silhouette", 1);
|
|
3225
|
+
centers[s.id] = { x: rect.cx, y: rect.cy };
|
|
3226
|
+
});
|
|
3227
|
+
tracker.setSectorCenters(centers);
|
|
3228
|
+
}
|
|
3229
|
+
}, [tracker, layout]);
|
|
3212
3230
|
const [, force] = React.useReducer((x) => x + 1, 0);
|
|
3213
3231
|
React.useEffect(() => {
|
|
3214
3232
|
if (onControllerReady) {
|