Skip to content

Commit

Permalink
Update scrollable-tweets.component.js
Browse files Browse the repository at this point in the history
  • Loading branch information
eashaw committed Oct 6, 2023
1 parent 4dfb325 commit f4cc526
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions website/assets/js/components/scrollable-tweets.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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));
Expand Down

0 comments on commit f4cc526

Please sign in to comment.