/    Sign up×
Community /Pin to ProfileBookmark

text dynamics, help me sort it out…Please!

Well, I found that script on a site, it’s made to control several types of animations…

I changed some parameters to have it do what I want but then it was slow (because the browser was doing things it shouldn’t) and when I tried to ‘clean out’ the script from unneccesary info, it stopped working properly…

I’m still a newbie at JS… That’s probably why I couldn’t make it to work properly… ?

Take a look here: a [URL=http://www.scriptsplus.com/scripts/image/dynamique.php#]Sample[/URL] (when you are on that page click on “Voir l’exemple” to see the sample)

The thing I want to do is to have the whole alphabet fall down, letter by letter, from the top of the page on page load (it’s what ‘Exemple3’ does on the sample…) but when I change the number of ‘steps’ to 24, it slows down so much it doesn’t look good anymore!!! ?

Can you help me with this??? Thanx

Here’s the code:

[b]<SCRIPT>
dynamicanimAttr = “hdynamicanimation”
animateElements = new Array()
currentElement = 0
speed = 0
stepsZoom = 8
stepsWord = 8
stepsFly = 12
stepsSpiral = 16
steps = stepsZoom
step = 0
outString = “”
function hdynAnimation()
{
var ms = navigator.appVersion.indexOf(“MSIE”)
ie4 = (ms>0) && (parseInt(navigator.appVersion.substring(ms+5, ms+6)) >= 4)
if(!ie4)
{
if((navigator.appName == “Netscape”) &&
(parseInt(navigator.appVersion.substring(0, 1)) >= 4))
{
for (index=document.layers.length-1; index >= 0; index–)
{
layer=document.layers[index]
if (layer.left==10000)
layer.left=0
}}
return
}
for (index=document.all.length-1; index >= document.body.sourceIndex; index–)
{
el = document.all[index]
animation = el.getAttribute(dynamicanimAttr, false)
if(null != animation)
{
if(animation == “dropWord” || animation == “flyTopRightWord” || animation == “flyBottomRightWord”)
{
ih = el.innerHTML
outString = “”
i1 = 0
iend = ih.length
while(true)
{
i2 = startWord(ih, i1)
if(i2 == -1)
i2 = iend
outWord(ih, i1, i2, false, “”)
if(i2 == iend)
break
i1 = i2
i2 = endWord(ih, i1)
if(i2 == -1)
i2 = iend
outWord(ih, i1, i2, true, animation)
if(i2 == iend)
break
i1 = i2
}
document.all[index].innerHTML = outString
document.all[index].style.posLeft = 0
document.all[index].setAttribute(dynamicanimAttr, null)
}
if(animation == “zoomIn” || animation == “zoomOut”)
{
ih = el.innerHTML
outString = “<SPAN ” + dynamicanimAttr + “=”” + animation + “” style=”position: relative; left: 10000;”>”
outString += ih
outString += “</SPAN>”
document.all[index].innerHTML = outString
document.all[index].style.posLeft = 0
document.all[index].setAttribute(dynamicanimAttr, null)
}}}
i = 0
for (index=document.body.sourceIndex; index < document.all.length; index++)
{
el = document.all[index]
animation = el.getAttribute(dynamicanimAttr, false)
if (null != animation)
{
if(animation == “flyLeft”)
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = 0
}
else if(animation == “flyRight”)
{
el.style.posLeft = 10000-offsetLeft(el)+document.body.offsetWidth
el.style.posTop = 0
}
else if(animation == “flyTop” || animation == “dropWord”)
{
el.style.posLeft = 0
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == “flyBottom”)
{
el.style.posLeft = 0
el.style.posTop = document.body.scrollTop-offsetTop(el)+document.body.offsetHeight
}
else if(animation == “flyTopLeft”)
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == “flyTopRight” || animation == “flyTopRightWord”)
{
el.style.posLeft = 10000-offsetLeft(el)+document.body.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == “flyBottomLeft”)
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)+document.body.offsetHeight
}
else if(animation == “flyBottomRight” || animation == “flyBottomRightWord”)
{
el.style.posLeft = 10000-offsetLeft(el)+document.body.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)+document.body.offsetHeight
}
else if(animation == “spiral”)
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = document.body.scrollTop-offsetTop(el)-el.offsetHeight
}
else if(animation == “zoomIn”)
{
el.style.posLeft = 10000
el.style.posTop = 0
}
else if(animation == “zoomOut”)
{
el.style.posLeft = 10000
el.style.posTop = 0
}
else
{
el.style.posLeft = 10000-offsetLeft(el)-el.offsetWidth
el.style.posTop = 0
}
el.initLeft = el.style.posLeft
el.initTop = el.style.posTop
animateElements[i++] = el
}}
window.setTimeout(“animate();”, speed)
}
function offsetLeft(el)
{
x = el.offsetLeft
for (e = el.offsetParent; e; e = e.offsetParent)
x += e.offsetLeft;
return x
}
function offsetTop(el)
{
y = el.offsetTop
for (e = el.offsetParent; e; e = e.offsetParent)
y += e.offsetTop;
return y
}
function startWord(ih, i)
{
for(tag = false; i < ih.length; i++)
{
c = ih.charAt(i)
if(c == ‘<‘)
tag = true
if(!tag)
return i
if(c == ‘>’)
tag = false
}
return -1
}
function endWord(ih, i)
{
nonSpace = false
space = false
while(i < ih.length)
{
c = ih.charAt(i)
if(c != ‘ ‘)
nonSpace = true
if(nonSpace && c == ‘ ‘)
space = true
if(c == ‘<‘)
return i
if(space && c != ‘ ‘)
return i
i++
}
return -1
}
function outWord(ih, i1, i2, dyn, anim)
{
if(dyn)
outString += “<SPAN ” + dynamicanimAttr + “=”” + anim + “” style=”position: relative; left: 10000;”>”
outString += ih.substring(i1, i2)
if(dyn)
outString += “</SPAN>”
}
function animate()
{
el = animateElements[currentElement]
animation = el.getAttribute(dynamicanimAttr, false)
step++
if(animation == “spiral”)
{
steps = stepsSpiral
v = step/steps
rf = 1.0 – v
t = v * 2.0*Math.PI
rx = Math.max(Math.abs(el.initLeft), 200)
ry = Math.max(Math.abs(el.initTop), 200)
el.style.posLeft = Math.ceil(-rf*Math.cos(t)*rx)
el.style.posTop = Math.ceil(-rf*Math.sin(t)*ry)
}
else if(animation == “zoomIn”)
{
steps = stepsZoom
el.style.fontSize = Math.ceil(50+50*step/steps) + “%”
el.style.posLeft = 0
}
else if(animation == “zoomOut”)
{
steps = stepsZoom
el.style.fontSize = Math.ceil(100+200*
(steps-step)/steps) + “%”
el.style.posLeft = 0
}
else
{
steps = stepsFly
if(animation == “dropWord” || animation == “flyTopRightWord” || animation == “flyBottomRightWord”)
steps = stepsWord
dl = el.initLeft / steps
dt = el.initTop / steps
el.style.posLeft = el.style.posLeft – dl
el.style.posTop = el.style.posTop – dt
}
if (step >= steps)
{
el.style.posLeft = 0
el.style.posTop = 0
currentElement++
step = 0
}
if(currentElement < animateElements.length)
window.setTimeout(“animate();”, speed)
}
</script>

