Skip to content

Instantly share code, notes, and snippets.

@TechWithTy
Created August 16, 2019 00:07
Show Gist options
  • Save TechWithTy/539d353162a0f49421c9c805ba5c7f2b to your computer and use it in GitHub Desktop.
Save TechWithTy/539d353162a0f49421c9c805ba5c7f2b to your computer and use it in GitHub Desktop.
Calculate Scroll Distance until the bottom of products
const setScrollDistance = product => {
const productRowLength = Math.ceil(product.length / 4);
switch (productRowLength) {
case 4:
if (counter === 0) {
setItems(productRowLength * 350 + mobile);
} else {
setItems(productRowLength * 530 + mobile);
}
break;
case 1:
setItems(productRowLength * 1000);
break;
case 2:
setItems(productRowLength * 650);
break;
case 3:
setItems(productRowLength * 580);
break;
default:
setItems(productRowLength * 530);
break;
}
};
@TechWithTy
Copy link
Author

(product.length / 4) Number of itmes per row

@TechWithTy
Copy link
Author

TechWithTy commented Aug 16, 2019

@TechWithTy
Copy link
Author

TechWithTy commented Aug 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment