Well, it's simply a matter of choice.
Using setTimeout is shorter, simpler, more readable and offers the
same performance. I consider these advantages. Maybe in some other
context setInterval would be a better fit, but in this case I'd go for
simplicity.
cheers,
- ricardo
On Jan 30, 3:56 am,
I'm not sure there is any difference in performance, most animations
use setTimeout instead of setInterval for better timing too (though
it's irrelevant in this case). And it would require a bit more code.
- ricardo
On Jan 29, 2:39 am, RobG rg...@iinet.net.au wrote:
On Jan 16, 3:15 am, Ricardo
On Jan 30, 6:57 am, Ricardo Tomasi ricardob...@gmail.com wrote:
I'm not sure there is any difference in performance,
Nor am I, who mentioned performance? It's about using the tool that's
intended for the job.
most animations
use setTimeout instead of setInterval for better timing too
Well, I should attach one class to all stickies, and fade loop them in
from there, just using class=sticky NumericValue
That would probably be the most elegant. Although to be fair, I rather
like the chaotic way in which they appear on screen.
On Jan 15, 12:42 pm, James Van Dyke
On Jan 16, 3:15 am, Ricardo Tomasi ricardob...@gmail.com wrote:
Can you add a single class sticky to all of the notes? Then do this:
$('.sticky:hidden').each(function(i){
var t = $(this);
setTimeout(function(){ t.fadeIn(500) }, i*100);
});
Rather than 9 calls to setTimeout,
I'm not sure what it is that its choking on. It doesnt throw any
errors in Firebug or Inspector
If I do
$(function() {
var i, numStickies = 9;
for (i = 1; i = numStickies; i += 1) {
setTimeout( function() {
$(.sticky1:hidden).fadeIn(500);
}, 100 * i);
}
front what I can tell it is not looping.
DJCarbon43 wrote:
I'm not sure what it is that its choking on. It doesnt throw any
errors in Firebug or Inspector
If I do
$(function() {
var i, numStickies = 9;
for (i = 1; i = numStickies; i += 1) {
setTimeout( function() {
ignore that, put the console.log() in the wrong place
Liam Potter wrote:
front what I can tell it is not looping.
DJCarbon43 wrote:
I'm not sure what it is that its choking on. It doesnt throw any
errors in Firebug or Inspector
If I do
$(function() {
var i, numStickies = 9;
for (i
Can you add a single class sticky to all of the notes? Then do this:
$('.sticky:hidden').each(function(i){
var t = $(this);
setTimeout(function(){ t.fadeIn(500) }, i*100);
});
Or if you can't change the classes:
$('[className^=sticky]:hidden').each(... //same as above
I'd prefer this
So, the code is working as expected?
As for how it works, I'm using a basic loop to run through the
numbers: http://www.w3schools.com/JS/js_loop_for.asp
Then, I'm just concatenating a string inside the $() function. Once
the string is concatenated, it will be passed to the $() function just
as
$(function() {
var i, numStickies = 9;
for (i = 1; i = numStickies; i += 1) {
setTimeout( function() {
$(.sticky + i + :hidden).fadeIn(500);
}, 100 * i);
}
});
Not sure if that's faster, but it's shorter and easier to change.
On Jan 14, 11:19 pm,
I haven't gotten it working yet, but I understand the concept, and its
brilliant!
Thank you very much!
On Jan 14, 11:28 pm, James Van Dyke jame...@gmail.com wrote:
$(function() {
var i, numStickies = 9;
for (i = 1; i = numStickies; i += 1) {
setTimeout( function() {
Let me know what's not working, and maybe I can help you out. I don't
have firebug handy, so I didn't test it.
On Jan 14, 11:44 pm, DJCarbon43 djcarbo...@gmail.com wrote:
I haven't gotten it working yet, but I understand the concept, and its
brilliant!
Thank you very much!
On Jan 14,
13 matches
Mail list logo