Created
August 16, 2019 00:07
-
-
Save TechWithTy/539d353162a0f49421c9c805ba5c7f2b to your computer and use it in GitHub Desktop.
Calculate Scroll Distance until the bottom of products
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
}; |
Working VIdeo Desktop
https://drive.google.com/file/d/1vSO-uyNPlNEyLX8mKYCGOax1XArWM1vn/view
Works on Mobile Too! https://drive.google.com/file/d/1oP8N-xHYgRKOtvI43T2G0WR7UXgktUgH/view?usp=sharing
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(product.length / 4) Number of itmes per row