I am having problem when using mCustomScrollbar (GIT Hub) when locker service is activated. During initialization of mCustomScrollbar in the helper, it throws the following error
[TypeError: Cannot create property 'jQuery17209760322836087683' on boolean 'true']
Everything works fine when LOCKER SERVICE is DEACTIVATED.
Please find the code below:-
Component:
<ltng:require scripts="{!join(',',
$Resource.namespace__StaticResourceName + '/scripts/jQuery_V1.js',
$Resource.namespace__StaticResourceName + '/scripts/Jquery.mousewheel.min.js',
$Resource.namespace__StaticResourceName + '/scripts/Jquery.mCustomScrollbar_V1.js',
$Resource.namespace__StaticResourceName + '/scripts/ScrollBar.js'
)}" afterScriptsLoaded="{!c.scriptsLoaded}" />
<aura:attribute name="isResourcesLoaded" type="Boolean" default="false"/>
<div class="slds slds-grid slds-wrap scrollableWrap">
<div class="slds-col slds-size--1-of-1 slds-m-top--small scrollable">
<table class="slds-table slds-table--bordered" id="myTable" width="100%">
<tr align="center">
<th width="" class="slds-cell-wrap slds-text-align--left" scope="col">
<b> Name </b>
</th>
<th width="" class="slds-cell-wrap slds-text-align--right" scope="col">
<b> Amount <br/> </b>
</th>
</tr>
<tbody>
<aura:iteration items="{!v.subordinateDetail}" var="data" indexVar="row" >
<tr>
<td align="left" class="slds-cell-wrap slds-text-align--left">
<ui:outputText value="{!data.name}" />
</td>
<td align="right" class="slds-cell-wrap slds-text-align--right">
<ui:outputText value="{!data.amount}" />
</td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
</div>
Controller:
scriptsLoaded : function(component, event, helper) {
component.set("v.isResourcesLoaded", true);
}
Helper:
scrollbar : function(component){
if(component.isValid() && component.get("v.isResourcesLoaded")){
$('.scrollable').mCustomScrollbar({
axis: 'y',
contentTouchScroll: 25,
advanced: {autoExpandHorizontalScroll:true},
});
$('.scrollableWrap').mCustomScrollbar({
axis: 'x',
contentTouchScroll: 25,
advanced: {autoExpandHorizontalScroll:true},
});
}
}
Renderer:
({
afterRender: function(component, helper) {
this.superAfterRender();
},
rerender: function(component, helper) {
this.superRerender();
helper.scrollbar(component);
}
})
isResourcesLoaded is a Boolean attribuite which I'm setting as true in afterScriptsLoaded (to make sure that the external scipts uploaded as static resources have loaded).
Also, I'm calling the scrollbar
function from the renderer to make sure that the DOM elements have also loaded successfully.
The above code works fine when locker service is not activated.
But when LS is activated, it throws error.
I had to use mCustomScrollbar as Salesforce still hasn't fixed the Lightning Design System scroll functionality for Salesforce-1.