Article View: pl.comp.lang.javascript
Article #51420czy to tylko u mnie tak nie działa
From: nkab
Date: Thu, 20 Mar 2014 09:22
Date: Thu, 20 Mar 2014 09:22
103 lines
2937 bytes
2937 bytes
Ilekroć jest mowa o al'a klasach w JS to sprawdzam
czy to działa bo miałem już z tym kłopoty.
Trafiłem na tego tutka http://www.youtube.com/watch?v=coIsvOMYEi0
i tam ten skrypt działa a u mnie nie działa,
bo wszystkie kręcą się jednakowo a środkowy napis
powinien kręcić się odwrotnie.
Czy u was też tak jest?
****************************
<!DOCTYPE html>
<html>
<script>
function rotAnim()
{
this.d=0;
this.anim=function anim(el,dir)
{
elem=document.getElementById(el);
me=this;
if(dir=="ccw")
{
//alert('el='+el+' dir='+dir+' d='+this.d )
this.d--;
//alert('el='+el+' dir='+dir+' d='+this.d )
}
else
{
this.d++;
}
elem.style.transform="rotate("+this.d+"deg)";
d1.innerHTML='el='+el+' cw='+dir+' d='+this.d;
//alert('ok..')
if(this.d>359)
this.d=1;
else
if(this.d<-359)
this.d=-1;
setTimeout(function(){me.anim(el,dir);}, 20);
}
}
</script>
<body>
<span id="n1">nap1</span>
<span id="n2">nap2</span>
<span id="n3">nap3</span>
<br><br><br><br>
<div id="d1">div...</div>
<script>
var On1 = new rotAnim();
var On2 = new rotAnim();
var On3 = new rotAnim();
On1.anim("n1","cw");
On2.anim("n2","ccw");
On3.anim("n3","cw");
</script>
</body>
</html>
**********************************
Tak na marginesie, jak dam deklarację w rotAnim() z var,
tak jak w tutku, to wogóle nie działa,
chociaż sam od początku poznawania JS pisałem "var"
tylko przy deklaracjach bez przypisanych wartości.
Andrzej.
Technical Details
Message-ID:
<4736d244-719a-4a5e-9d65-e6805ca5c970@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin2!goblin.stu.neva.ru!feeder.erje.net!us.feeder.erje.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!hw13no6467636qab.1!news-out.google.com!du2ni7482qab.0!nntp.google.com!w5no6496451qac.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Received: by 10.58.85.3 with SMTP id d3mr7823390vez.40.1395307337815; Thu, 20 Mar 2014 02:22:17 -0700 (PDT) X-Received: by 10.140.20.77 with SMTP id 71mr33585qgi.17.1395307337757; Thu, 20 Mar 2014 02:22:17 -0700 (PDT) Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin2!goblin.stu.neva.ru!feeder.erje.net!us.feeder.erje.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!hw13no6467636qab.1!news-out.google.com!du2ni7482qab.0!nntp.google.com!w5no6496451qac.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: pl.comp.lang.javascript Date: Thu, 20 Mar 2014 02:22:17 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=31.183.1.64; posting-account=xnOwqAoAAAAJ48pUkVrL2a6sJByqdB8s NNTP-Posting-Host: 31.183.1.64 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <4736d244-719a-4a5e-9d65-e6805ca5c970@googlegroups.com> Subject: czy to tylko u mnie tak nie działa From: nkab@toya.net.pl Injection-Date: Thu, 20 Mar 2014 09:22:17 +0000 X-Received-Bytes: 2692 X-Received-Body-CRC: 173645164 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit