Would be nice to support centering like scrollIntoView()
munkeez-asa opened this issue · 2 comments
munkeez-asa commented
Here's is what I'm trying to replicate:
element.scrollIntoView({behavior: "smooth", block: "center", inline: "start"});
This works in some browsers, but unfortunately I need it to work in mobile Safari and it does not. That's why I'm looking at your plugin and it seems great except for the missing ability to specify that the target element should be scrolled toward the center of the container element instead of the top.
flesler commented
Center on screen? Should be doable by passing half the window height as negative offset.
Centering on the element could be doable with over: 0.5
if I remember correctly
brunoinds commented
With you wanna center to middle of "x" axis (as a carousel), use this code:
$(parent).scrollTo(elementToBeCentered, 300, {
over: 0.5,
axis: 'x',
offset: -$(parent).width() / 2
});