Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batchInsert에서 사용하는 addedElements 배열과 elIdx값의 싱크가 맞지 않습니다. #887

Open
hynarin-crema opened this issue Aug 28, 2024 · 3 comments
Assignees
Labels
🔖4.x v4.x~ related issue 🐛Bug Bugs

Comments

@hynarin-crema
Copy link

hynarin-crema commented Aug 28, 2024

Description

안녕하세요.
sync 함수에서 실행되는 batchInsert에 대해 문의드립니다.
diffResult.added가 [0, 2, 3]일 경우, [0, 2]에 대해서 batchInsert함수가 한번 실행되고 [3]에 대해서 batchInsert함수가 한번 더 실행됩니다.

[3]에 대해서 batchInsert함수가 호출될 때 리턴하는 element가 잘못 지정되고 있습니다.
(이때 addedElements는 [0번째 요소, 2번째 요소, 3번째 요소]이고, startIdx는 2입니다.)
elIdx는 항상 0부터 시작하여, element의 값으로 addedElements[2]가 아닌 addedElements[0]이 할당되고 있습니다.
그 결과 addedElements[2]에 동적으로 width가 할당되지 않는 문제가 발생하고 있습니다. 확인 부탁드립니다.

Steps to check or reproduce

sync 함수를 아래와 같이 수정해야 하지 않을까 싶습니다.

...
if (diffResult.added.length > 0) {
    var startIdx_1 = -1;
    var prevIdx_2 = -1;
    var addedElements_1 = rendered.slice(prevList.length);
    diffResult.added.forEach(function (addedIdx, idx) {
      if (startIdx_1 < 0) {
        startIdx_1 = idx;
      }
      if (prevIdx_2 >= 0 && addedIdx !== prevIdx_2 + 1) {
        added.push.apply(added, __spread(batchInsert(renderer, diffResult, addedElements_1, startIdx_1, idx + 1)));
        startIdx_1 = -1;
        prevIdx_2 = -1;
      } else {
        prevIdx_2 = addedIdx;
      }
    });
    if (startIdx_1 >= 0) {
     // 수정한 부분: addedElements_1 -> addedElements_1.slice(startIdx_1)
      added.push.apply(added, __spread(batchInsert(renderer, diffResult, addedElements_1.slice(startIdx_1), startIdx_1)));
    }
...
@hynarin-crema hynarin-crema reopened this Sep 1, 2024
@malangfox malangfox self-assigned this Sep 4, 2024
@malangfox malangfox added 🐛Bug Bugs 🔖4.x v4.x~ related issue labels Sep 4, 2024
@malangfox
Copy link
Contributor

안녕하세요 @hynarin-crema 님.

전달 주신 부분을 수정하여 @egjs/flicking 4.11.5-beta.4 버전과 @egjs/react-flicking 4.11.5-beta.4 버전이 배포되었습니다.
위 버전의 패키지를 사용해보시고 겪고 계신 이슈가 해결되었는지 확인이 가능할까요?
만약 다른 프레임워크의 패키지를 사용 중이시라면 해당 프레임워크를 위한 패키지 또한 베타 버전으로 배포하도록 하겠습니다.

감사합니다.

@hynarin-crema
Copy link
Author

hynarin-crema commented Sep 11, 2024 via email

@malangfox
Copy link
Contributor

@hynarin-crema

@egjs/vue-flicking 및 @egjs/vue3-flicking의 4.11.5-beta.4 버전이 배포되었습니다.
해당 버전의 패키지를 이용해보시면 되겠습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔖4.x v4.x~ related issue 🐛Bug Bugs
Projects
None yet
Development

No branches or pull requests

2 participants