

Someone could create (or find) a collection of. ani files available online without needing to convert them to another format server side. It would be cool to see someone use this library to build a website that makes a large collection of. If you want to see some animated cursors rendering in your browser, check out these skins that feature animated cursors and try hovering your mouse around. It may also save some CPU cycles.Īnd that's about it! The full implementation can be found in the ani-cursor NPM module which lives in the Webamp repository on GitHub.

This helps us match Winamp's behavior where the animation always restarts when you hover over an element. Secondly, we add a :hover pseudo selector so that the animation loop only runs when the cursor is visible. Luckily the animation progress is computed using the timing-function so we can use step-end to ensure the cursor image updates immediately when each keyframe percentage is reached. This is because discrete properties, like cursor, do not actually change at the time specified by the keyframe (10%), but rather when the animation progress has reached the midpoint between keyframes ( source). There are two small details in the CSS that we generate which are worth calling out.įirstly, we use a timing-function of step-end.

The result looks something like ani-cursor-27 ms step-end infinite We define a CSS animation where the cursor property changes over time. To get around this, we use a technique I discovered in a four year old forum post. We now have enough information to construct the animation ourselves! Browsers don't support animated cursors We then use the byte-data library to parse the first three sections into JavaScript numbers. Riff-file only gives us the byte range of each of these sections within the. riff-file breaks the file into sections for us:Ī "rate" array showing for how long each frame is rendered (optional)Ī "seq" array, showing in which order the frames should be rendered (optional)Īn array of frames containing the raw image data for each frame ani file and extract the frames and metadata indicating the order and timing in which to render the frames.ani files use the RIFF container format, and someone on NPM has already written a small library riff-file that can parse RIFF in the browser. To get around this, we use JavaScript to parse the. ani files nativelyīrowsers don't support animated image formats (gif, apng) as cursors However, up until recently, Webamp didn't support. Cursor : url (data:image/x-win-bitmap base64,AAAAAAA, auto)
