jhh6576 commited on
Commit
ba6a1a2
·
verified ·
1 Parent(s): 6539266

Update app_enhanced.py

Browse files
Files changed (1) hide show
  1. app_enhanced.py +17 -5
app_enhanced.py CHANGED
@@ -545,7 +545,7 @@ body { margin: 0; padding: 20px; background: #f0f0f0; font-family: Arial, sans-s
545
  <div class="edit-controls">
546
  <h4>✏️ Interactive Editor</h4>
547
  <div class="control-group">
548
- <label for="bubble-type-select">Bubble Tools:</label>
549
  <select id="bubble-type-select" onchange="changeBubbleType(this.value)">
550
  <option value="speech">Speech</option><option value="thought">Thought</option><option value="reaction">Reaction</option><option value="narration">Narration</option><option value="idea">Idea</option>
551
  </select>
@@ -632,18 +632,29 @@ body { margin: 0; padding: 20px; background: #f0f0f0; font-family: Arial, sans-s
632
  });
633
  document.querySelectorAll('.speech-bubble').forEach(b => initializeBubbleEvents(b));
634
  document.getElementById('zoom-slider').addEventListener('input', handleZoom);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635
  }
636
 
637
  function initializePanelImageEvents(img) {
638
  img.addEventListener('mousedown', startPan);
639
- document.addEventListener('mousemove', panImage);
640
- document.addEventListener('mouseup', stopPan);
641
- document.addEventListener('mouseleave', stopPan);
642
  }
643
 
644
  function initializeBubbleEvents(bubble) {
645
  bubble.addEventListener('dblclick', e => { e.stopPropagation(); editBubbleText(bubble); });
646
- bubble.addEventListener('mousedown', e => startDrag(e));
647
  bubble.addEventListener('click', e => { e.stopPropagation(); selectBubble(bubble); });
648
  bubble.addEventListener('wheel', e => {
649
  e.preventDefault();
@@ -763,6 +774,7 @@ body { margin: 0; padding: 20px; background: #f0f0f0; font-family: Arial, sans-s
763
  }
764
 
765
  function drag(e) {
 
766
  const parentRect = draggedBubble.parentElement.getBoundingClientRect();
767
  let x = e.clientX - parentRect.left - offset.x;
768
  let y = e.clientY - parentRect.top - offset.y;
 
545
  <div class="edit-controls">
546
  <h4>✏️ Interactive Editor</h4>
547
  <div class="control-group">
548
+ <label>Bubble Tools:</label>
549
  <select id="bubble-type-select" onchange="changeBubbleType(this.value)">
550
  <option value="speech">Speech</option><option value="thought">Thought</option><option value="reaction">Reaction</option><option value="narration">Narration</option><option value="idea">Idea</option>
551
  </select>
 
632
  });
633
  document.querySelectorAll('.speech-bubble').forEach(b => initializeBubbleEvents(b));
634
  document.getElementById('zoom-slider').addEventListener('input', handleZoom);
635
+
636
+ // Universal listeners for dragging and panning
637
+ document.addEventListener('mousemove', (e) => {
638
+ panImage(e);
639
+ drag(e);
640
+ });
641
+ document.addEventListener('mouseup', (e) => {
642
+ stopPan(e);
643
+ stopDrag(e);
644
+ });
645
+ document.addEventListener('mouseleave', (e) => {
646
+ stopPan(e);
647
+ stopDrag(e);
648
+ });
649
  }
650
 
651
  function initializePanelImageEvents(img) {
652
  img.addEventListener('mousedown', startPan);
 
 
 
653
  }
654
 
655
  function initializeBubbleEvents(bubble) {
656
  bubble.addEventListener('dblclick', e => { e.stopPropagation(); editBubbleText(bubble); });
657
+ bubble.addEventListener('mousedown', e => { e.stopPropagation(); startDrag(e); });
658
  bubble.addEventListener('click', e => { e.stopPropagation(); selectBubble(bubble); });
659
  bubble.addEventListener('wheel', e => {
660
  e.preventDefault();
 
774
  }
775
 
776
  function drag(e) {
777
+ if (!draggedBubble) return;
778
  const parentRect = draggedBubble.parentElement.getBoundingClientRect();
779
  let x = e.clientX - parentRect.left - offset.x;
780
  let y = e.clientY - parentRect.top - offset.y;