jInvertScroll icon indicating copy to clipboard operation
jInvertScroll copied to clipboard

Elementoffset scroll to the center of the element

Open cvalues opened this issue 3 years ago • 0 comments

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

cvalues avatar Oct 31 '22 08:10 cvalues