What I am trying to do is detect, using onChange, if a dojo horizontal slider is being dragged right to left. This happens to be in IBM XPages, but the area of CSJS code below should be universal. How do I use the _isReversed property to get true/false?
<xe:djHorizontalSlider
style="margin-left:5px;width:200px;height:20px"
id="djHorizontalSlider1" showButtons="false"
defaultValue="1" maximum="15" minimum="1"
intermediateChanges="true"
discreteValues="8" value="#{viewScope.sliderNumber1}">
<xe:this.converter>
<xp:convertNumber integerOnly="true"
type="number">
</xp:convertNumber>
</xe:this.converter>
<xp:eventHandler event="onChange" submit="false">
<xe:this.script><![CDATA[
//I WANT TO DETECT IN THIS CSJS
//IF THE SLIDER WAS DRAGGED RIGHT TO LEFT
}]]></xe:this.script>
</xe:djHorizontalSlider>
When the onChange
event happens the widget already changed its internal values making it almost impossible to detect any change here. But I wrote a small workaround to detect if the slider was moved from right tot left.
You should place this code inside your onChange
handler. What it does is saving the current value in a data attribute on the widget itself. When another change occurs it will be checked against the new value and updated with the new value. This way you can compare the previous value (could also be the starting value) against the new value.
Hope this works for you!
// find dojo widget
var w = dijit.byId("#{id:djHorizontalSlider1}");
// get previous value from attribute (or default value)
var previousValue = dojo.attr(w.domNode,"data-prev-value") || w.params.value;
// log info about current and previous value
console.log("new value=" + thisEvent);
console.log("previous value=" + previousValue);
//save new value
dojo.attr(w.domNode,"data-prev-value",thisEvent);
// check value
if(parseInt(thisEvent) < parseInt(previousValue)){
alert("Detected slide right to left! new value="+thisEvent+", old value="+previousValue);
}