Here is what I've been working with. Everything is working great, except that if you scroll down a bit, you will see the alignment gets progressively more off as you scroll down. The #left
div should be moving via .css('top')
the same distance as the #right
div's scrollTop()
but over time, the place where the boxes interscect creeps up the containing div#innerScroller
.
If you compare where the frog lines up at first, to where it lines up the second time it appears, you will see my issue.
Don't worry about the handlebars stuff... the relevant JS is quite small:
var left = $('#left');
var leftHeight = left.height();
var leftTop = 0 - leftHeight + $('#right').height();
left.css('top', leftTop + 'px');
$('#right').on('scroll', function(){
var scro = parseFloat($('#right').scrollTop());
var goal = leftTop + scro;
left.css('top', goal + 'px');
});
Thanks!
Edit:
Just to say it, this works, but is very hackey and not the kind of solution I am looking for:
var scro = (parseFloat($('#right').scrollTop())) * 1.062;