You need to sign in to do that
Don't have an account?
Mohita Kalra
Hi All , I have this lightning component which has a moving text. I want to add onmouseover - pause and onmouseout - startagain kind of functionality
Component:
<aura:component>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:attribute name="intervalId" type="Integer" default="0"/>
<div id="parentDIV" style="overflow:hidden">
<p style="position:relative;" id="tofloat">
<b><span style="color:red">Important Note : </span>
I am Floating (Left to Right) Imformation...</b>
</p>
</div>
</aura:component>
Controller :
({
doInit : function(component, event, helper) {
var lWidth = window.innerWidth ;//Get the window's width
//The setInterval() method calls a function or
//evaluates an expression at specified intervals (in milliseconds).
window.setInterval($A.getCallback(function() {
helper.shiftDiv(component, event,lWidth);
} ), 100);
},
})
Helper :
({
shiftDiv: function(component, event,lWidth) {
var changeposition = component.get("v.intervalId");
var floatElement = document.getElementById('tofloat');
if(changeposition < lWidth){
floatElement.style.left = changeposition+'px';
changeposition = changeposition + 5;
component.set("v.intervalId",changeposition);
}
//reset the left to 0
else{
component.set("v.intervalId",0);
floatElement.style.left = "0px";
changeposition = component.get("v.intervalId");//resetting so as to hit the if block again
}
}
})
Can someone advise how can i achieve this. I used onmouseover in div tag but getting stuck at what function should be used?
PS : Have copied this code from sfdcmonkey
<aura:component>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:attribute name="intervalId" type="Integer" default="0"/>
<div id="parentDIV" style="overflow:hidden">
<p style="position:relative;" id="tofloat">
<b><span style="color:red">Important Note : </span>
I am Floating (Left to Right) Imformation...</b>
</p>
</div>
</aura:component>
Controller :
({
doInit : function(component, event, helper) {
var lWidth = window.innerWidth ;//Get the window's width
//The setInterval() method calls a function or
//evaluates an expression at specified intervals (in milliseconds).
window.setInterval($A.getCallback(function() {
helper.shiftDiv(component, event,lWidth);
} ), 100);
},
})
Helper :
({
shiftDiv: function(component, event,lWidth) {
var changeposition = component.get("v.intervalId");
var floatElement = document.getElementById('tofloat');
if(changeposition < lWidth){
floatElement.style.left = changeposition+'px';
changeposition = changeposition + 5;
component.set("v.intervalId",changeposition);
}
//reset the left to 0
else{
component.set("v.intervalId",0);
floatElement.style.left = "0px";
changeposition = component.get("v.intervalId");//resetting so as to hit the if block again
}
}
})
Can someone advise how can i achieve this. I used onmouseover in div tag but getting stuck at what function should be used?
PS : Have copied this code from sfdcmonkey
If you want to show/hide the data, use onMouseOver (To show data value on mouse hover) and onMouseOut (To hide data value on mouse out)
If you want to take a look at sample code, see the following
https://sfdcmonkey.com/2017/07/27/data-mask-lightning-component/
https://developer.salesforce.com/forums/?id=9060G0000005bJaQAI
Anudeep