Jump to content

JS autoscroll

stefanmz

Hey so I have an animation of a ninja sprite running down and slicing with his sword and for it to look good it has to be  on one line of the page(all the images are inline they are on one line) and at some point it goes out of the creen and I have to scroll. I was wondering how do I use this to set the scrolling position to the Y of the ninja so it autoscrolls when he goes off screen

const el = document.querySelector('.btn');
// set scroll position in px
el.scrollLeft = ninja.x?

let's say the object is named ninja,so how do I make this correct?

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×