How to constrain draggable into a smaller div (simulate scrollable)

How to constrain draggable into a smaller div (simulate scrollable)


Hi,
I have 2 divs, a parent and a children which is draggable.
Parent is in overflow hidden and child is bigger (larger) than its
parent.
I want to constrain on its x axys (that the easiest part) and to be
between 0 and - width, it's mean that child will be draggable until
its left side reach the parent left side and its right side reach
parent right side.
I tried constainment and grid but with no results.
I'm currently trying to do (table.w is the computed width of the
chidren) :
    if($(this).css('left') > 0)
    {
        $(this).css('left',0);
    }
    if($(this).css('left') < (table.w * -1))
    {
        $(this).css('left', (table.w * -1));
    }
It doesn't set this css left to 0 or table.w.
Any ideas, and was it clear ?
Thanks, regards,
David