pixxelfactory / jInvertScroll

A lightweight jQuery vertical scroll - horizontal move plugin with parallax effect.
http://www.pixxelfactory.net/jInvertScroll
MIT License
786 stars 156 forks source link

Elementoffset scroll to the center of the element #29

Open cvalues opened 1 year ago

cvalues commented 1 year ago

Hi,

`
e.preventDefault(); var target = '.'+$(this).data('target'); var left = $(target).position().left; var total = $('.front.scroll').width(); var perc = left / (total - $(window).width()) * 100;

    var height = $('html').height();
    var final = ((height - $(window).height())/ 100 * perc);

    $('html, body').animate({scrollTop: final}, 500);

`

Scrolls the selected item to the left corner. How to scroll to the element center?

var perc = left / (total - ($(window).width()+ $(target).width)/2 ) * 100;

Does not do the trick BR