/    Sign up×
Community /Pin to ProfileBookmark

A question about js animation

I just startd some lessons and thoughted i’d create a lil something. I’m trying to animate a small png with a sequence of images in it in it. But whenever i load the page the animation never runs. I was wondering if you think this makes sense.

CSS:

#face_ani {
position:absolute;
bottom:-2px;
left: 105px;
background:url(images/face_ani.png) no-repeat 0px 200px;
width:363px;
height:456px;
overflow: visible;
background-attachment:fixed;
}

Javascript:

window.onload = InitAll

var frameTotal = new Array(12);

function InitAll() {
if (document.getElementById(“face_ani”).style.backgroundPositionX<360+”px”) {
for (var i=0; i<12; i++) {
var int=self.setInterval(“anim(i)”,71);
}
} else {
var int=window.clearInterval(int);
}

function anim(frame) {
var currFrame = frameTotal[frame];
document.getElementById(“face_ani”).style.backgroundPositionX = (currFrame*12)+”px”;
}

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Kblack21 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...