For my portfolio section i've combined two scripts to be able to filter by category and be able to scroll horizontally through the images.

The scrolling works (does some weird jumping but still works), the bigger issue arises when you filter by category. The thumbnail animates off the screen so it can't be seen (and if you scroll it never shows up at all). You can see an example of what it's doing here: just click on one of the category buttons.

Can anyone advise me on why this is doing that and how to go about fixing it to where when someone clicks on a category it resets to the start?

Here is the jQuery being used in a single file:

Thank You.