Limit the number of clones

Asked

Viewed 82 times

0

With the follow-up of this project, Clone of an image, I wanted to limit the number of clones and the movement of the images for example through a variable (ex: variable = 5) When for example the 5 clones are moved/created, I cannot create or move again. And change the cursor, when passing images, to no-drop.

Example jsfiddle: http://jsfiddle.net/twsthyds/12/

  • And what’s the problem?

  • I can’t stop moving the images, I want to limit that.

1 answer

3


Just add a condition to the function mousedown in the if:

|| position_souris_x.length >=5

To put the no-drop just check in function onmouseup if you already have 5 elements:

if( position_souris_x.length ==5 ) 
{
    elem=document.getElementById('img1');
    elem.style.cursor='no-drop';
}

See here it works:

http://jsfiddle.net/twsthyds/28/

  • 1

    Thank you, how can I change the mouse cursor to no-drop after this condition?

  • Check out my @akm edition.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.