Skip to content

Conversation

@gyutato
Copy link

@gyutato gyutato commented Oct 1, 2025

Issue

https://oss.navercorp.com/egjs/work/issues/2127

Details

  • flicking 컨테이너가 중첩된 경우, 특정 축(방향)의 flicking 이 시작되었을 때 다른 축 방향으로의 전파를 방지합니다.
  • 본 PR에서는, 자식 요소에서 시작된 flicking 이 부모에게 전파되는 것을 방지하는 로직만 구현하였습니다.

리뷰 요청 사항

  • 적절한 객체를 수정하였는지 (PanInput, InputObserver)
  • 기존 구조를 잘 보존하는 방식으로, 적절한 위치에 로직이 추가되었는지 (InputObserver.change, InputObserver.release)

@gyutato gyutato requested a review from daybrush October 1, 2025 02:35
@gyutato gyutato self-assigned this Oct 1, 2025
@CLAassistant
Copy link

CLAassistant commented Oct 1, 2025

CLA assistant check
All committers have signed the CLA.

!this.options.nested ||
!this._isEndofAxis(offset, depaPos, destPos) ||
/* 부모 전파 중단 조건 중, 최초 동작 축(방향)과 동일한 축인지 확인하는 조건 추가 */
!isSameAxis
Copy link
Member

Choose a reason for hiding this comment

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

isSameAxis 조건이 닿는지, 닿더라도 항상 true인지 확인해보시면 좋을 것 같아요.

자식이 양방향 드래그로 설정되어 있는 경우도 고려하시면 좋을 것 같아요.

Copy link
Author

Choose a reason for hiding this comment

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

@daybrush 제가 의도했던 '같은 축' 판단 조건은 다음과 같습니다:

  1. 최초 flicking 방향 (primary) 이 없으면 무조건 false
  2. 최초 방향이 HORIZONTAL 인 경우, 현재 input 의 input.axes 가 가로 단일 축일 때만 true
  3. 최초 방향이 VERTICAL 인 경우, 현재 input 의 input.axes 가 세로 단일 축일 때만 true

isSameAxis 가 항상 true 일 것이라고는 예상하지 못했는데, 혹시 제가 놓친 지점이 있는 것인지 확인 부탁드립니다!

Copy link
Member

@daybrush daybrush Oct 1, 2025

Choose a reason for hiding this comment

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

connect(["x", y"]) // both
connect(["", "y") // vertical
connect(["x", ""]) // horizontal

아마도 PanInput에서 관련없는 방향의 offset을 0으로 만들어버릴거에요.
그리고 offset이 0이면 위에서 거르는 조건이 있을거에요.

그러다보니까 isSameAxis를 지나가는 거라면 이미 같은 방향이라고 보고 있습니다

panEvent.preventSystemEvent = prevent;
/* 부모에게 전달되는 네이티브 이벤트 객체(srcEvent)에 방향 정보 추가 */
if (this._primaryDirection !== DIRECTION_NONE && panEvent && panEvent.srcEvent) {
(panEvent.srcEvent as any).__axesPrimaryDirection = this._primaryDirection;
Copy link
Member

Choose a reason for hiding this comment

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

자식에서도 설저할 수 있지만 부모에서도 바로 변경이 될 수 있어서 1번만 설정할 수 있게 하시는게 좋을 것 같아요.

Copy link
Author

Choose a reason for hiding this comment

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

반영했습니다 ffa2b88

@gyutato
Copy link
Author

gyutato commented Oct 1, 2025

피드백 (d4eae16)

기존 구조 설명

  • 시나리오: X축으로 드래그하다가 Y축으로 꺾는 경우
  • childrenAxesAlreadyChanged 등의 값은 자식 Observer가 세팅하는 관점
    • 해당 값을 사용하고 읽는 것은 부모가 함
  • 전체적인 구조: 조건 판단(자신의 동작 결정) + 값 세팅(전파할 값 설정)
  • PanInput: InputObserver 에게 숫자를 전달 (나(input) 에 의해 만들어진 offset 이 이렇다)
  • InputObserver: 전달받은 offset (거리) 를 좌표 상의 실제 이동 (?) 으로 변환한다

수정 제안

  • 기존 flag true 처리하는 로직이 아니라, return 문 부분으로 조건 이동
  • PanInput 에서 처리
    • stopPropagation 중단 로직을 추가
  • PrimaryDirection 설정 시, 한번 설정된 뒤로는 바꿀 수 없도록 가드 필요

Todos

  • 현재 코드가 잘 동작하는지 확인 (자식 > 부모 전파 방지)
  • 부모 > 자식으로 전파 막는 로직 (필요하다면) 추가
  • nested flicking 데모 파일 전달받기

!this._moveDistance
!this._moveDistance ||
/* 인터랙션 종료 시점에서도, 축 방향 확인을 위한 가드 추가 */
!this._isSameAxisWithPrimary(nativeEvent, input)
Copy link
Member

Choose a reason for hiding this comment

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

부모도 일단 시작은 발생했기 때문에 릴리즈가 발생해야될 것 같습니다.

@coveralls
Copy link

coveralls commented Oct 17, 2025

Coverage Status

coverage: 49.511% (-0.9%) from 50.406%
when pulling 88b5490 on gyutato:fix/nested-flicking
into d529450 on naver:master.

@gyutato gyutato changed the title fix: prevent nested flicking from child to parent (direction-based) fix: prevent nested flicking (direction-based) Oct 20, 2025
@gyutato
Copy link
Author

gyutato commented Oct 22, 2025

@daybrush 리뷰 요청드립니다.

Issue

https://oss.navercorp.com/egjs/work/issues/2127

Details

  • flicking 컨테이너가 중첩된 경우, 특정 축(방향)의 flicking 이 시작되었을 때 다른 축 방향으로의 전파를 방지합니다.
    • 후속 커밋을 통해, 자식에서 시작된 flicking 이 부모로 전파되는 것과, 부모에서 시작된 flicking 이 자식으로 전파되는 것 모두 방지하였습니다.
  • 자식에서 부모로 flicking 이 전파되는 경우, __axesPrimaryDirection 값을 기반으로 observer.isSameAxis 메서드를 통해 수직 축 flicking 을 제한합니다.
  • 부모에서 자식으로 flicking 이 전파되는 경우, 부모의 __inputStack 배열에 담긴 자식 객체들의 ignoreChange 메서드를 트리거하여 후속 change 트리거를 제한합니다.

리뷰 요청 사항

  • 적절한 객체를 수정하였는지 (PanInput, InputObserver)
  • 이벤트 별 로직이 적절하게 작성되어 있는지
    • onPanmove 내부, direction 결정 조건
    • onPanend 내부, velocity 를 0으로 초기화하는 로직

@gyutato gyutato requested a review from daybrush October 22, 2025 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants