Reputation: 8705
I have this part of code:
if(mess <= 0 || mess < -width) {
img_container.find('ul').animate({'margin-left' : mess + 'px' }, 1000);
}
I need this to stop working when mess is lesser the -width. How can I do this?
Upvotes: 0
Views: 367
Reputation: 10246
See if you are getting width as string, if yes, use JS parseInt
function.
If you are looking to stop animation syntax, see on http://api.jquery.com/stop/
It could be img_container.find('ul').stop();
This could help:
if(mess < (-1 * width)){
img_container.find('ul').stop();
}
Upvotes: 6
Reputation: 324620
You want the condition to fail if mess
is less than -width
, which means you only want it to succeed if mess >= -width
.
Since it's a required condition just like mess <= 0
, you need &&
instead of ||
.
Upvotes: 1
Reputation: 207501
You do not want it to do into the if the mess is less than the width?
You want to use AND instead of OR
if(mess <= 0 && mess > -width) {
Upvotes: 1