0

I've just tried to use the weather icons a few times in one page. http://weathericons.char95.com/

but the problem is ID in canvas:

<canvas id='icon1'></canvas>
<canvas id='icon'></canvas>
<canvas id='icon1'></canvas>


var icon1 = WeatherIcon.add('icon1', WeatherIcon.SUN, {mode:WeatherIcon.NIGHT, stroke:true, shadow:true, animated:true } );

I think, the problem is in "ID". I have to use the "CLASS". But I don't know how the change the code.

lokalinjo
  • 27
  • 4
  • do you get any errors? Try to add width and heigh attributes in your canvas. Eg ` `. Also use `icon1.play()` to play the first icon animation. Then stop it when you need with `icon1.stop();` and start the other `icon2.play();`. As I understand you haven't undesrant html programming yet. Why do you don't copy the whole example code from the website you given and play with it ? –  Jun 07 '16 at 10:53
  • try to use the example from the website. And get a nice JS book. :) I recomend: http://shop.oreilly.com/product/9780596805531.do –  Jun 07 '16 at 10:59
  • Thanks, I need the change the ID to class. In this case I can use multiple the same icon. I don't know how to do it. – lokalinjo Jun 07 '16 at 11:04

1 Answers1

0

HTML/PHP/CSS is no problem, but I'm not fit in Javascrpit.

    <script type='text/javascript' src='WeatherIcon.js'></script>


<canvas id='icon1'></canvas>
<canvas id='icon2'></canvas>
<canvas id='icon3'></canvas>



<script type='text/javascript'>

WeatherIcon.add('icon1' , WeatherIcon.SUN , { mode:WeatherIcon.DAY  , stroke:true , shadow:true , animated:true } );
WeatherIcon.add('icon2' , WeatherIcon.LIGHTRAINSUN , { mode:WeatherIcon.NIGHT   , stroke:true , shadow:true , animated:true } ); 
WeatherIcon.add('icon3' , WeatherIcon.LIGHTRAINTHUNDERSUN ); // no parameters

JS: http://weathericons.char95.com/js/WeatherIcon.js

lokalinjo
  • 27
  • 4
  • if the library takes as argument *only * `id` then you can't change to `class`. If the examples work only for `id's` then it's the structure of the library. –  Jun 07 '16 at 11:09
  • There is some other example: http://stackoverflow.com/questions/24572100/skycons-cant-display-the-same-icon-twice thay use the CLASS instead of ID. – lokalinjo Jun 07 '16 at 11:12
  • glad you solved it. To be honest I didn't understand what do you asked. There was no question, actually. You just said "but the problem is ID in canvas:". Please read about how to ask in stcackoverflow here so to be more detailed and let the community help you better. See the full guidelines here: https://stackoverflow.com/help/asking –  Jun 08 '16 at 09:54