پرش به محتوا
مارکت محصولات دیجیتال و خدمات توسعه
خانهپروژه‌هاotp-animation-v10
</>
Open Source Project

otp-animation-v10

MilMit/otp-animation-v10

Interactive OTP verification card with fluid lock & key physics, morphing checkmark tile, and keyboard/paste navigation.

★ 0Stars
⑂ 0Forks
0Open Issues
0Watchers
CSSزبان اصلی
MITLicense
README

مستندات مخزن

🔒 Interactive OTP Animation & Verification

A high-fidelity, physics-based One-Time Password verification component with fluid morphing animations, smart inputs, and clipboard paste support.

License: MIT Vanilla JS CSS3 Live Demo PRs Welcome

🚀 Live Demo✨ Key Features⚡ Quick Start🎨 Customization⌨️ Keyboard & UX


🌟 Overview

This project is a recreation and enhancement of the popular OTP Animation V10 mobile motion concept. It faithfully translates complex UI choreographies into clean, production-ready, dependency-free web code using HTML5, Vanilla CSS, and JavaScript (Web Animations API).

Unlike typical video-only concept mockups, this repository provides a fully interactive, accessible, and responsive implementation ready to be dropped into web apps, authentication modals, or design systems.


✨ Key Features

  • 🔑 Keyhole & Shackle Physics: Dynamic key approach, rotation, and shackle unlock with spring-like easing driven by the native Web Animations API.
  • 🗂️ Morphing Verification Sequence: When verified, the four digit input cards smoothly stack, collapse into a single square, and transition into an animated green checkmark tile.
  • 📋 Smart Clipboard Paste Support: Paste a 4-digit code directly (Ctrl+V / Cmd+V) from SMS or an authenticator app; the digits automatically distribute across fields and trigger verification.
  • ⌨️ Fluid Keyboard Navigation: Full support for ArrowLeft / ArrowRight, backspace traversal, and automatic focus progression.
  • Real-time Amber Glowing Tracer: Ambient verification pulse around input boxes while the code is being checked.
  • 🛑 Non-intrusive Interactive Showcase: Includes a built-in control bar to test valid codes (4545), trigger error shakes (9999), toggle the lock, or replay the showcase animation without interrupting user typing.
  • 📱 100% Responsive & Cross-Device: Adapts seamlessly across desktop monitors, tablets, and smartphones.
  • Accessible & Semantic: Comprehensive ARIA labels, inputmode="numeric", autocomplete="one-time-code", and prefers-reduced-motion compliance.
  • 🪶 Zero External Dependencies: No React, no Framer Motion, no heavy bundle. Open and run instantly.

🎮 Interactive Demo Controls

The component includes a developer toolbar for quick testing:

ButtonAction
Play DemoPlays the full choreographed showcase loop once.
Toggle LockAnimates the key approaching the lock, rotating, and releasing the shackle.
Valid (4545)Auto-fills the valid demo code (4545) and initiates the success morph.
Invalid (9999)Auto-fills an invalid code to demonstrate the error shake state.
ResetClears inputs and resets the card and lock to the initial resting state.

Note: Typing in any input box or clicking any control immediately stops any running autoplay loop so you have full manual control.


🚀 Quick Start

No build tools, npm install, or bundlers needed.

1. Clone the repository

git clone https://github.com/MilMit/otp-animation-v10.git
cd otp-animation-v10

2. Open index.html

Simply double-click index.html in your file explorer, or launch a local static server:

# Using Python
python3 -m http.server 8000

# Or using Node / npx
npx serve .

Visit http://localhost:8000 in your browser.


⌨️ Keyboard & UX Controls

  • Digit Typing: Automatically advances to the next box upon typing a number.
  • Backspace: Deletes the current digit; pressing backspace on an empty field moves focus to the previous box.
  • Arrow Keys ( / ): Move quickly between digit boxes.
  • Paste (Ctrl+V / Cmd+V): Pastes up to 4 numeric digits into the boxes.
  • Lock Key / Shackle: Click or press Space/Enter when focused on the lock to toggle its state.
  • Close Button (×): Resets the component with a subtle spring dismiss animation.

🎨 Customization

Changing the Valid OTP Code

Open script.js and modify the valid code condition:

// script.js (around line 140)
function verifyNow() {
  // ...
  const code = inputs.map(x => x.value).join('');
  wait(() => {
    if (code === '4545') { // <-- Replace with your validation logic or API call
      triggerSuccessMorph();
    } else {
      triggerError();
    }
  }, 950);
}

Theming with CSS Custom Properties

All primary colors, radii, and glow parameters are customizable in style.css:

:root {
  --cream: #f6efcc;           /* Canvas background top tint */
  --tan: #dfd2aa;             /* Canvas background bottom tint */
  --green: #8bd13d;           /* Verify button background */
  --success: #2bcf70;         /* Success state & checkmark */
  --amber: #f5bd28;           /* Keyhole & glow accents */
  --error: #ef4f58;           /* Error shake state */
  --card-bg: rgba(252, 251, 255, 0.98);
  --radius-card: 32px;
  --radius-input: 12px;
}

📁 Project Structure

otp-animation-v10/
├── index.html       # Clean semantic HTML5 markup with SVG assets & metadata
├── style.css        # Modular CSS with variables, keyframes & responsive layout
├── script.js        # State machine, input logic, Web Animations API physics
├── LICENSE          # MIT License
├── .gitignore       # Standard git ignore rules
└── README.md        # Documentation & showcase guide

🤝 Contributing

Contributions, issues, and feature requests are welcome!
Feel free to check the issues page if you want to contribute.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

Distributed under the MIT License. See LICENSE for more information.


Inspired by UI motion design concepts • Re-engineered for the modern web with ❤️