Refactoring thumbnail scroll code to fix jumps

Fixes #3230 and supersedes #3243.

This PR does a couple of things:

- Fixes thumbnail jumps as described in #3230 in a cleaner way than the previous PR, that is with almost no JavaScript.

- Improves the thumbnail view by adding a bit more margin between the thumbnails. Also, the last thumbnail is given a larger bottom margin to make it look the same as the top of the thumbnail view.

- The code style for the piece of code this PR touches has been updated to adhere to the coding standards.

*The thumbnail value is explained as follows: each thumbnail has a 7px wide border. Therefore, the top and bottom border both take up 7px + 7px = 14px. The margin between the thumbnails is 5px, which gives a total margin of 14px + 5px = 19px to move to make the thumbnails show up properly.*