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

Fix slide direction for two items #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ted537
Copy link

@ted537 ted537 commented Jul 7, 2022

Should close #192

@ChenCodes
Copy link

Hi @Learus , would you mind taking a look at this fix? I'm running into the same issue above and appreciate if this issue can be resolved :)

@ruinixu
Copy link

ruinixu commented Aug 11, 2022

Would also greatly appreciate this fix being merged in!

@ChenCodes
Copy link

Bump @Learus ! 🙏

@LoliDelgado
Copy link

I am seeing the same issue, will appreciate it if this fix is merged and released!

@yingWideop
Copy link

yingWideop commented Oct 14, 2022

So when will this fix be released? Having the same issue...🥲 Thank you in advance! @Learus

@jb19901234
Copy link

Having the same issues, would love to see release of the proposed fix.

In te mean time, how can I yarn add the repository including the fix?

@ted537
Copy link
Author

ted537 commented Jan 26, 2023

I hosted my fork here for my own npm install purposes: https://www.npmjs.com/package/@ted537/react-material-ui-carousel

Should work for anyone I believe

@grna
Copy link

grna commented Feb 2, 2023

@Learus I am facing the same problem...

@kamami
Copy link

kamami commented Apr 3, 2023

Any plans for merge?

@davidgl12
Copy link

I'm facing this problem currently, merging this would save me a lot of time in designing a workaround

@@ -111,7 +111,7 @@ export const CarouselItem = ({ animation, next, prev, swipe, state, index, maxIn
let animate = 'center';
if (index === active)
animate = 'center';
else if (index === prevActive)
else if (maxIndex>1 && index === prevActive)

Choose a reason for hiding this comment

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

This solution created a jitter effect where the current card would disappear and then would be replaced by the next card with a slide effect.. i have fixed that...

Suggested change
else if (maxIndex>1 && index === prevActive)
else if (index === prevActive)

Comment on lines +123 to +126
if (maxIndex > 1) {
if (active === maxIndex && index === 0) animate = 'rightOut';
if (active === 0 && index === maxIndex) animate = 'leftOut';
}

Choose a reason for hiding this comment

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

Suggested change
if (maxIndex > 1) {
if (active === maxIndex && index === 0) animate = 'rightOut';
if (active === 0 && index === maxIndex) animate = 'leftOut';
}
if (maxIndex === 1) {
if (active === maxIndex && index === 0) animate = 'leftOut';
if (active === 0 && index === maxIndex) animate = 'rightOut';
} else {
if (active === maxIndex && index === 0) animate = 'rightOut';
if (active === 0 && index === maxIndex) animate = 'leftOut';
}

@@ -111,7 +111,7 @@ export const CarouselItem = ({ animation, next, prev, swipe, state, index, maxIn
let animate = 'center';
if (index === active)
animate = 'center';
else if (index === prevActive)
else if (maxIndex>1 && index === prevActive)
{
animate = isNext ? 'leftwardExit' : 'rightwardExit';
if (active === maxIndex && index === 0) animate = 'rightwardExit';

Choose a reason for hiding this comment

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

replace the code in line 117, 118 with the following

Suggested change
if (active === maxIndex && index === 0) animate = 'rightwardExit';
if (maxIndex === 1) {
if (active === maxIndex && index === 0) animate = 'leftwardExit';
if (active === 0 && index === maxIndex) animate = 'rightwardExit';
} else {
if (active === maxIndex && index === 0) animate = 'rightwardExit';
if (active === 0 && index === maxIndex) animate = 'leftwardExit';
}

@RoiFordefi
Copy link

RoiFordefi commented Jul 27, 2023

this is solved already?
i still have this problem at version 3.4.2

@bishwo-pratap it's looks like you already have the solution in your hand, please fix whats necessary and get it in.

pretty please..

@hhlwt
Copy link

hhlwt commented Jun 19, 2024

this is solved already? i still have this problem at version 3.4.2

@bishwo-pratap it's looks like you already have the solution in your hand, please fix whats necessary and get it in.

pretty please..

Here is the fixed version
https://www.npmjs.com/package/react-material-ui-carousel-dromanov-fixed-version?activeTab=readme

npm i react-material-ui-carousel-dromanov-fixed-version

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.

Incorrect Slide direction with two items