Limit the number of clones

0

Following this project, Clone of an image , I wanted to limit the number of clones and the movement of images for example through a variable (eg: variable = 5) When for example the 5 clones are moved / created, they can not be created or moved again. And change the cursor, when moving in the images, to no-drop.

jsfiddle Example: link

    
asked by anonymous 08.04.2015 / 10:21

1 answer

3

Just add a condition in function mousedown in if :

|| position_souris_x.length >=5

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

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

Here's how it works:

link

    
08.04.2015 / 11:57