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