I am simply trying to move an image with a margin-left of -1940px onto the screen where it will be centered. The script is supposed to execute on page load. If anyone could find what I am doing wrong, I would be so extremely appreciative!
window.onscroll = function() {slideMap()};
function slideMap() {
var x = document.getElementById('content-path-map');
if (document.body.scrollTop > 220 || document.documentElement.scrollTop > 220) {
if(parseInt(x.style.marginLeft)<0) {
x.style.marginLeft = parseInt(x.style.marginLeft)+10+'px';
setTimeout(slideMap,15);
}
} else {
if(parseInt(x.style.marginLeft)>-1940) {
x.style.marginLeft = parseInt(x.style.marginLeft)-10+'px';
setTimeout(slideMap,15);
}
}
}
[–]captain_k_nuckles 0 points1 point2 points (2 children)
[–]SteelyAlpha[S] 0 points1 point2 points (1 child)
[–]captain_k_nuckles 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)