Created
June 23, 2017 04:44
-
-
Save Sunil02kumar/bf025c86c18eac70821fc9251edc9fd7 to your computer and use it in GitHub Desktop.
Lightning Component to show/hide loading spinner image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <aura:component > | |
| <aura:attribute name="show" type="Boolean" default="false" /> | |
| <aura:handler name="change" value="{!v.show}" action="{!c.spinnerDisplayHandler}"/> | |
| <div class="slds-align--absolute-center"> | |
| <lightning:spinner aura:id="spinner" variant="brand" size="large" class="slds=hide"/> | |
| </div> | |
| </aura:component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| spinnerDisplayHandler : function(component, event, helper) { | |
| console.log('show spinner value changes'); | |
| helper.showHideSpinner(component); | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| showHideSpinner : function(component) { | |
| var showValue = component.get('v.show'); | |
| if(showValue) { | |
| console.log('showValue'+showValue); | |
| var spinner = component.find("spinner"); | |
| console.log('spinner'+spinner); | |
| $A.util.removeClass(spinner, "slds-hide"); | |
| } else { | |
| console.log('showValue'+showValue); | |
| var spinner = component.find("spinner"); | |
| console.log('spinner'+spinner); | |
| $A.util.addClass(spinner, "slds-hide"); | |
| } | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice example. I've been struggling with spinners - and this does the job nicely. Thanks!