Skip to content

refactor: 좌우 스와이프 더 확실하게 차단#223

Merged
ljh130334 merged 2 commits into
developfrom
feat/savedbook-hotfix
Sep 1, 2025
Merged

refactor: 좌우 스와이프 더 확실하게 차단#223
ljh130334 merged 2 commits into
developfrom
feat/savedbook-hotfix

Conversation

@ljh130334

@ljh130334 ljh130334 commented Sep 1, 2025

Copy link
Copy Markdown
Member
  1. 임계값을 5px로 줄임 - 더 민감하게 감지
  2. 수평 스와이프시 무조건 차단 - 가장자리 조건 제거
  3. capture: true 추가 - 이벤트 버블링 단계에서도 차단
  4. gesture 이벤트들도 차단 - iOS에서 추가적인 제스처 방지
  5. touchend에서 변수 초기화 - 더 정확한 상태 관리

Summary by CodeRabbit

  • 버그 수정
    • 좌우 스와이프 시 의도치 않은 뒤로가기·탭 전환 등 시스템 제스처가 발생하던 문제를 해소했습니다.
    • 수직/수평 이동을 더 정확히 구분해 스크롤 중 오작동을 줄였습니다.
    • 제스처 종료 후 상태를 초기화해 드래그 잔상·먹통 현상을 방지했습니다.
    • 멀티터치·핀치 등 기타 제스처 간섭을 차단해 터치 인터랙션의 일관성을 높였습니다.
    • 터치 이벤트 처리 안정성을 개선해 일부 기기에서의 스크롤 끊김과 입력 지연을 완화했습니다.

@ljh130334 ljh130334 self-assigned this Sep 1, 2025
@vercel

vercel Bot commented Sep 1, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
thip Ready Ready Preview Comment Sep 1, 2025 7:09am

@coderabbitai

coderabbitai Bot commented Sep 1, 2025

Copy link
Copy Markdown

Warning

Rate limit exceeded

@ljh130334 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 44 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 92266d9 and f2fcf6a.

📒 Files selected for processing (1)
  • index.html (1 hunks)

Walkthrough

터치/제스처 이벤트 처리 로직을 조정하여 수평 스와이프 차단을 강화하고, 수직 이동 추적을 추가했다. touchstart/move에 비수동 옵션을 적용하고, touchmove에서 preventDefault/stopPropagation을 적극 호출한다. touchend로 상태를 초기화하고, gesture* 이벤트 전반을 차단한다.

Changes

Cohort / File(s) Summary
터치 제스처 차단 로직 강화
index.html
- startY/currentY 및 diffY 도입으로 수직 추적 추가
- 수평 스와이프 차단 조건을 diffX > 5 && diffX > diffY로 단순/강화
- touchstart: { passive: false }, touchmove: { passive: false, capture: true } 적용
- touchmove에서 preventDefault(), stopPropagation(), return false 수행
- touchend에서 startX/startY 리셋
- gesturestart/change/end에서 preventDefault()로 제스처 전면 차단
- 주석 갱신(“완전 차단”)

Sequence Diagram(s)

sequenceDiagram
  actor User as 사용자
  participant Doc as Document
  participant Handlers as GestureHandlers

  User->>Doc: touchstart
  activate Handlers
  Handlers->>Handlers: startX/startY 저장 (passive: false)

  User->>Doc: touchmove (capture: true)
  Handlers->>Handlers: currentX/currentY 계산<br/>diffX/diffY 비교
  alt 수평 스와이프 (diffX > 5 && diffX > diffY)
    Handlers->>Doc: preventDefault() + stopPropagation()
    Note over Handlers: 스크롤/제스처 완전 차단
  else 기타 이동
    Handlers->>Handlers: 통과
  end

  User->>Doc: touchend
  Handlers->>Handlers: startX/startY 초기화
  deactivate Handlers

  User->>Doc: gesturestart/change/end
  Handlers->>Doc: preventDefault() (제스처 전면 차단)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

