Skip to content

Instantly share code, notes, and snippets.

@Sunil02kumar
Created June 23, 2017 04:44
Show Gist options
  • Select an option

  • Save Sunil02kumar/bf025c86c18eac70821fc9251edc9fd7 to your computer and use it in GitHub Desktop.

Select an option

Save Sunil02kumar/bf025c86c18eac70821fc9251edc9fd7 to your computer and use it in GitHub Desktop.
Lightning Component to show/hide loading spinner image
<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>
({
spinnerDisplayHandler : function(component, event, helper) {
console.log('show spinner value changes');
helper.showHideSpinner(component);
}
})
({
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");
}
}
})
@kernowork
Copy link

Nice example. I've been struggling with spinners - and this does the job nicely. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment