-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drag a div from one div to another #8
Comments
Our project plane:
|
Which function will you use to change the background color of the container div? |
The plan looks good. You can go ahead. |
Thanks! after checking overlap we will use if condition to change background color of container div |
Highlighted the category div with a yellow background when an overlap is detected. |
@Mahimahto Have reviewed your code and added a comment. I ran your code and it looks great! One thing is missing. I would like you to move the dragging div INTO the container div. For example before you start dragging the DOM structure will look like this <body>
<h1>Draging-Box</h1>
<div id="dragingDiv" style="width: 100px; height: 100px; position: absolute; left: 665px; top: 261px;"></div>
<div class="category" id="category-a" style="">category-a</div>
<div class="category" id="category-b" style="">category-b</div>
<div class="category" id="category-c" style="background-color: yellow;">category-c</div>
<div class="category" id="category-d" style="">category-d</div>
<div class="category" id="category-e" style="">category-e</div>
</body> Now if you drag the dragging div into category-e, the DOM should look like <body>
<h1>Draging-Box</h1>
<div class="category" id="category-a" style="">category-a</div>
<div class="category" id="category-b" style="">category-b</div>
<div class="category" id="category-c" style="background-color: yellow;">category-c</div>
<div class="category" id="category-d" style="">category-d</div>
<div class="category" id="category-e" style="">category-e
<div id="dragingDiv" style="width: 100px; height: 100px; position: absolute; left: 665px; top: 261px;"></div>
</div>
</body> I hope this makes sense. |
Update drag-and-drop behavior to correctly position dragged element at mouseup |
@maanasb01 @Mahimahto's code is ready to merge. I have run the code locally so feel free to merge her PR. |
#9 |
Add drag-and-drop functionality for categorizing items |
Overview
Create 5 divs called "category-a", "category-b", "category-c", "category-d", "category-e"
At first your div is inside category-a. Then the user should be able to click on that div and move it into another div. Anytime your dragged div is on top of another div, the underlying div should change its background color. When the drag stops, if your div is within the boundary of any of the 5 divs, it should be moved inside the category div.
Hint
Illustration
The text was updated successfully, but these errors were encountered: