Skip to content

About

Interactive math manipulatives with Vue 3, GSAP physics-based drag-and-drop, and XState v5 state machines

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Vue 3 Interactive Math Manipulatives

Physics-based drag-and-drop + XState state machines + GSAP animations

Demo

A showcase of advanced Vue 3 patterns through an interactive Cuisenaire rod manipulative for teaching fraction addition. Drag rods onto a number line, snap them to grid positions, and let the state machine orchestrate the lesson flow.

Features

  • GSAP Physics Drag-and-Drop -- Pointer-event-driven drag with momentum throw, grid snapping, and animated lift/drop effects
  • XState v5 State Machines -- Multi-step lesson flow with guards, actions, and typed context/events
  • Cuisenaire Rod Fraction Manipulatives -- Classic math teaching tool rendered as interactive draggable elements
  • Grid Snapping with Collision Detection -- Bounding-box hit detection against registered drop zones
  • Composable Animation Patterns -- Scoped GSAP timelines with auto-cleanup and reusable presets
  • Full TypeScript -- Typed machine context, events, guards, and component props throughout

Architecture

User Interaction
       |
       v
 Vue Components          DraggableRod, NumberLineDropZone, RodBoard
       |
       v
 XState Machine           lesson-machine.ts (intro -> selecting -> placing -> checking -> feedback)
       |
       v
 GSAP Animations          useGsapTimeline (presets), useDragPhysics (momentum, snap)

Key Patterns

State Machine as Choreography Score

The lessonMachine (XState v5) declares every valid state, transition, and guard so Vue components never contain lesson-flow conditionals. The machine handles:

  • Step progression with assign() actions
  • Answer evaluation with sum-checking guards
  • Attempt tracking with configurable max attempts
  • Feedback message generation based on context

Physics Drag Composable

useDragPhysics implements pointer-event-driven drag without any drag library:

  • Velocity tracking during pointermove for momentum throw on release
  • GSAP-animated snap-to-grid with spring easing
  • Shared drop zone registry with bounding-box hit detection
  • Lift/shadow effects on grab, settle animation on drop

Scoped GSAP Timelines

useGsapTimeline creates GSAP contexts tied to Vue template refs:

  • All tweens auto-scoped to the component DOM subtree
  • Full cleanup on unmount (no leaked animations)
  • Preset library: fadeIn, slideUp, pulse, shake, celebrate

Tech Stack

Tool Version Purpose
Vue 3.5 Composition API, <script setup>
TypeScript 5.8 Type safety throughout
XState 5 State machine lesson flow
GSAP 3.12 Animation and drag physics
Pinia 3 State management (extensible)
Vite 6 Build tooling and dev server

Getting Started

git clone https://github.com/amadorcarlosa/vue-math-interactive.git
cd vue-math-interactive
npm install
npm run dev

Open http://localhost:5173 in your browser.

Project Structure

src/
  main.ts                          App entry point
  App.vue                          Root layout (dark theme)
  types/
    index.ts                       Rod, DropZone, HitRect types + color palette
  machines/
    lesson-machine.ts              XState v5 lesson state machine
  composables/
    useGsapTimeline.ts             Scoped GSAP timeline + animation presets
    useDragPhysics.ts              Pointer-driven drag with momentum and snapping
  components/
    RodBoard.vue                   Main orchestrator (machine + rods + zones)
    DraggableRod.vue               Draggable Cuisenaire rod
    NumberLineDropZone.vue          Number line drop target
    FeedbackPanel.vue              Animated progress and feedback display

About

Inspired by MathTabla, an educational technology platform built by Carlos Amador for teaching math through interactive manipulatives. The production app uses Cuisenaire rods for fraction addition with physics-based drag-and-drop and state-machine-driven lesson flow.

This standalone showcase demonstrates the core architectural patterns in a simplified form suitable for portfolio review.

License

MIT -- see LICENSE

About

Interactive math manipulatives with Vue 3, GSAP physics-based drag-and-drop, and XState v5 state machines

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages