I am trying to animate related columns' width in my HTML layout using a slider.
in this code everything works great, here I am getting new value for another column on slide-UP.
var item.thisWidth; // current width of edited column
var item.prevCellWidth; // current width of previus/last column
fdd
if(slider.value > item.thisWidth){
var prevNewWidth = item.prevCellWidth - (slider.value-item.thisWidth);
$('#r'+item.thisRowId+'s'+item.prevCellRowOrder+'').css('width', prevNewWidth + '%');
}
But here is something weird happening after the calculation on slide-Down. The value created is in 100s of thousands. Need to keep in mind that the slider min/max value is from 0-100
"slider.value"
if(slider.value < item.thisWidth){
var prevNewWidth = item.prevCellWidth + (item.thisWidth - slider.value);
$('#r'+item.thisRowId+'s'+item.prevCellRowOrder+'').css('width', prevNewWidth + '%');
}
I have tried to check all values that are being passed over for calculation and they show up ok.
alert('oldWidth'+item.thisWidth+'sliderWidth'+slider.value+'previuscell'+item.prevCellWidth+'');
But when decreasing the slider I get these wrong results
e.g. 30 + (40 - 10) = 400000; ??
UPDATE:
Sorted this out by using @rogelio's suggestion - parsing a string into an integer:
var integer = parseInt(string);
Thanks, @rogelio!
slider.valueis a integer? Why you compare it with a string? Have you tried withparseInt()? - rogelio