Files
pguzman 3a1433b71e Add drag-to-pan + zoom photo repositioning for card/avatar crops
Every photo upload (session setup, novena group, Rosary Builder title
photo) gets shown two ways: full-size on the presentation cover slide
(unaffected, stays untouched), and cropped to a fixed box everywhere else
— home page cards, profile cards, the novena day-picker's circular hero
photo, and each admin form's own preview thumbnail. All of those crops
used to just take the image's dead center, with no way to control what
part of the photo that was — cropping out people's heads on portrait
photos.

- New sessions/novena_groups columns: photo_focal_x, photo_focal_y (0-100%),
  photo_zoom (1-3x), defaulting to 50/50/1 — today's exact centered/
  unzoomed behavior, so this is fully backward compatible until someone
  actively repositions a photo.

- New assets/js/photo-crop.js: a reusable drag-to-pan + zoom modal editor.
  The crop frame renders with the *exact* CSS recipe used at final render
  time (object-position + transform:scale/transform-origin), so the editor
  is a truthful live preview, not an approximation. A reference thumbnail
  shows the full photo dimmed outside a rectangle marking the current crop.
  All math reads actual rendered box dimensions rather than assuming fixed
  pixel sizes, so it holds up responsively at any viewport width — caught
  and fixed a real mismatch bug here by testing the widget standalone in a
  browser before wiring it into any PHP form.

- New includes/photo.php: photo_crop_style() builds the inline style="..."
  from a session/group row, used everywhere a crop is displayed.

- Wired into all three upload locations (admin/setup.php,
  admin/novena_group.php, admin/builder.php) with a "Reposition" button,
  and persisted through api/save_session.php, admin/novena_group.php's
  save handler, and api/builder_session.php.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 15:10:43 -07:00

119 lines
2.2 KiB
CSS

.photo-crop-overlay {
display: none;
position: fixed;
inset: 0;
background: rgba(17, 24, 39, .6);
z-index: 1000;
align-items: center;
justify-content: center;
}
.photo-crop-overlay.open { display: flex; }
.photo-crop-box {
background: #fff;
border-radius: 10px;
padding: 24px;
max-width: 560px;
width: calc(100% - 32px);
box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.photo-crop-box h3 {
margin: 0 0 16px;
font-size: 16px;
}
.photo-crop-main {
display: flex;
gap: 20px;
align-items: flex-start;
flex-wrap: wrap;
}
.photo-crop-frame {
position: relative;
overflow: hidden;
border-radius: 6px;
border: 2px solid #1e3a5f;
background: #e5e7eb;
cursor: grab;
touch-action: none;
flex-shrink: 0;
max-width: 100%;
aspect-ratio: 2 / 1;
height: auto;
}
.photo-crop-frame:active { cursor: grabbing; }
.photo-crop-frame-img {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
pointer-events: none;
user-select: none;
-webkit-user-drag: none;
}
.photo-crop-ref {
position: relative;
overflow: hidden;
border-radius: 6px;
border: 1px solid #e5e7eb;
background: #f3f4f6;
flex-shrink: 0;
max-width: 100%;
aspect-ratio: 1 / 1;
height: auto;
}
.photo-crop-ref-img {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: contain;
pointer-events: none;
user-select: none;
}
.photo-crop-ref-rect {
position: absolute;
border: 2px solid #c9973d;
box-shadow: 0 0 0 9999px rgba(17, 24, 39, .55);
pointer-events: none;
}
.photo-crop-zoom-row {
display: flex;
align-items: center;
gap: 10px;
margin-top: 16px;
}
.photo-crop-zoom-row label {
font-size: 13px;
font-weight: 600;
color: #374151;
flex-shrink: 0;
}
.photo-crop-zoom-slider { flex: 1; }
.photo-crop-hint {
font-size: 12px;
color: #6b7280;
margin: 10px 0 0;
}
.photo-crop-actions {
display: flex;
align-items: center;
gap: 8px;
margin-top: 20px;
}
@media (max-width: 480px) {
.photo-crop-main { flex-direction: column; align-items: stretch; }
.photo-crop-frame, .photo-crop-ref { width: 100%; }
}