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
On mount, carousel raises an error Cannot read properties of undefined (reading 'getIndex')
when circular option is set to true.
#616
Comments
Hello @kazvaggos! |
Hello @WoodNeck, Looking at the source code, the following lines break: The reason for this is because: let panelAtLeftBoundary!: Panel; // undefined
for (const panel of reversedPanels) {
if (!panel) {
continue;
}
sizeSum += panel.getSize() + gap;
if (sizeSum >= areaPrev) { // always false
panelAtLeftBoundary = panel; // never accessed
break;
}
}
// or
let panelAtRightBoundary!: Panel; // undefined
for (const panel of panels) {
if (!panel) {
continue;
}
sizeSum += panel.getSize() + gap;
if (sizeSum >= areaNext) { // always false
panelAtRightBoundary = panel; // never accessed
break;
}
}
// resulting:
// Throws 'Cannot read properties of undefined (reading 'getIndex')'
const needCloneOnPrev = panelAtLeftBoundary.getIndex() !== 0
&& panelAtLeftBoundary.getIndex() <= panelAtRightBoundary.getIndex(); Probably it can be reproduced if the carousel tries to mount on a div that is with style const needCloneOnPrev = panelAtLeftBoundary?.getIndex() !== 0
&& panelAtLeftBoundary?.getIndex() <= panelAtRightBoundary?.getIndex(); |
Certainly, it could be a possible cause for this issue. As there were a few issues related to panel size being 0 in the v3. |
@kazvaggos npm i @egjs/vue-flicking@latest-3 Please try that version, and reopen this issue if the bug still remains :) |
Description
"@egjs/vue-flicking": "3.8.0"
On mount, carousel raises an error
Cannot read properties of undefined (reading 'getIndex')
when circular option is set to true.It doesn't happen all the time, but we noticed this error happening a lot on our error monitor tool.
Steps to check or reproduce
Unfortunately we cannot reproduce it locally. But we know that it is in this line:
panelAtLeftBoundary
andpanelAtRightBoundary
start as undefined and one of them (or both) is not set in the for loops above this line.Is there a reason why this is happening? Is it possible to add an extra check if
panelAtLeftBoundary
andpanelAtRightBoundary
exist in this line so it doesn't throw?The text was updated successfully, but these errors were encountered: