Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-ds-1806 committed Mar 7, 2020
1 parent 7ec5502 commit 8e026a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions public/scripts/cards.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var cards = document.querySelectorAll('div.card');
for (let i = 0; i < cards.length; i = i + 2) {
cards[i].addEventListener('click', function (e) {
const wrapper = document.querySelector('div.scroll-wrapper');
e.preventDefault();
wrapper.scrollLeft = this.offsetLeft - 100;
if (cards[i + 1].style.width === '0px') {
closeAll();
cards[i + 1].style.width = '45vh';
Expand Down
3 changes: 2 additions & 1 deletion public/scripts/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ window.addEventListener('load', function (e) {
} else {
var scrollAmount = card.clientWidth + Number(window.getComputedStyle(card).marginLeft.substring(0, 1)) + Number(window.getComputedStyle(prevCard).marginRight.substring(0, 2));
}
var delay = 3000;
var delay = 5000;
wrapper.forEach(slider => {
setInterval(function () {
slider.scrollLeft = slider.scrollLeft + scrollAmount;
if (Math.abs(Math.floor(slider.scrollLeft) - Math.floor(slider.scrollWidth - slider.clientWidth)) <= 1) {
slider.scrollLeft = 0;
}
}, delay);

right.forEach(right => {
right.addEventListener('click', function (e) {
slider.scrollLeft = slider.scrollLeft + scrollAmount;
Expand Down

0 comments on commit 8e026a7

Please sign in to comment.