Spaces:
Running
Running
The user must be able to move from tab to another by clicking or swapping
Browse files- index.html +2 -2
- script.js +79 -10
- style.css +2 -1
index.html
CHANGED
|
@@ -12,8 +12,8 @@
|
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
<div class="mobile-frame">
|
| 15 |
-
<div class="app-container">
|
| 16 |
-
|
| 17 |
<div class="header-content">
|
| 18 |
<h1><i class="fas fa-camera-retro"></i> VisionSnap</h1>
|
| 19 |
<p class="header-subtitle">OCR Wizard</p>
|
|
|
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
<div class="mobile-frame">
|
| 15 |
+
<div class="app-container" id="appContainer">
|
| 16 |
+
<div class="app-header">
|
| 17 |
<div class="header-content">
|
| 18 |
<h1><i class="fas fa-camera-retro"></i> VisionSnap</h1>
|
| 19 |
<p class="header-subtitle">OCR Wizard</p>
|
script.js
CHANGED
|
@@ -4,25 +4,94 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 4 |
const scanResults = [];
|
| 5 |
|
| 6 |
// Tab switching functionality
|
| 7 |
-
const tabButtons = document.querySelectorAll('.tab-button');
|
| 8 |
const tabContents = document.querySelectorAll('.tab-content');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
tabButtons.forEach(button => {
|
| 11 |
button.addEventListener('click', function(e) {
|
| 12 |
e.preventDefault();
|
| 13 |
const tabId = this.getAttribute('data-tab');
|
| 14 |
-
|
| 15 |
-
// Remove active class from all tabs and buttons
|
| 16 |
-
tabButtons.forEach(btn => btn.classList.remove('active'));
|
| 17 |
-
tabContents.forEach(content => content.classList.remove('active'));
|
| 18 |
-
|
| 19 |
-
// Add active class to clicked tab and button
|
| 20 |
-
this.classList.add('active');
|
| 21 |
-
document.getElementById(tabId).classList.add('active');
|
| 22 |
});
|
| 23 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
// Scan buttons functionality
|
| 25 |
-
|
| 26 |
const captureButton = document.querySelector('.capture-button');
|
| 27 |
const textPreview = document.querySelector('.text-preview');
|
| 28 |
uploadButton.addEventListener('click', function() {
|
|
|
|
| 4 |
const scanResults = [];
|
| 5 |
|
| 6 |
// Tab switching functionality
|
| 7 |
+
const tabButtons = document.querySelectorAll('.tab-button');
|
| 8 |
const tabContents = document.querySelectorAll('.tab-content');
|
| 9 |
+
const appContainer = document.querySelector('.app-container');
|
| 10 |
+
let startX = 0;
|
| 11 |
+
let currentTab = 'home';
|
| 12 |
+
const tabs = ['home', 'history', 'settings'];
|
| 13 |
|
| 14 |
+
// Track touch start position
|
| 15 |
+
appContainer.addEventListener('touchstart', (e) => {
|
| 16 |
+
startX = e.touches[0].clientX;
|
| 17 |
+
}, { passive: true });
|
| 18 |
+
|
| 19 |
+
// Handle swipe gesture
|
| 20 |
+
appContainer.addEventListener('touchend', (e) => {
|
| 21 |
+
const endX = e.changedTouches[0].clientX;
|
| 22 |
+
const diffX = startX - endX;
|
| 23 |
+
|
| 24 |
+
if (Math.abs(diffX) > 50) { // Minimum swipe distance
|
| 25 |
+
const currentIndex = tabs.indexOf(currentTab);
|
| 26 |
+
let newIndex = currentIndex;
|
| 27 |
+
|
| 28 |
+
if (diffX > 0 && currentIndex < tabs.length - 1) {
|
| 29 |
+
// Swipe left - move to next tab
|
| 30 |
+
newIndex = currentIndex + 1;
|
| 31 |
+
} else if (diffX < 0 && currentIndex > 0) {
|
| 32 |
+
// Swipe right - move to previous tab
|
| 33 |
+
newIndex = currentIndex - 1;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
if (newIndex !== currentIndex) {
|
| 37 |
+
switchTab(tabs[newIndex]);
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
}, { passive: true });
|
| 41 |
+
|
| 42 |
+
// Click handler for tab buttons
|
| 43 |
tabButtons.forEach(button => {
|
| 44 |
button.addEventListener('click', function(e) {
|
| 45 |
e.preventDefault();
|
| 46 |
const tabId = this.getAttribute('data-tab');
|
| 47 |
+
switchTab(tabId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
});
|
| 49 |
});
|
| 50 |
+
|
| 51 |
+
// Function to handle tab switching
|
| 52 |
+
function switchTab(tabId) {
|
| 53 |
+
// Remove active class from all tabs and buttons
|
| 54 |
+
tabButtons.forEach(btn => btn.classList.remove('active'));
|
| 55 |
+
tabContents.forEach(content => content.classList.remove('active'));
|
| 56 |
+
|
| 57 |
+
// Add active class to clicked tab and button
|
| 58 |
+
const activeButton = document.querySelector(`.tab-button[data-tab="${tabId}"]`);
|
| 59 |
+
const activeTab = document.getElementById(tabId);
|
| 60 |
+
|
| 61 |
+
if (activeButton && activeTab) {
|
| 62 |
+
activeButton.classList.add('active');
|
| 63 |
+
activeTab.classList.add('active');
|
| 64 |
+
currentTab = tabId;
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
// Initialize first tab
|
| 69 |
+
switchTab('home');
|
| 70 |
+
// Add swipe indicator animation
|
| 71 |
+
const swipeStyle = document.createElement('style');
|
| 72 |
+
swipeStyle.textContent = `
|
| 73 |
+
.tab-content {
|
| 74 |
+
transition: transform 0.3s ease-out;
|
| 75 |
+
}
|
| 76 |
+
.swipe-left {
|
| 77 |
+
animation: swipeLeft 0.3s ease-out;
|
| 78 |
+
}
|
| 79 |
+
.swipe-right {
|
| 80 |
+
animation: swipeRight 0.3s ease-out;
|
| 81 |
+
}
|
| 82 |
+
@keyframes swipeLeft {
|
| 83 |
+
0% { transform: translateX(100%); }
|
| 84 |
+
100% { transform: translateX(0); }
|
| 85 |
+
}
|
| 86 |
+
@keyframes swipeRight {
|
| 87 |
+
0% { transform: translateX(-100%); }
|
| 88 |
+
100% { transform: translateX(0); }
|
| 89 |
+
}
|
| 90 |
+
`;
|
| 91 |
+
document.head.appendChild(swipeStyle);
|
| 92 |
+
|
| 93 |
// Scan buttons functionality
|
| 94 |
+
const uploadButton = document.querySelector('.upload-button');
|
| 95 |
const captureButton = document.querySelector('.capture-button');
|
| 96 |
const textPreview = document.querySelector('.text-preview');
|
| 97 |
uploadButton.addEventListener('click', function() {
|
style.css
CHANGED
|
@@ -126,8 +126,9 @@ body {
|
|
| 126 |
flex: 1;
|
| 127 |
overflow-y: auto;
|
| 128 |
padding: 20px;
|
|
|
|
|
|
|
| 129 |
}
|
| 130 |
-
|
| 131 |
.tab-content.active {
|
| 132 |
display: block;
|
| 133 |
}
|
|
|
|
| 126 |
flex: 1;
|
| 127 |
overflow-y: auto;
|
| 128 |
padding: 20px;
|
| 129 |
+
touch-action: pan-y;
|
| 130 |
+
will-change: transform;
|
| 131 |
}
|
|
|
|
| 132 |
.tab-content.active {
|
| 133 |
display: block;
|
| 134 |
}
|