From f4cc5260b022526fa52f38ff363cd90c5426d990 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 6 Oct 2023 18:01:10 -0500 Subject: [PATCH] Update scrollable-tweets.component.js --- .../assets/js/components/scrollable-tweets.component.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/assets/js/components/scrollable-tweets.component.js b/website/assets/js/components/scrollable-tweets.component.js index 0430944d353f..f40a2e9f57c8 100644 --- a/website/assets/js/components/scrollable-tweets.component.js +++ b/website/assets/js/components/scrollable-tweets.component.js @@ -157,9 +157,9 @@ parasails.registerComponent('scrollableTweets', { updateNumberOfTweetPages: async function() { // Get the width of the first tweet card. let firstTweetCardDiv = document.querySelector('div[purpose="tweet-card"]'); - this.tweetCardWidth = firstTweetCardDiv.clientWidth - 16; + this.tweetCardWidth = firstTweetCardDiv.clientWidth + 16; // Find out how may entire cards can fit on the screen. - this.numberOfTweetsPerPage = Math.floor(window.innerWidth / (this.tweetCardWidth + 16)); + this.numberOfTweetsPerPage = Math.floor(window.innerWidth / this.tweetCardWidth); // Find out how many pages of tweet cards there will be. this.numberOfTweetPages = Math.ceil(this.numberOfTweetCards / this.numberOfTweetsPerPage); // Update the current page indicator. @@ -173,9 +173,9 @@ parasails.registerComponent('scrollableTweets', { // Find out the width of a page of tweet cards let tweetPageWidth; if(this.numberOfTweetPages === 2 && this.numberOfTweetsPerPage > 3){ - tweetPageWidth = this.tweetCardWidth; + tweetPageWidth = (this.tweetCardWidth - 32); } else { - tweetPageWidth = this.tweetCardWidth * this.numberOfTweetsPerPage; + tweetPageWidth = (this.tweetCardWidth - 32) * this.numberOfTweetsPerPage; } // Set the maximum number of pages as the maximum value let currentPage = Math.min(Math.round(tweetsDiv.scrollLeft / tweetPageWidth), (this.numberOfTweetPages - 1));