jspsych-tangram 0.0.15 → 0.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.
- package/dist/afc/index.browser.js +3897 -4514
- package/dist/afc/index.browser.js.map +1 -1
- package/dist/afc/index.browser.min.js +12 -12
- package/dist/afc/index.browser.min.js.map +1 -1
- package/dist/afc/index.cjs +39 -4
- package/dist/afc/index.cjs.map +1 -1
- package/dist/afc/index.js +39 -4
- package/dist/afc/index.js.map +1 -1
- package/dist/construct/index.browser.js +3892 -4522
- package/dist/construct/index.browser.js.map +1 -1
- package/dist/construct/index.browser.min.js +13 -13
- package/dist/construct/index.browser.min.js.map +1 -1
- package/dist/construct/index.cjs +31 -9
- package/dist/construct/index.cjs.map +1 -1
- package/dist/construct/index.js +31 -9
- package/dist/construct/index.js.map +1 -1
- package/dist/index.cjs +31 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -9
- package/dist/index.js.map +1 -1
- package/dist/nback/index.browser.js +3897 -4514
- package/dist/nback/index.browser.js.map +1 -1
- package/dist/nback/index.browser.min.js +12 -12
- package/dist/nback/index.browser.min.js.map +1 -1
- package/dist/nback/index.cjs +39 -4
- package/dist/nback/index.cjs.map +1 -1
- package/dist/nback/index.js +39 -4
- package/dist/nback/index.js.map +1 -1
- package/dist/prep/index.browser.js +3163 -3791
- package/dist/prep/index.browser.js.map +1 -1
- package/dist/prep/index.browser.min.js +13 -13
- package/dist/prep/index.browser.min.js.map +1 -1
- package/dist/prep/index.cjs +34 -10
- package/dist/prep/index.cjs.map +1 -1
- package/dist/prep/index.js +34 -10
- package/dist/prep/index.js.map +1 -1
- package/package.json +9 -3
- 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/tangram-afc.min.js +42 -0
- package/tangram-construct.min.js +13 -13
- package/tangram-nback.min.js +12 -12
- package/tangram-prep.min.js +13 -13
package/dist/prep/index.cjs
CHANGED
|
@@ -16,8 +16,9 @@ const CONFIG = {
|
|
|
16
16
|
silhouetteMask: "#374151",
|
|
17
17
|
anchors: { invalid: "#7dd3fc", valid: "#475569" },
|
|
18
18
|
// validFill used here for placed composites
|
|
19
|
-
piece: { draggingFill: "#8e7cc3", validFill: "#8e7cc3", invalidFill: "#d55c00", invalidStroke: "#dc2626", allGreenStroke: "#86efac"},
|
|
20
|
-
|
|
19
|
+
piece: { draggingFill: "#8e7cc3", validFill: "#8e7cc3", invalidFill: "#d55c00", invalidStroke: "#dc2626", selectedStroke: "#674ea7", allGreenStroke: "#86efac", borderStroke: "#674ea7" },
|
|
20
|
+
ui: { light: "#60a5fa", dark: "#1d4ed8" },
|
|
21
|
+
blueprint: { fill: "#374151", selectedStroke: "#111827", badgeFill: "#000000", labelFill: "#ffffff" },
|
|
21
22
|
tangramDecomposition: { stroke: "#fef2cc" },
|
|
22
23
|
primitiveColors: [
|
|
23
24
|
// from seaborn "colorblind" palette, 6 colors, with red omitted
|
|
@@ -36,7 +37,7 @@ const CONFIG = {
|
|
|
36
37
|
piece: { invalid: 1, dragging: 1, locked: 1, normal: 1 }
|
|
37
38
|
},
|
|
38
39
|
size: {
|
|
39
|
-
stroke: { bandPx: 5, allGreenStrokePx: 10, tangramDecompositionPx: 1 },
|
|
40
|
+
stroke: { bandPx: 5, pieceSelectedPx: 5, allGreenStrokePx: 10, pieceBorderPx: 2, tangramDecompositionPx: 1 },
|
|
40
41
|
anchorRadiusPx: { valid: 1, invalid: 1 },
|
|
41
42
|
badgeFontPx: 16,
|
|
42
43
|
centerBadge: { fractionOfOuterR: 0.15, minPx: 20, marginPx: 4 },
|
|
@@ -52,10 +53,15 @@ const CONFIG = {
|
|
|
52
53
|
quickstashDiamAnchors: 7,
|
|
53
54
|
// num anchors req'd to be in single quickstash slot
|
|
54
55
|
primitiveDiamAnchors: 5
|
|
55
|
-
}
|
|
56
|
+
},
|
|
57
|
+
defaults: { maxQuickstashSlots: 1 }
|
|
58
|
+
},
|
|
56
59
|
game: {
|
|
57
60
|
snapRadiusPx: 15,
|
|
58
|
-
showBorders: false
|
|
61
|
+
showBorders: false,
|
|
62
|
+
hideTouchingBorders: true,
|
|
63
|
+
silhouettesBelowPieces: true
|
|
64
|
+
}
|
|
59
65
|
};
|
|
60
66
|
|
|
61
67
|
function isComposite(bp) {
|
|
@@ -2655,7 +2661,9 @@ function useClickController(controller, layout, pieces, clickMode, draggingId, s
|
|
|
2655
2661
|
|
|
2656
2662
|
class InteractionTracker {
|
|
2657
2663
|
constructor(controller, callbacks, trialParams) {
|
|
2658
|
-
this.
|
|
2664
|
+
this.completionTimes = [];
|
|
2665
|
+
// Sector centers (set by GameBoard after layout computation)
|
|
2666
|
+
this.sectorCenters = {};
|
|
2659
2667
|
// Interaction state
|
|
2660
2668
|
this.interactionIndex = 0;
|
|
2661
2669
|
this.currentPickup = null;
|
|
@@ -2665,14 +2673,13 @@ class InteractionTracker {
|
|
|
2665
2673
|
this.mouseTracking = [];
|
|
2666
2674
|
// Interaction history (for TrialEndData)
|
|
2667
2675
|
this.interactions = [];
|
|
2668
|
-
// Construction-specific tracking
|
|
2669
|
-
this.completionTimes = [];
|
|
2670
2676
|
// Prep-specific tracking
|
|
2671
2677
|
this.createdMacros = [];
|
|
2672
2678
|
this.controller = controller;
|
|
2673
2679
|
this.callbacks = callbacks;
|
|
2674
2680
|
this.trialParams = trialParams;
|
|
2675
2681
|
this.trialStartTime = Date.now();
|
|
2682
|
+
this.gridStep = CONFIG.layout.grid.stepPx;
|
|
2676
2683
|
this.controller.setTrackingCallbacks({
|
|
2677
2684
|
onSectorCompleted: (sectorId) => this.recordSectorCompletion(sectorId)
|
|
2678
2685
|
});
|
|
@@ -2802,7 +2809,13 @@ class InteractionTracker {
|
|
|
2802
2809
|
});
|
|
2803
2810
|
}
|
|
2804
2811
|
/**
|
|
2805
|
-
*
|
|
2812
|
+
* Set sector centers (for anchor alignment)
|
|
2813
|
+
*/
|
|
2814
|
+
setSectorCenters(centers) {
|
|
2815
|
+
this.sectorCenters = centers;
|
|
2816
|
+
}
|
|
2817
|
+
/**
|
|
2818
|
+
* Record a sector completion event
|
|
2806
2819
|
*/
|
|
2807
2820
|
recordSectorCompletion(sectorId) {
|
|
2808
2821
|
this.completionTimes.push({
|
|
@@ -2979,7 +2992,8 @@ class InteractionTracker {
|
|
|
2979
2992
|
sectorId: sector.id,
|
|
2980
2993
|
completed,
|
|
2981
2994
|
pieceCount: pieces.length,
|
|
2982
|
-
pieces
|
|
2995
|
+
pieces,
|
|
2996
|
+
center: this.sectorCenters[sector.id] ? this.toAnchorPoint(this.sectorCenters[sector.id]) : void 0
|
|
2983
2997
|
};
|
|
2984
2998
|
if (sectorState?.completedAt !== void 0) {
|
|
2985
2999
|
snapshot.completedAt = sectorState.completedAt;
|
|
@@ -3207,6 +3221,16 @@ function GameBoard(props) {
|
|
|
3207
3221
|
viewBox: { w: logicalBox.LOGICAL_W, h: logicalBox.LOGICAL_H }
|
|
3208
3222
|
};
|
|
3209
3223
|
}, [sectors, layoutMode, target, maxQuickstashSlots, primitives.length]);
|
|
3224
|
+
React.useEffect(() => {
|
|
3225
|
+
if (tracker && layout) {
|
|
3226
|
+
const centers = {};
|
|
3227
|
+
layout.sectors.forEach((s) => {
|
|
3228
|
+
const rect = rectForBand(layout, s, "silhouette", 1);
|
|
3229
|
+
centers[s.id] = { x: rect.cx, y: rect.cy };
|
|
3230
|
+
});
|
|
3231
|
+
tracker.setSectorCenters(centers);
|
|
3232
|
+
}
|
|
3233
|
+
}, [tracker, layout]);
|
|
3210
3234
|
const [, force] = React.useReducer((x) => x + 1, 0);
|
|
3211
3235
|
React.useEffect(() => {
|
|
3212
3236
|
if (onControllerReady) {
|