Skip to content

Instantly share code, notes, and snippets.

@apsicle
Last active June 27, 2017 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apsicle/a305c1c3d1b468d3be905ea6f05d828b to your computer and use it in GitHub Desktop.
Save apsicle/a305c1c3d1b468d3be905ea6f05d828b to your computer and use it in GitHub Desktop.
@apsicle
Copy link
Author

apsicle commented Jun 27, 2017

This is the javascript file running on the gallery page on my portfolio site. It controls the image carousel at the focus of the screen as well as loading the descriptions on the sidebar when you click one of the buttons or directly on the carousel. I didn't feel like writing this as a class was necessary as I was just making this carousel unique to my galley site.

The first part of the script instantiates does some width / height checks in order to make the video-on-hover effect look better for different aspect ratios (in case the video doesn't exactly cover the image on the carousel, we just make the image disappear so there's no jarring overlap between the image and the video).

The load_carousel function creates the carousel, calculating the geometry of the image carousel, and performs the CSS transforms on the images from the HTML file to generate the effect.

The rest of the functions are used to control animations / effects such as rotating the carousel to a panel, or displaying the text associated with each panel. Most of these are bound to HTML elements so they occur on click.

The $(window).load() function is called when the assets are loaded to show a smooth transition into the gallery screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment