MCPcopy Create free account
hub / github.com/Coneja-Chibi/CarrotKernel / positionTutorialPopup

Function positionTutorialPopup

tutorials.js:392–423  ·  view source on GitHub ↗
(popup, targetRect)

Source from the content-addressed store, hash-verified

390
391// Position tutorial popup near target element
392function positionTutorialPopup(popup, targetRect) {
393 if (!popup) return;
394
395 const popupRect = popup.getBoundingClientRect();
396 const viewportWidth = window.innerWidth;
397 const viewportHeight = window.innerHeight;
398
399 // Try to position to the right of target
400 let left = targetRect.right + 20;
401 let top = targetRect.top;
402
403 // If it goes off right edge, position to the left
404 if (left + popupRect.width > viewportWidth - 20) {
405 left = targetRect.left - popupRect.width - 20;
406 }
407
408 // If still off screen, center horizontally
409 if (left < 20) {
410 left = (viewportWidth - popupRect.width) / 2;
411 }
412
413 // Adjust vertical position to keep in viewport
414 if (top + popupRect.height > viewportHeight - 20) {
415 top = viewportHeight - popupRect.height - 20;
416 }
417 if (top < 20) {
418 top = 20;
419 }
420
421 popup.style.left = Math.max(20, left) + 'px';
422 popup.style.top = Math.max(20, top) + 'px';
423}
424
425// Navigate to next tutorial step
426export function nextTutorialStep() {

Callers 1

showTutorialOverlayFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected