Skip to content

Instantly share code, notes, and snippets.

@gka gka/script.js Secret
Created Aug 15, 2016

Embed
What would you like to do?
horizontal scrolling
var scroll_pct = 0,
aspect_ratio = dimensions[0]/dimensions[1],
vw_height = $(window).height();
layoutDesktop();
window.onscroll = function() {
scroll_pct = window.scrollY / (document.body.scrollHeight - window.innerHeight);
$('.g-composite').css('left', '-' + (scroll_pct * (artboard_width - window.innerWidth)) + 'px');
};
window.onresize = _.throttle(layoutDesktop, 400);
function layoutDesktop() {
vw_height = $(window).height();
artboard_width = vw_height * aspect_ratio;
$(".g-composite").width(artboard_width);
$(".g-composite-wrapper").height(vw_height*aspect_ratio);
$('.g-composite').css('left', '-' + (scroll_pct * (artboard_width - window.innerWidth)) + 'px');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.