Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font-Awesome - icon-spin does not spin when hidden and then displayed

When my page loads, I hide the icon-refresh + icon-spin icon by setting its display property to none.

Now, after some action is performed, I wish to display this icon. I invoke jQuery's .show() method on the icon. However, while the icon is shown, the icon is not spinning anymore.

If I load it without hiding it initially, it spins. But not when it is hidden and displayed later.

EDIT: If it was not clear from the title, I am using Font Awesome to display the icons

like image 244
user109187 Avatar asked Apr 11 '13 20:04

user109187


People also ask

How do I make Font Awesome icons spin?

Use the fa-spin class to get any icon to rotate, and use fa-pulse to have it rotate with eight steps. This works especially well with fa-spinner & everything in the spinner icons category.

Why are Font Awesome icons not working?

Double check that you don't have AdBlock Plus or uBlock enabled. They might be blocking some of the icons. If you are using IE8, are you using a HTML5 Shim? If this doesn't work, there are further Troubleshooting Ideas on the Font Awesome Wiki.

What is Aria hidden true in Font Awesome?

aria-hidden="true" attribute. Provide a text alternative inside a <span> (or similar) element. Also include appropriate CSS to visually hide the element while keeping it accessible to assisitive technologies. title attribute on the icon to provide a tooltip for sighted mouse users.

Is Font Awesome no longer free?

Font Awesome is fully open source and is GPL friendly. You can use it for commercial projects, open source projects, or really just about whatever you want.


2 Answers

You have to use $element.css("display","inline-block"); instead of .show();

like image 131
Stefan Pöltl Avatar answered Oct 27 '22 19:10

Stefan Pöltl


Old topic, but I had similar issue with "fa-spin" not working after the containing element was hidden with { visibility: hidden }, set with jQuery. There was also some other animation involve, which was probably causing timing issues, etc.

The fix was to set an event on the containing element to fire on making it visible again, which fired this function:

ply_obj.container.on(
            'controlsshown',
            function () {

                if (ply_obj.config.loop_tf) {
                    ply_obj.loop_icon.removeClass('fa-spin');
                    setTimeout(function () { ply_obj.loop_icon.addClass('fa-spin'); }, 100);
                }
            }
        );

So removing the "fa-spin", then adding it back with a small delay made it work as desired for me.

like image 22
Dwight Vietzke Avatar answered Oct 27 '22 20:10

Dwight Vietzke