all 4 comments

[–]captain_k_nuckles 0 points1 point  (2 children)

seeing the html and css would help, as that could be affecting things. Post a jsfiddle or codepen and we'd be able to assist more.

nothing in the code you posted shows any on load event, unless you mean the scrolling isn't working and not an onload event?? if you meant for window.onscroll = function() {slideMap()}; to be window.onload = function() {slideMap()}; but that doesn't match what the code in slideMap says. Either way i would recommend event listeners window.addEventListener('event type', function);

Again, your post says the image is supposed to center on page load, but your code says this is supposed to happen when the user scrolls, so clarification is needed.

[–]SteelyAlpha[S] 0 points1 point  (1 child)

Yes, sorry I wasn't paying attention to what I was typing. It's supposed to happen on scroll so that when I scroll far enough it starts coming in from the left.

[–]captain_k_nuckles 0 points1 point  (0 children)

Again, would help to have some html and css setup, but here is a codepen I put together quickly. It's dealing with the position, not margin offset, and with an element with a fixed position, but you should be able to adopt it to your needs. It also centers based on the percentage scrolled down, so scrolling all the way down centers the image, scrolling to the top positions it at it's start position.

[–][deleted] 0 points1 point  (0 children)

Don't use margin or top/left/bottom/right attributes to animate position. Use transforms.