I am new to Babylon. I am using drag.validateDrag to set a boundary to my slider but drag.validateDrag is not working properly . Here is my code:
setupSlider(slider1Center, newMeshs, 5.849, -6.082, onSlider1Change);
function setupSlider(slider, meshes, leftBound, rightBound, onDrag){
let drag = new PointerDragBehavior({dragAxis: new Vector3(1,0,0)});
slider.addBehavior(drag);
drag.validateDrag = (targetPosition)=>{
console.log( `target position.x = ${targetPosition.x}`)
if(targetPosition.x < leftBound){
slider.position.x = leftBound
}
if(targetPosition.x > rightBound){
slider.position.x = rightBound;
}
return true;
}