View Full Version : [DHTML] Animated cursors anyone?
02-14-2007, 04:50 PM
1) CODE TITLE: Animated cursors
2) AUTHOR NAME: Shachi Bista
3) DESCRIPTION: Lets you have "animated" cursors in FF.
4) URL TO CODE: http://shachi.prophp.org/animcur.html
5) NOTES: This isn't cross-browser. I didn't need to make it as IE already supports the .ani format. I got the cursor images from: http://www.maxthemes.com/guistuff/?guistuff=Wait%20Cursors and used http://www.xoyosoft.com/gs/index.htm to chop it down into different images then I used gimp to convert the bmps to pngs and then again used: http://converticon.com/ to convert the pngs icos and simply renamed them to a .cur extension. This script takes up some resources because of the constant setInterval after every 30 ms.
6) BROWSER COMPATIBILITY: Tested with, FF 188.8.131.52. Please feel free to test it and please post your name and version of firefox you test it with, it will be listed here. :)
Tested with FF1.5 -- by drj33 & jscheuer1 - Works fine :D
Tested with FF184.108.40.206 -- by jscheuer1 - Works fine :D
Tested with IE7 -- by jscheuer1 - Doesn't work.
Tested with Opera -- by jscheuer1 - Doesn't work
02-14-2007, 05:38 PM
It's a big buggy... the normal cursor shows up if you scroll too fast, click, etc.
The buttons don't seem to do anything.
The animation apparently loops every second or two, with a slight white flash between the beginning and end frames (at least I assume this is the case).
Though IE may already support this, it is a good idea to make it cross browser compatible. Right now you're making a FF only script, and that's a bad idea. Using .ani is fine, but you should include a browser check then, or better, function check, to determine if the .ani or your script should be used.
02-14-2007, 06:17 PM
No work in Opera. I think if you used .cur files instead of .png it might. I didn't see the problems like djr33 did. Worked fine in FF 1.5 unless I hit start it again without having first stopped it. You need some way to prevent multiple intervals. I'd try clearing at the beginning of the stop and start events (you are clearing timeout after reset but, there is no timeout):
<input type="button" value="Stop the animation" onclick="clearInterval(c);reset();">
<input type="button" value="Start it again" onclick="clearInterval(c);c = setInterval('changeCur()', 30);">
02-14-2007, 06:42 PM
jscheuer1: done with the changes you pointed out. I guess it is the problem with .pngs but the .curs I made are too small(or at least they appear too small).
02-14-2007, 09:19 PM
Works good in FF 220.127.116.11 now here. I just tried it out in IE 7 and, I am unsure why but, it doesn't work. I can tell you that the .png images try to load but never have a chance to get cached. Perhaps if you preloaded them it would work in IE 7. Or, IE 7 may also require .cur files. IE 7 does support the .ani files for animated cursors though.
02-15-2007, 12:15 AM
Good updates, whatever they were. All of the problems above (that both John and I had) are now fixed.
One issue is that the actual pixel at which the mouse is touching and interacting (the point of the arrow) is not any logical position in the sphere.... in fact, it's a point about 5px from the edge of the sphere.
02-15-2007, 04:10 AM
I see that too, more specifically it (the position of the unseen arrow tip) appears to be about 5px diagonally from the upper leftmost point of the animated cursor. This is not a huge deal. One thought I've been having in connection with this effect though is a different approach - that you could use a single transparent .cur file for the cursor and then position an animated .gif file based upon the mouse's coordinates. This might have the problem of the mouse seeming to be over the .gif when it needs to be over other elements on the page to trigger events.
02-15-2007, 07:43 AM
drj33: now, that's strange. I didn't do any updates(except the onclick events of the buttons).
drj33, jscheuer1: I am not sure about the pointer of the cursor. I hope to fix that soon(hopefully)
One thought I've been having in connection with this effect though is a different approach - that you could use a single transparent .cur file for the cursor and then position an animated .gif file based upon the mouse's coordinates. This might have the problem of the mouse seeming to be over the .gif when it needs to be over other elements on the page to trigger events.
That is a good idea too. If we do this we will not have to use setInterval thus not overloading the performance.
EDIT: I just realised where my Mouse object comes into action. And by the way I have changed the cursor extension to .cur too.
EDIT: Something just came to my mind. Usually when the cursor is busy the document.onmousedown function is canceled, so I don't think that the pointer would be much of a big problem. What do you think about it?
02-15-2007, 10:47 PM
Yeah i like this script! It looks nice.
02-18-2007, 06:21 AM
Thank you iMarc. :)
02-18-2007, 06:49 PM
Shachi, why do you always use "$" as a function name? Isn't it possible that it could be an invalid character when referring to with a global scope?
02-18-2007, 06:56 PM
What a minute... each frame is an individual image?
02-19-2007, 05:46 PM
why do you always use "$" as a function name? Isn't it possible that it could be an invalid character when referring to with a global scope?
I've got this horrible habit from using firebug. I try to avoid it but I always forget about it. I'll try to avoid it as much as possible. :(
What a minute... each frame is an individual image?
I guess you intended to type "Wait", well, yes each frame is an indivisual image(that's why it slows down the performance).
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.