greenmelon

cursor trail

Jan 5th, 2022 (edited)
1,907
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. <script language="JavaScript1.2">
  2. <!--
  3.  
  4. /*
  5. Submitted by Marcin Wojtowicz [one_spook@hotmail.com]
  6. Featured on JavaScript Kit (http://javascriptkit.com)
  7. Modified by JK to be IE7+/ Firefox compatible
  8. For this and over 400+ free scripts, visit http://javascriptkit.com
  9. */
  10.  
  11. var trailLength = 12 // The length of trail (8 by default; put more for longer "tail")
  12. var path = "https://tomomi.neocities.org/pixeles/145.gif"// URL of your image
  13.  
  14. var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
  15. var i,d = 0
  16.  
  17. function initTrail() { // prepares the script
  18. images = new Array() // prepare the image array
  19. for (i = 0; i < parseInt(trailLength); i++) {
  20. images[i] = new Image()
  21. images[i].src = path
  22. }
  23. storage = new Array() // prepare the storage for the coordinates
  24. for (i = 0; i < images.length*3; i++) {
  25. storage[i] = 0
  26. }
  27. for (i = 0; i < images.length; i++) { // make divs for IE and layers for Navigator
  28. document.write('<div id="obj' + i + '" style="position: absolute; z-Index: 100; height: 0; width: 0"><img src="' + images[i].src + '"></div>')
  29. }
  30. trail()
  31. }
  32. function trail() { // trailing function
  33. for (i = 0; i < images.length; i++) { // for every div/layer
  34. document.getElementById("obj" + i).style.top = storage[d]+'px' // the Y-coordinate
  35. document.getElementById("obj" + i).style.left = + storage[d+1]+'px' // the X-coordinate
  36. d = d+2
  37. }
  38. for (i = storage.length; i >= 2; i--) { // save the coordinate for the div/layer that's behind
  39. storage[i] = storage[i-2]
  40. }
  41. d = 0 // reset for future use
  42. var timer = setTimeout("trail()",30) // call recursively
  43. }
  44. function processEvent(e) { // catches and processes the mousemove event
  45. if (window.event) { // for IE
  46. storage[0] = window.event.y+standardbody.scrollTop+7
  47. storage[1] = window.event.x+standardbody.scrollLeft+10
  48. } else {
  49. storage[0] = e.pageY+12
  50. storage[1] = e.pageX+12
  51. }
  52. }
  53.  
  54. initTrail()
  55. document.onmousemove = processEvent // start capturing
  56.  
  57. //-->
  58.  
  59. </script>
  60.  
  61. <style type="text/css">
  62. BODY {overflow-x: hidden;}
  63. </style>
Add Comment
Please, Sign In to add comment