Spaces:
Running
Running
Creat a browser plugin that can generate 360 for pages when click at . The purpose is for web pages enhancer. To make web pages zoom bigger n clearer when click at - Initial Deployment
Browse files- README.md +7 -5
- index.html +420 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: browser-enhancer2
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: green
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,420 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>360° Page Enhancer</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<style>
|
9 |
+
/* Custom CSS for the magnifier effect */
|
10 |
+
.magnifier-glass {
|
11 |
+
position: absolute;
|
12 |
+
width: 150px;
|
13 |
+
height: 150px;
|
14 |
+
border-radius: 50%;
|
15 |
+
border: 3px solid rgba(255, 255, 255, 0.8);
|
16 |
+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
|
17 |
+
background-repeat: no-repeat;
|
18 |
+
background-color: white;
|
19 |
+
cursor: none;
|
20 |
+
z-index: 9999;
|
21 |
+
pointer-events: none;
|
22 |
+
display: none;
|
23 |
+
transform: translate(-50%, -50%);
|
24 |
+
mix-blend-mode: multiply;
|
25 |
+
}
|
26 |
+
|
27 |
+
.rotate-controls {
|
28 |
+
position: fixed;
|
29 |
+
bottom: 20px;
|
30 |
+
left: 50%;
|
31 |
+
transform: translateX(-50%);
|
32 |
+
background: rgba(0, 0, 0, 0.7);
|
33 |
+
padding: 10px;
|
34 |
+
border-radius: 20px;
|
35 |
+
display: flex;
|
36 |
+
gap: 10px;
|
37 |
+
z-index: 10000;
|
38 |
+
opacity: 0;
|
39 |
+
transition: opacity 0.3s;
|
40 |
+
}
|
41 |
+
|
42 |
+
.rotate-controls.visible {
|
43 |
+
opacity: 1;
|
44 |
+
}
|
45 |
+
|
46 |
+
.rotate-btn {
|
47 |
+
width: 40px;
|
48 |
+
height: 40px;
|
49 |
+
border-radius: 50%;
|
50 |
+
background: white;
|
51 |
+
display: flex;
|
52 |
+
align-items: center;
|
53 |
+
justify-content: center;
|
54 |
+
cursor: pointer;
|
55 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
56 |
+
transition: transform 0.2s;
|
57 |
+
}
|
58 |
+
|
59 |
+
.rotate-btn:hover {
|
60 |
+
transform: scale(1.1);
|
61 |
+
}
|
62 |
+
|
63 |
+
.zoom-level {
|
64 |
+
position: fixed;
|
65 |
+
top: 20px;
|
66 |
+
right: 20px;
|
67 |
+
background: rgba(0, 0, 0, 0.7);
|
68 |
+
color: white;
|
69 |
+
padding: 5px 10px;
|
70 |
+
border-radius: 10px;
|
71 |
+
font-family: sans-serif;
|
72 |
+
font-size: 14px;
|
73 |
+
z-index: 10000;
|
74 |
+
display: none;
|
75 |
+
}
|
76 |
+
</style>
|
77 |
+
</head>
|
78 |
+
<body class="bg-gray-100">
|
79 |
+
<div class="container mx-auto p-4">
|
80 |
+
<!-- Extension UI -->
|
81 |
+
<div class="bg-white rounded-lg shadow-lg p-6 mb-6">
|
82 |
+
<h1 class="text-2xl font-bold text-gray-800 mb-4">360° Page Enhancer</h1>
|
83 |
+
<p class="text-gray-600 mb-4">This extension adds a 360° zoom and rotation feature to web pages. Click on any element to activate the magnifier.</p>
|
84 |
+
|
85 |
+
<div class="flex flex-wrap gap-4 mb-6">
|
86 |
+
<div class="flex-1 min-w-[200px]">
|
87 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Zoom Level</label>
|
88 |
+
<input type="range" id="zoomRange" min="1" max="5" step="0.5" value="2" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
|
89 |
+
<div class="flex justify-between text-xs text-gray-500 mt-1">
|
90 |
+
<span>1x</span>
|
91 |
+
<span>2x</span>
|
92 |
+
<span>3x</span>
|
93 |
+
<span>4x</span>
|
94 |
+
<span>5x</span>
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
|
98 |
+
<div class="flex-1 min-w-[200px]">
|
99 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Magnifier Size</label>
|
100 |
+
<input type="range" id="sizeRange" min="100" max="300" step="50" value="150" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
|
101 |
+
<div class="flex justify-between text-xs text-gray-500 mt-1">
|
102 |
+
<span>100px</span>
|
103 |
+
<span>200px</span>
|
104 |
+
<span>300px</span>
|
105 |
+
</div>
|
106 |
+
</div>
|
107 |
+
</div>
|
108 |
+
|
109 |
+
<div class="flex flex-wrap gap-4">
|
110 |
+
<div class="flex items-center">
|
111 |
+
<input type="checkbox" id="enableRotation" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
|
112 |
+
<label for="enableRotation" class="ml-2 block text-sm text-gray-700">Enable 360° Rotation</label>
|
113 |
+
</div>
|
114 |
+
|
115 |
+
<div class="flex items-center">
|
116 |
+
<input type="checkbox" id="showControls" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded" checked>
|
117 |
+
<label for="showControls" class="ml-2 block text-sm text-gray-700">Show Rotation Controls</label>
|
118 |
+
</div>
|
119 |
+
|
120 |
+
<div class="flex items-center">
|
121 |
+
<input type="checkbox" id="smoothZoom" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded" checked>
|
122 |
+
<label for="smoothZoom" class="ml-2 block text-sm text-gray-700">Smooth Zoom Transition</label>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
|
126 |
+
<button id="toggleExtension" class="mt-6 bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200">
|
127 |
+
Activate Extension
|
128 |
+
</button>
|
129 |
+
</div>
|
130 |
+
|
131 |
+
<!-- Demo content to test the extension -->
|
132 |
+
<div class="bg-white rounded-lg shadow-lg p-6">
|
133 |
+
<h2 class="text-xl font-semibold text-gray-800 mb-4">Try it on this demo content</h2>
|
134 |
+
|
135 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
136 |
+
<div class="bg-gray-50 p-4 rounded-lg">
|
137 |
+
<h3 class="font-medium text-gray-700 mb-2">Sample Image</h3>
|
138 |
+
<img src="https://images.unsplash.com/photo-1682686580391-615b4f715f5e?w=500&auto=format&fit=crop" alt="Sample" class="w-full h-auto rounded cursor-pointer demo-target">
|
139 |
+
</div>
|
140 |
+
|
141 |
+
<div class="bg-gray-50 p-4 rounded-lg">
|
142 |
+
<h3 class="font-medium text-gray-700 mb-2">Sample Text</h3>
|
143 |
+
<p class="text-gray-600 cursor-pointer demo-target">
|
144 |
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam in dui mauris. Vivamus hendrerit arcu sed erat molestie vehicula. Sed auctor neque eu tellus rhoncus ut eleifend nibh porttitor.
|
145 |
+
</p>
|
146 |
+
</div>
|
147 |
+
|
148 |
+
<div class="bg-gray-50 p-4 rounded-lg">
|
149 |
+
<h3 class="font-medium text-gray-700 mb-2">Sample UI Elements</h3>
|
150 |
+
<div class="flex flex-wrap gap-2 cursor-pointer demo-target">
|
151 |
+
<button class="bg-blue-500 text-white px-3 py-1 rounded">Button</button>
|
152 |
+
<button class="bg-green-500 text-white px-3 py-1 rounded">Another</button>
|
153 |
+
<button class="bg-red-500 text-white px-3 py-1 rounded">Click Me</button>
|
154 |
+
</div>
|
155 |
+
</div>
|
156 |
+
|
157 |
+
<div class="bg-gray-50 p-4 rounded-lg">
|
158 |
+
<h3 class="font-medium text-gray-700 mb-2">Sample Complex Content</h3>
|
159 |
+
<div class="cursor-pointer demo-target">
|
160 |
+
<div class="flex items-center mb-2">
|
161 |
+
<div class="w-8 h-8 bg-purple-500 rounded-full mr-2"></div>
|
162 |
+
<span class="text-gray-700">User Avatar</span>
|
163 |
+
</div>
|
164 |
+
<div class="border-t pt-2">
|
165 |
+
<p class="text-sm text-gray-600">This is a more complex UI element that you can zoom into.</p>
|
166 |
+
</div>
|
167 |
+
</div>
|
168 |
+
</div>
|
169 |
+
</div>
|
170 |
+
</div>
|
171 |
+
</div>
|
172 |
+
|
173 |
+
<!-- Magnifier elements that will be added to the page -->
|
174 |
+
<div id="magnifier" class="magnifier-glass"></div>
|
175 |
+
<div id="zoomLevel" class="zoom-level">2x</div>
|
176 |
+
<div id="rotateControls" class="rotate-controls">
|
177 |
+
<div id="rotateLeft" class="rotate-btn" title="Rotate Left">←</div>
|
178 |
+
<div id="resetRotation" class="rotate-btn" title="Reset Rotation">↻</div>
|
179 |
+
<div id="rotateRight" class="rotate-btn" title="Rotate Right">→</div>
|
180 |
+
</div>
|
181 |
+
|
182 |
+
<script>
|
183 |
+
document.addEventListener('DOMContentLoaded', function() {
|
184 |
+
// Extension state
|
185 |
+
const state = {
|
186 |
+
active: false,
|
187 |
+
zoomLevel: 2,
|
188 |
+
magnifierSize: 150,
|
189 |
+
enableRotation: false,
|
190 |
+
showControls: true,
|
191 |
+
smoothZoom: true,
|
192 |
+
currentRotation: 0,
|
193 |
+
currentTarget: null
|
194 |
+
};
|
195 |
+
|
196 |
+
// DOM elements
|
197 |
+
const magnifier = document.getElementById('magnifier');
|
198 |
+
const zoomLevelDisplay = document.getElementById('zoomLevel');
|
199 |
+
const rotateControls = document.getElementById('rotateControls');
|
200 |
+
const toggleExtensionBtn = document.getElementById('toggleExtension');
|
201 |
+
const zoomRange = document.getElementById('zoomRange');
|
202 |
+
const sizeRange = document.getElementById('sizeRange');
|
203 |
+
const enableRotation = document.getElementById('enableRotation');
|
204 |
+
const showControls = document.getElementById('showControls');
|
205 |
+
const smoothZoom = document.getElementById('smoothZoom');
|
206 |
+
const rotateLeftBtn = document.getElementById('rotateLeft');
|
207 |
+
const rotateRightBtn = document.getElementById('rotateRight');
|
208 |
+
const resetRotationBtn = document.getElementById('resetRotation');
|
209 |
+
|
210 |
+
// Demo targets
|
211 |
+
const demoTargets = document.querySelectorAll('.demo-target');
|
212 |
+
|
213 |
+
// Initialize UI
|
214 |
+
function updateUI() {
|
215 |
+
toggleExtensionBtn.textContent = state.active ? 'Deactivate Extension' : 'Activate Extension';
|
216 |
+
toggleExtensionBtn.className = state.active ?
|
217 |
+
'mt-6 bg-red-600 hover:bg-red-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200' :
|
218 |
+
'mt-6 bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200';
|
219 |
+
|
220 |
+
if (state.active) {
|
221 |
+
document.body.style.cursor = 'crosshair';
|
222 |
+
demoTargets.forEach(el => el.style.cursor = 'crosshair');
|
223 |
+
} else {
|
224 |
+
document.body.style.cursor = '';
|
225 |
+
demoTargets.forEach(el => el.style.cursor = '');
|
226 |
+
hideMagnifier();
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
// Show magnifier
|
231 |
+
function showMagnifier(e, target) {
|
232 |
+
if (!state.active) return;
|
233 |
+
|
234 |
+
state.currentTarget = target;
|
235 |
+
magnifier.style.display = 'block';
|
236 |
+
zoomLevelDisplay.style.display = 'block';
|
237 |
+
|
238 |
+
if (state.enableRotation && state.showControls) {
|
239 |
+
rotateControls.classList.add('visible');
|
240 |
+
}
|
241 |
+
|
242 |
+
updateMagnifier(e);
|
243 |
+
}
|
244 |
+
|
245 |
+
// Hide magnifier
|
246 |
+
function hideMagnifier() {
|
247 |
+
magnifier.style.display = 'none';
|
248 |
+
zoomLevelDisplay.style.display = 'none';
|
249 |
+
rotateControls.classList.remove('visible');
|
250 |
+
state.currentTarget = null;
|
251 |
+
state.currentRotation = 0;
|
252 |
+
}
|
253 |
+
|
254 |
+
// Update magnifier position and content
|
255 |
+
function updateMagnifier(e) {
|
256 |
+
if (!state.active || !state.currentTarget) return;
|
257 |
+
|
258 |
+
const targetRect = state.currentTarget.getBoundingClientRect();
|
259 |
+
const x = e.clientX;
|
260 |
+
const y = e.clientY;
|
261 |
+
|
262 |
+
// Position the magnifier
|
263 |
+
magnifier.style.left = `${x}px`;
|
264 |
+
magnifier.style.top = `${y}px`;
|
265 |
+
magnifier.style.width = `${state.magnifierSize}px`;
|
266 |
+
magnifier.style.height = `${state.magnifierSize}px`;
|
267 |
+
|
268 |
+
// Calculate the background position for the magnifier
|
269 |
+
const bgX = ((x - targetRect.left) / targetRect.width) * 100;
|
270 |
+
const bgY = ((y - targetRect.top) / targetRect.height) * 100;
|
271 |
+
|
272 |
+
// Create a screenshot of the target
|
273 |
+
const screenshot = createScreenshot(state.currentTarget);
|
274 |
+
|
275 |
+
// Apply transformations
|
276 |
+
magnifier.style.backgroundImage = `url(${screenshot})`;
|
277 |
+
magnifier.style.backgroundSize = `${targetRect.width * state.zoomLevel}px ${targetRect.height * state.zoomLevel}px`;
|
278 |
+
magnifier.style.backgroundPosition = `${bgX}% ${bgY}%`;
|
279 |
+
|
280 |
+
if (state.enableRotation) {
|
281 |
+
magnifier.style.transform = `translate(-50%, -50%) rotate(${state.currentRotation}deg)`;
|
282 |
+
}
|
283 |
+
|
284 |
+
// Update zoom level display
|
285 |
+
zoomLevelDisplay.textContent = `${state.zoomLevel}x`;
|
286 |
+
zoomLevelDisplay.style.top = '20px';
|
287 |
+
zoomLevelDisplay.style.right = '20px';
|
288 |
+
}
|
289 |
+
|
290 |
+
// Create a screenshot of an element
|
291 |
+
function createScreenshot(element) {
|
292 |
+
// In a real extension, we would use more sophisticated methods
|
293 |
+
// For this demo, we'll just create a basic representation
|
294 |
+
const canvas = document.createElement('canvas');
|
295 |
+
const rect = element.getBoundingClientRect();
|
296 |
+
|
297 |
+
// Set canvas dimensions
|
298 |
+
canvas.width = rect.width;
|
299 |
+
canvas.height = rect.height;
|
300 |
+
|
301 |
+
const ctx = canvas.getContext('2d');
|
302 |
+
|
303 |
+
// Draw a representation of the element
|
304 |
+
if (element.tagName === 'IMG') {
|
305 |
+
// For images, we can actually draw them
|
306 |
+
ctx.drawImage(element, 0, 0, rect.width, rect.height);
|
307 |
+
} else {
|
308 |
+
// For other elements, create a simplified representation
|
309 |
+
ctx.fillStyle = window.getComputedStyle(element).backgroundColor || 'white';
|
310 |
+
ctx.fillRect(0, 0, rect.width, rect.height);
|
311 |
+
|
312 |
+
// Add text if the element contains text
|
313 |
+
if (element.textContent.trim()) {
|
314 |
+
ctx.fillStyle = window.getComputedStyle(element).color || 'black';
|
315 |
+
ctx.font = '14px Arial';
|
316 |
+
ctx.fillText(element.textContent.trim(), 10, 20);
|
317 |
+
}
|
318 |
+
}
|
319 |
+
|
320 |
+
return canvas.toDataURL();
|
321 |
+
}
|
322 |
+
|
323 |
+
// Event listeners
|
324 |
+
toggleExtensionBtn.addEventListener('click', function() {
|
325 |
+
state.active = !state.active;
|
326 |
+
updateUI();
|
327 |
+
});
|
328 |
+
|
329 |
+
zoomRange.addEventListener('input', function() {
|
330 |
+
state.zoomLevel = parseFloat(this.value);
|
331 |
+
zoomLevelDisplay.textContent = `${state.zoomLevel}x`;
|
332 |
+
});
|
333 |
+
|
334 |
+
sizeRange.addEventListener('input', function() {
|
335 |
+
state.magnifierSize = parseInt(this.value);
|
336 |
+
magnifier.style.width = `${state.magnifierSize}px`;
|
337 |
+
magnifier.style.height = `${state.magnifierSize}px`;
|
338 |
+
});
|
339 |
+
|
340 |
+
enableRotation.addEventListener('change', function() {
|
341 |
+
state.enableRotation = this.checked;
|
342 |
+
if (!state.enableRotation) {
|
343 |
+
state.currentRotation = 0;
|
344 |
+
magnifier.style.transform = 'translate(-50%, -50%)';
|
345 |
+
}
|
346 |
+
});
|
347 |
+
|
348 |
+
showControls.addEventListener('change', function() {
|
349 |
+
state.showControls = this.checked;
|
350 |
+
if (state.showControls && state.active && state.currentTarget && state.enableRotation) {
|
351 |
+
rotateControls.classList.add('visible');
|
352 |
+
} else {
|
353 |
+
rotateControls.classList.remove('visible');
|
354 |
+
}
|
355 |
+
});
|
356 |
+
|
357 |
+
smoothZoom.addEventListener('change', function() {
|
358 |
+
state.smoothZoom = this.checked;
|
359 |
+
if (state.smoothZoom) {
|
360 |
+
magnifier.style.transition = 'transform 0.2s ease, width 0.2s ease, height 0.2s ease';
|
361 |
+
} else {
|
362 |
+
magnifier.style.transition = 'none';
|
363 |
+
}
|
364 |
+
});
|
365 |
+
|
366 |
+
// Rotation controls
|
367 |
+
rotateLeftBtn.addEventListener('click', function() {
|
368 |
+
if (!state.active || !state.enableRotation || !state.currentTarget) return;
|
369 |
+
state.currentRotation -= 15;
|
370 |
+
updateMagnifier({ clientX: parseFloat(magnifier.style.left), clientY: parseFloat(magnifier.style.top) });
|
371 |
+
});
|
372 |
+
|
373 |
+
rotateRightBtn.addEventListener('click', function() {
|
374 |
+
if (!state.active || !state.enableRotation || !state.currentTarget) return;
|
375 |
+
state.currentRotation += 15;
|
376 |
+
updateMagnifier({ clientX: parseFloat(magnifier.style.left), clientY: parseFloat(magnifier.style.top) });
|
377 |
+
});
|
378 |
+
|
379 |
+
resetRotationBtn.addEventListener('click', function() {
|
380 |
+
if (!state.active || !state.enableRotation || !state.currentTarget) return;
|
381 |
+
state.currentRotation = 0;
|
382 |
+
updateMagnifier({ clientX: parseFloat(magnifier.style.left), clientY: parseFloat(magnifier.style.top) });
|
383 |
+
});
|
384 |
+
|
385 |
+
// Document event listeners
|
386 |
+
document.addEventListener('mousemove', function(e) {
|
387 |
+
if (!state.active || !state.currentTarget) return;
|
388 |
+
updateMagnifier(e);
|
389 |
+
});
|
390 |
+
|
391 |
+
document.addEventListener('click', function(e) {
|
392 |
+
if (!state.active) return;
|
393 |
+
|
394 |
+
// Find the target element
|
395 |
+
let target = e.target;
|
396 |
+
|
397 |
+
// Ignore clicks on the magnifier itself or its controls
|
398 |
+
if (target === magnifier || target.closest('#rotateControls')) {
|
399 |
+
return;
|
400 |
+
}
|
401 |
+
|
402 |
+
// If we're already showing a magnifier and click outside, hide it
|
403 |
+
if (state.currentTarget && !target.closest('.demo-target')) {
|
404 |
+
hideMagnifier();
|
405 |
+
return;
|
406 |
+
}
|
407 |
+
|
408 |
+
// If clicking on a demo target, show magnifier
|
409 |
+
if (target.closest('.demo-target')) {
|
410 |
+
target = target.closest('.demo-target');
|
411 |
+
showMagnifier(e, target);
|
412 |
+
}
|
413 |
+
});
|
414 |
+
|
415 |
+
// Initialize
|
416 |
+
updateUI();
|
417 |
+
});
|
418 |
+
</script>
|
419 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Mackin7/browser-enhancer2" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
420 |
+
</html>
|