귀 쫑긋, 스와이프 금지 깃발 펄럭여요 🏳️
왼쪽? 오른쪽? 나, 토끼 경비병이 보초 서요.
diffX가 크면 “멈춰!” 하고 발 구르기 탁—
수직 발걸음만 살짝살짝 통과 OK.
제스처 바람도 잠깐, 오늘은 출입 금지!

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/savedbook-hotfix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ljh130334 ljh130334 added the 🐞 BugFix Something isn't working label Sep 1, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (5)
index.html (5)

22-22: touchstart에 passive:false는 불필요

해당 핸들러에서 preventDefault를 호출하지 않으므로 passive:true로 바꿔 스크롤 성능 힌트를 주는 것이 안전합니다.

-      }, { passive: false });
+      }, { passive: true });

33-37: return false는 addEventListener 컨텍스트에서 무의미

preventDefault/stopPropagation만으로 충분합니다. 혼동 방지를 위해 제거 권장.

         if (diffX > 5 && diffX > diffY) {
           e.preventDefault();
           e.stopPropagation();
-          return false;
         }

38-38: capture + passive:false는 전역 성능·호환성 영향 가능

문서 캡처 단계에서 비수동 touchmove는 메인 스레드 일을 늘립니다. 실제 페이지 스크롤/터치 지연이 없는지 RUM/프레임 드랍 지표로 확인 바랍니다. 문제가 있으면 iOS Safari에만 제한하거나(UA/feature detect), 캡처를 해제하는 대안을 검토하세요.


33-37: 수평 스와이프 전면 차단은 가로 스크롤 UI를 망가뜨릴 수 있음

수평 스크롤이 필요한 컴포넌트(가로 리스트/코드블록 등)에 escape 해놓는 것이 안전합니다. data-allow-x 같은 opt-out 훅 권장.

       document.addEventListener('touchmove', function(e) {
-        if (startX === null || startY === null) return;
+        if (startX === null || startY === null) return;
+        const target = e.target;
+        if (target && (target.closest('[data-allow-x]') || target.closest('[contenteditable="true"]') || /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName))) {
+          return; // 인터랙티브/허용 영역은 패스
+        }

46-56: gesture 이벤트는 비표준(Safari 전용) — 환경 가드 권장*

다른 브라우저에서는 존재하지 않습니다. 안전하게 기능 감지 후 등록하거나 try/catch로 감싸세요.

-      document.addEventListener('gesturestart', function(e) {
+      if ('ongesturestart' in window) document.addEventListener('gesturestart', function(e) {
         e.preventDefault();
       }, { passive: false });
-      document.addEventListener('gesturechange', function(e) {
+      if ('ongesturechange' in window) document.addEventListener('gesturechange', function(e) {
         e.preventDefault();
       }, { passive: false });
-      document.addEventListener('gestureend', function(e) {
+      if ('ongestureend' in window) document.addEventListener('gestureend', function(e) {
         e.preventDefault();
       }, { passive: false });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a2c4500 and 92266d9.

📒 Files selected for processing (1)
  • index.html (1 hunks)
🔇 Additional comments (2)
index.html (2)

17-22: 세로 추적(startY/diffY) 추가는 방향성 판별에 유효

수평/수직 분기 정확도가 좋아집니다. 이 부분은 유지 추천합니다.

Also applies to: 28-31


33-37: 임계값 5px은 오탭 가능성↑ — 실제 기기에서 재검증 필요

약간의 손 떨림에도 가로 판정될 수 있습니다. 주요 디바이스(iOS/Android, 저/고 DPI)에서 뉴스피드 세로 스크롤 시 오차 판정 비율을 확인해 주세요. 필요시 6~8px로 미세 조정 제안.

Comment thread index.html Outdated
Comment thread index.html
@ljh130334 ljh130334 merged commit 3c15ff9 into develop Sep 1, 2025
3 checks passed
@ljh130334 ljh130334 deleted the feat/savedbook-hotfix branch September 9, 2025 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 BugFix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant