Draggable add element
How do I make an draggable add element?
Http://forums.greensock.com/topic/8248-drag-new-element-from-the-div/. What is a draggable add element? How do you make a draggable add element? This script and codes were developed by Eduard L. on 15 October 2022, Saturday.
Draggable add element - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Draggable add element</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="parent"> <div class="element"></div> <div class="newElement"></div> <div style="clear:both;"></div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/utils/Draggable.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Draggable add element - Script Codes CSS Codes
body
{ margin:0px; padding:0px; font-family: "Open Sans", arial; background:url('http://wallpapersus.com/wallpapers/2012/06/abstract-blurry-creative-gaussian-blur-720x1152.jpg'); color:#fff; font-weight:300;
}
#parent
{ border:solid 1px #fff; margin:50px; position:relative; clear:both; height:500px;
}
.element, .newElement
{ position:absolute; width:100px; height:100px; margin:10px; float:left; z-index:10;
boder:solid 1px #f9f9f9; -webkit-box-shadow: 0px 0px 7px 0px rgba(50, 50, 50, 0.26);
-moz-box-shadow: 0px 0px 7px 0px rgba(50, 50, 50, 0.26);
box-shadow: 0px 0px 7px 0px rgba(50, 50, 50, 0.26);
}
.newElement
{ border: 1px blue #f0edf0; background:#ebebeb; z-index:100; opacity:0;
border: 1px solid #f0edf0;
-webkit-box-shadow: 3px 3px 9px 0px rgba(50, 50, 50, 0.32);
-moz-box-shadow: 3px 3px 9px 0px rgba(50, 50, 50, 0.32);
box-shadow: 3px 3px 9px 0px rgba(50, 50, 50, 0.32);
} .newElement:hover
{ position:absolute; width:120px; height:120px; margin:0px; float:right; z-index:10;
border: 1px solid #f0edf0;
-webkit-box-shadow: 3px 3px 9px 0px rgba(50, 50, 50, 0.32);
-moz-box-shadow: 3px 3px 9px 0px rgba(50, 50, 50, 0.32);
box-shadow: 3px 3px 9px 0px rgba(50, 50, 50, 0.32);
-webkit-transition:all .2s;
-webkit-transition-timing-function:gradient;
}
.element:active, .newElement:active
{ position:absolute; width:100px; height:100px; margin:10px; float:right; z-index:10;
border: 1px solid #f0edf0;
-webkit-box-shadow: 3px 3px 9px 0px rgba(50, 50, 50, 0.32);
-moz-box-shadow: 3px 3px 9px 0px rgba(50, 50, 50, 0.32);
box-shadow: 3px 3px 9px 0px rgba(50, 50, 50, 0.32);
}
Draggable add element - Script Codes JS Codes
var parent = $("div#parent"), elements = $("div.element"), currentID = 0, newElements = $("div.newElement"), latest;
$.each(elements, function(index, element)
{ $(element).attr('id','element'+index); currentID++; $(element).html('Create Icon: ');
});
$.each(newElements, function(index, element)
{ $(element).attr('id','element'+currentID); currentID++; //create the draggable instance for the current element in the DOM createDraggable(element);
});//new element loop end
function addElement()
{ var newElement = '<div class="newElement" id="element' + currentID + '"></div>'; parent.append(newElement); newElements = $("div#element"+currentID) //create the draggable instance for the new element createDraggable(newElements); //update the ID number currentID++;
}
function createDraggable(element)
{ Draggable.create($(element), { type:'x,y', bounds:'#parent', edgeResistance:0.85, onDragStart:function() { TweenMax.to(this.target, .2, {opacity:1}); //add just one element if(!$(this.target).hasClass("dragged")) { addElement(); $(this.target).addClass("dragged"); } } });//draggable instance end
}
Developer | Eduard L. |
Username | EduardL |
Uploaded | October 15, 2022 |
Rating | 3 |
Size | 2,642 Kb |
Views | 22,264 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Grid Resizable Drag and Drop, Masonery | 2,437 Kb |
Side Sliding Menu CSS | 4,388 Kb |
A Pen by Eduard L. | 3,953 Kb |
Sticker.js Peel and drag the edge to unstick te element | 1,962 Kb |
Social Menu | 1,931 Kb |
HackaGlobal | 1,798 Kb |
404 not found page | 3,165 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
BenU Maintenance Site | Ksherman | 4,893 Kb |
Material design buttons | Fischaela | 4,381 Kb |
A Pen by Stan Williams | Stanssongs | 6,706 Kb |
JS Countdown Timer | Ayoungh | 2,435 Kb |
Multi-step GSAP animation | Acacheung | 2,668 Kb |
Multiple jCarousel | Pafnuty | 2,461 Kb |
Slide out Menu | Rbiggs | 4,936 Kb |
Css3 only dropdown menu | Riogrande | 2,519 Kb |
Review test | Otro_user_gil | 4,054 Kb |
NeeilTimer | Neeilan | 2,836 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!