Cosmic-Chatter / Exhibitera

Free and open-source software for building and controlling museum exhibits.
MIT License
2 stars 2 forks source link

code change to add a looping function for media browser #23

Open Code-Bagi opened 4 weeks ago

Code-Bagi commented 4 weeks ago

starting at line 5 in the media_browser.js file, you will see this:


function changePage (val) {
  switch (val) {
    case 0:
      currentPage = 0
      break
    case 1:
      // Calculate if there are more cards to show
      if ((currentPage + 1) * cardsPerPage < spreadsheet.length) {
        currentPage += 1
      }
      break
    case -1:
      currentPage -= 1
      if (currentPage < 0) {
        currentPage = 0
      }
      break
    default:
  }

The addition to a loop here provides ease for a user to get back to the first page of the slideshow once they have reached the end. The change in code to make this happen would look like this:


function changePage (val) {
  switch (val) {
    case 0:
      currentPage = 0
      break
    case 1:
      currentPage += 1
      if (currentPage * cardsPerPage >= spreadsheet.length) {
        currentPage = 0
      }
      break
    case -1:
      currentPage -= 1
      if (currentPage < 0) {
        currentPage = Math.floor((spreadsheet.length - 1 / cardsPerPage)) 
      }
      break
    default:
  }
forceflow1049 commented 4 weeks ago

Hi @Code-Bagi, thanks for the suggestion! I think this change makes sense, but can we think of any instances in which this would not be desirable behavior? If so, this behavior could be an option toggled during setup.

alexaverill commented 5 days ago

I think having this as the default would make sense, but having a toggle to turn it off would help incase someone didn't want it for whatever reason