<body onload=”hdynAnimation()”>

<!– available dynamics : flyTop,flyBottom,flyRight,flyLeft,flyTopLeft,flyTopRight,flyBottomLeft,flyBottomRight–>
<!– dropWord(texte),zoomIn(texte),zoomOut(texte) et spiral !–>

<p align=center hdynamicanimation=”zoomIn” style=”position:relative !important;left:10000 !important”>Exemple 1</p>[/b]

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@nashauthorApr 05.2003 — Well, if you don't feel like editing this script and know a place were I can find a "pre-made" script that will do the job, it would be fine with me!!! ?
Copy linkTweet thisAlerts:
@nashauthorApr 07.2003 — well, errr.... *bump*?
Copy linkTweet thisAlerts:
@DaveSWApr 07.2003 — Comment dit on "well, errr.... *bump*" en anglais? lol.? I'm not sure exactly what you want, but is it something like this????

[URL]http://www.emdevelopments.co.uk/Nash/[/URL]

Je ne sais pas??? (French is another of my a-level subjects lol.)

Dave
Copy linkTweet thisAlerts:
@nashauthorApr 08.2003 — Merci beaucoup Dave!!!

that's exactly what I was looking for! ?

*does happy dance* ?

Is there a way for me to simply control the speed???

I'm sure the speed might change and be slower or faster depending how far down on the page the text will get!!!
Copy linkTweet thisAlerts:
@DaveSWApr 08.2003 — If you edit the fourth line down in the js script: 'speed = 0' I think this controls the time taken to reach the place it has to be on the page. If you set it to 1000 it is very slow, 100 is reasonable, and 0 means it goes as fast as it can.

Just speed alone... Je ne sais pas... I like that phrase. C'est tres utile!!

Dave
Copy linkTweet thisAlerts:
@nashauthorApr 08.2003 — Merci encore!

I'll try that... ? your french is good! Usually people only know:

"Au Revoir" or "Voulez vous coucher avec moi?" ?
Copy linkTweet thisAlerts:
@DaveSWApr 08.2003 — Pas de probleme! ?

J'etudie la Francais dans ecole. Mon Prof est Francaise aussi(Normandie).

My French gets me round France quite regularly, but it still isn't as good as your English (I won't be going into any French forums!!).

One question that keeps bugging me: Do French Keyboards have keys for all the letters with accents? My French teacher doesn't seem to know...

Dave
×

Success!

Help @nash 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.18,
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,
)...