Angularjs arrange divs in nested rectangular manner - angularjs

I have two arrays whose elements I want to display as nested divs:
$scope.boxes = [{
id:1,
isLit: false,
color: 'green'
}, {
id:2,
isLit: false,
color: 'blue'
}, {
id:3,
isLit: false,
color: 'red'
}, {
id:4,
isLit: false,
color: 'yellow'
}];
$scope.images=[
{
id:1, path: './img/Baum_grün.png', color:'green'
},
{
id:2, path: './img/Baum_blau.png', color:'blue'
},
{
id:3, path: './img/Baum_rot.png', color:'red'
},
{
id:4, path: './img/Baum_gelb.png', color:'yellow'
}
]
I want to arrange them in following manner (consider those stars being images):
Right now my template looks like following:
<div class="outer-wrapper">
<div class="inner-wrapper">
<div class="box {{box.color}}" ng-repeat="box in boxes" ng-class="{'lit': box.isLit}" ng-click="boxClick(box.id)" ng-click="boxClick(box.id)" ng-audio="sounds/beep-08b.mp3" volume="0.5">
</div>
</div>
<div class="image" ng-repeat="image in images" ng-if="showImages" ng-click="imageClick(image.id, image.color)">
<img src="{{image.path}}">
</div>
</div>
And my css:
.outer-wrapper {
width: 250px;
}
.inner-wrapper {
width: 200px;
}
.box {
position: relative;
height: 50px;
width: 50px;
border: 1px solid black;
margin: 10px;
float: left;
}
.green {
background-color: green;
opacity: 0.3;
}
.blue {
background-color: blue;
opacity: 0.3;
}
.red {
background-color: red;
opacity: 0.3;
}
.yellow {
background-color: yellow;
opacity: 0.3;
}
.lit {
opacity: 1.0;
}
.image img{
height: 50px;
width: 100px;
margin-top: 45px;
float: right;
border: 0.5px solid;
margin: 10px;
}
This much code gives me following result:
What and how should I modify my css/html to achieve the desired result, it also has be responsive at least till medium sizes screens ?

It's easy if you can use flexbox - the new layout mode in CSS3. You can read more about it here: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
If you can use it, here's how you could do it:
<div id="first-container">
<div id="a">
a
</div>
<div id="b">
b
</div>
</div>
<div id="wrapper">
<div id="div-container">
<div id="x">
x
</div>
<div id="y">
y
</div>
</div>
<div id="div1-container">
<div id="z">
z
</div>
<div id="q">
q
</div>
</div>
</div>
<div id="second-container">
<div id="c">
a
</div>
<div id="d">
b
</div>
</div>
And the CSS:
#first-container, #second-container {
display: flex;
justify-content: space-between;
}
#wrapper {
display: flex;
flex-direction: column;
}
#div-container, #div1-container {
display: flex;
align-items: center;
justify-content: center;
}
#a, #c {
width: 20%;
border: solid 1px #000;
}
#b, #d {
width: 20%;
border: solid 1px #000;
}
Also, here's a working fiddle: http://jsfiddle.net/zeLh0foy/72/

Related

Unexpected gap between two columns

I'm working on a react application and one of the pages has a two column layout. When I'm using a larger screen, there is a gap in between the two columns, thats not there on a smaller screen like a laptop. When i use the chrome inspect tool on the larger screen, the gap disappears.
I know its not my CSS doing this because I've adjusted every margin and padding value and it still shows up. I've even tried the resolution and the display on the larger screen and its still there.
Any help would be greatly appreciated!
EDIT
ProjectList.js
.project-list-page {
float: right;
width: 90vw;
}
.project-top-bar {
padding: 1rem;
display: flex;
justify-content: space-between;
border-bottom: 1px solid grey;
box-shadow: var(--box-shadow);
}
.project-top-bar input {
box-shadow: var(--box-shadow);
border: none;
border-radius: var(--border-radius);
width: 25vw;
padding: 5px;
font-size: 1em;
}
.project-list {
height: 100%;
list-style-type: none;
margin: 0;
padding: 0;
height: 100%;
overflow: scroll;
}
.project-column {
float: left;
border-collapse: collapse;
height: 87vh;
}
.project-left-side {
width: 30%;
}
.project-right-side {
width: 70%;
}
.project-list-item {
padding: 2em 0.5rem;
border-collapse: collapse;
border: 1px solid lightgrey;
overflow: auto;
width: 100%;
cursor: pointer;
}
.project-list-item:hover {
background-color: #e6e6e6;
}
.project-list a {
text-decoration: none;
color: black;
}
<>
<div className='project-list-page'>
<div className='project-top-bar'>
<input type="text" className='project-search-input' placeholder='Search projects ...' />
<button className='btn new-project-btn'>New Project</button>
</div>
<div className='project-column project-left-side'>
<ul className='project-list'>
{projectList.map(project => {
return <ProjectListItem project={project}/>
})}
</ul>
</div>
<div className='project-column project-right-side'>
Preview
</div>
</div>
</>
ProjectListItem.js
<Link to={`/projects/${project.name}`}>
<li className='project-list-item'>
{project.name}
</li>
</Link>

Structuring Sidebar in React

Relatively new to React, and am wanting to recreate the design below
enter image description here
I have the base formatting down, but as you will notice, there are lines separating the logo blocks, from the login and signup blocks, with the signup and login buttons pushed to the bottom.
Below is my current code
CSS:
width: 100vw;
height: 100vh;
}
body {
margin: 0;
padding: 0;
}
.Sidebar {
height: 100%;
width: 20%;
background-color: white;
border-right: 1px solid #F0F4FB;
padding-left: 15px;
box-sizing: border-box;
}
.SidebarList {
height: auto;
width: 100%;
padding-left: 15px;
font-size: 18px;
border: 2px #FD954E;
box-sizing: border-box
}
.SidebarList .row {
width: 100%;
height: 50px;
background-color: white;
list-style-type: none;
margin: 0%;
padding-bottom: 15px;
display: flex;
color: #A7ACB6;
justify-content: center;
align-items: center;
font-family: Arial, Helvetica, sans-serif;
}
.SidebarList .row:hover {
cursor: pointer;
background-color: #E7E7E7 ;
}
.SidebarList #active {
background-color: white;
color: #FD954E
}
.SidebarList .Login {
background-color: white;
color: #FD954E;
width: 279px;
height: 39px;
right: 1596px;
top: 958px;
border: 1px solid #FD954E;
box-sizing: border-box;
border-radius: 19.5px;
}
.SidebarList .SignUp {
width: 279px;
height: 39px;
right: 1596px;
top: 1011px;
background: #FD954E;
border-radius: 19.5px;
border: none;
}
.row #icon {
flex: 30%;
display: grid;
place-items: center;
transform: scale(1.2)
}
.row #title {
flex: 70%;
}
.Logo {
padding-left: 25px;
padding-top: 25px;
padding-bottom: 30px;
border-bottom: 1px solid #F0F4FB;
width: 55%;
}
Sidebar.js
import React from "react";
import "../App.css";
import { SidebarData } from './SidebarData'
import Logo from './Logo.svg'
function Sidebar() {
return (
<div className="Sidebar">
<div>
<img src = {Logo} alt='Logo’ className=‘Logo’ />
</div>
<ul className="SidebarList">
{SidebarData.map((val, key) => {
return (
<li
key={key}
className="row"
id={window.location.pathname == val.link ? "active" : ""}
onClick={() => {
window.location.pathname = val.link;
}}
>
<div id="icon">{val.icon}</div> <div id="title">{val.title}</div>
</li>
);
})}
</ul>
<div className= "SidebarList">
<button className="Login">
Login
</button>
</div>
<div className= "SidebarList">
<button className="SignUp">
Sign Up
</button>
</div>
</div>
);
}
export default Sidebar;
How should I structure my code in order to acheive my desired result? Ex: with the logo at the top with the seperator, the list of navigation elements, and then the login and signup buttons at the bottom with the seperator?
Currently, my sidebar looks as follows, with the seperator not full width between the logo and navigation elements, and the buttons extending beyond the sidebar.
enter image description here
It would be easier to simplify the problem with just HTML and CSS as that's much easier to troubleshoot. Part of your problem is that you are defining the width of the sidebar as a percentage of the screen width but elements within the sidebar are defined with a width in pixels. When the browser window is too small, your buttons will appear outside the full width of the sidebar. You could either code all your values as percentages or in pixels. Alternatively, you could use a mix and just set a min-width for the sidebar so that you don't end up with elements out of place.
The reason that your line break is not the full width of your sidebar is because you are defining it with the border-bottom property of the logo. Your logo is not 100% the width of the sidebar so your line break will only be the width of the logo. A better solution would be to define a div that is set to width: 100%. This way, you will have more control.
Here is a simplified solution to your sidebar problem using pixels to define the widths.
HTML:
<div class="sidebar">
<div class="header">
<div class="logo">Logo</div>
</div>
<div class="line-break" />
<div class="content">
<ul class="nav">
<li>Home</li>
<li>Blog</li>
</ul>
</div>
<div class="line-break" />
<div class="footer">
<button class="login">Login</button>
<button class="sign-up">Sign up</button>
</div>
</div>
CSS:
html, body {
height: 100%;
margin: 0;
padding: 0;
}
.sidebar {
width: 300px;
height: 100%;
border-right: 1px solid grey;
}
.line-break {
height: 1px;
width: 100%;
background-color: grey;
}
.header .logo {
height: 40px;
width: 200px;
background-color: grey;
margin: 20px;
}
ul.nav {
list-style-type: none;
padding: 20px 0 0 40px;
}
ul.nav li {
margin-bottom: 14px;
}
ul.nav li:last-child {
margin-bottom: 0;
}
.footer {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px 0;
}
.footer button {
padding: 6px 0;
width: 80%;
margin-bottom: 14px;
}
.footer button:last-child {
margin-bottom: 0;
}
And here is a link to a CodePen
where you can see this in action.

How do I add a font aswesome's className or id in React

I tried to add an className in fontawesome and give a property(width,padding,fontsize, etc)in the sass but it didn't work what I expected.
Is there any syntax give a className or id in the fa react? It works when I give a div+className and using flexbox but you know this is pretty not a good way if we can use className or id. I will leave my code below!
!
or
didn't work...
This is my whole main.js file! I will leave my part of my code(my question part)
import React, { Component } from "react";
import "./Main.scss";
import "./Common.scss";
import { FontAwesomeIcon } from "#fortawesome/react-fontawesome";
import {
faHeart,
faComment,
faPaperPlane,
faBookmark,
faEllipsisH,
} from "#fortawesome/free-solid-svg-icons";
// import { FaRegComment } from "#fortawesome/free-solid-svg-icons";
// how to impport this faRegComment?
class Main extends Component {
render() {
return (
<>
<div class="main-wrapper">
<div class="nav">
<p class="logo"> Westagram </p>
<input
class="search-box"
type="text"
placeholder=" Search"
/>
{/* ,style="font-family:Arial, FontAwesome */}
<div class="icons">
<img
id="compass"
src="https://s3.ap-northeast-2.amazonaws.com/cdn.wecode.co.kr/bearu/explore.png"
/>
<img
id="heart"
src="https://s3.ap-northeast-2.amazonaws.com/cdn.wecode.co.kr/bearu/heart.png"
/>
<img
id="my-page"
src=" https://s3.ap-northeast-2.amazonaws.com/cdn.wecode.co.kr/bearu/profile.png"
/>
</div>
</div>
<div class="main">
<div class="feeds">
<div class="article">
<div class="identi">
<img class="selfi-identi" src="/images/about.png" />
<span class="name"> Jiwan Jeon </span>
{/* <i id="test" class="fa fa-ellipsis-h" aria-hidden="true"></i> */}
<div class="faEllipsisH">
<FontAwesomeIcon icon={faEllipsisH}></FontAwesomeIcon>
</div>
</div>
<div class="pic">
<img id="feed-pic" src="/images/ucscPic.png" />
</div>
<div class="show-box">
<div class="reaction-icons">
<FontAwesomeIcon icon={faHeart}></FontAwesomeIcon>
<FontAwesomeIcon icon={faComment}></FontAwesomeIcon>
<FontAwesomeIcon icon={faPaperPlane}></FontAwesomeIcon>
<FontAwesomeIcon icon={faBookmark}></FontAwesomeIcon>
</div>
<div class="like-counts">
<span>like 4,000</span>
</div>
<div class="check-comments">
<span>
UC Santa Cruz will continue to offer most courses remotely
or online for spring and summer 2021, providing in-person
instruction for a small
</span>
<a id="space" href="">
expanding
</a>
<br />
Check the all comments
<ul class="feed-comments">
<li>test</li>
</ul>
</div>
</div>
<div class="comment">
<i class="fa fa-smile-o"></i>
<input
class="user-input"
type="text"
placeholder="Add Comment..."
/>
<button class="post">Post</button>
</div>
</div>
</div>
</div>
<div class="main-right">
<div class="top">
<img class="selfi" src="/images/about.png" />
<div class="main-right-name">
<span id="eng-name">JiwanJeon94</span>
<br />
<span id="kr-name">전지완</span>
</div>
Transform
</div>
<div class="middle">
<div class="middle-words">
<span id="recommendation">Suggestions For You</span>
<a href="" id="view-all">
view all
</a>
</div>
<div class="recommendation-people">
<div id="recommendation-section1">
<img
id="recommendation-people-selfi"
src="/images/about.png"
/>
<span>Recommendation for you</span>
Follow
</div>
<div id="recommendation-section1">
<img
id="recommendation-people-selfi"
src="/images/about.png"
/>
<span>Recommendation for you</span>
Follow
</div>
<div id="recommendation-section1">
<img
id="recommendation-people-selfi"
src="/images/about.png"
/>
<span>Recommendation for you</span>
Follow
</div>
<div id="recommendation-section1">
<img
id="recommendation-people-selfi"
src="/images/about.png"
/>
<span>Recommendation for you</span>
Follow
</div>
<div id="recommendation-section1">
<img
id="recommendation-people-selfi"
src="/images/about.png"
/>
<span>Recommendation for you</span>
Follow
</div>
</div>
</div>
<div class="footer">
<div class="footer-top">
About
Help
press
API
Jobs
Privacy
Terms
Locations
TopAccounts
Hashtags
Language
<br />
<br />
</div>
<span>2021 INSTAGRAM FROM FACEBOOK</span>
</div>
</div>
</div>
</>
);
}
}
export default Main;
This is my fa icons part
<div class="show-box">
<div class="reaction-icons">
<FontAwesomeIcon icon={faHeart}></FontAwesomeIcon>
<FontAwesomeIcon icon={faComment}></FontAwesomeIcon>
<FontAwesomeIcon icon={faPaperPlane}></FontAwesomeIcon>
<FontAwesomeIcon icon={faBookmark}></FontAwesomeIcon>
</div>
I Will leave sass file just in case
#font-face {
font-family: instagramFont;
src: url("./westagram.ttf") format("opentype");
}
#mixin icon-size() {
width: 30px;
height: 30px;
}
#root {
height: 100vh;
.main-wrapper {
margin: 10px 10px 10px 10px;
height: 100%;
.nav {
position: fixed;
display: flex;
flex-direction: row;
justify-content: space-around;
width: 100%;
padding-top: 20px;
padding-bottom: 10px;
border-bottom: solid 1px #dbdbdb;
z-index: 9999;
.logo {
font-family: instagramFont;
padding-right: 100px;
font-size: 2rem;
}
.search-box {
margin-top: 5px;
width: 250px;
// main css파일이랑 똑같이 세팅 했는데 개발자툴이랑 왜 다른지 -해결-
height: 28px;
}
.icons {
margin-left: 100px;
#compass {
#include icon-size();
//30*30 으로 세팅했는데 개발자툴에서는 왜 53*53인지
}
#heart {
#include icon-size();
}
#my-page {
#include icon-size();
}
}
}
.main {
position: relative;
top: 70px;
left: 8px;
width: 100%;
height: 100%;
.feeds {
position: relative;
top: 40px;
right: 5px;
left: 61px;
width: 60%;
.article {
position: absolute;
display: flex;
flex-direction: column;
width: 614px;
height: 954px;
padding-bottom: 10px;
.identi {
position: relative;
display: flex;
flex-direction: row;
align-items: flex-start;
height: 50px;
.selfi-identi {
width: 30px;
height: 30px;
// padding: 15px 20px 20px 20px;
border-radius: 50%;
}
.name {
margin-top: 10px;
margin-left: 5px;
}
#test {
padding-top: 23px;
padding-left: 410px;
}
.faEllipsisH {
padding-top: 10px;
padding-left: 40px;
// padding-bottom: 20px;
}
}
.pic {
#feed-pic {
position: relative;
padding: 3px 3px 3px 3px;
width: 614px;
height: 614px;
padding: 5px 0px 2px 0px;
}
}
.show-box {
position: relative;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 170px;
padding: 5px 0px 20px 0px;
.reation-icons {
#heartShowBox {
padding-left: 10px;
font-size: 30px;
width: 30px;
}
.fa-comment-o {
padding-left: 10px;
padding-right: 5px;
}
.fa-send-o {
padding-left: 10px;
font-size: 30px;
}
.fa-bookmark-o {
padding-left: 450px;
font-size: 30px;
}
}
.like-counts {
margin-top: 10px;
padding-top: 20px;
}
.check-comments {
.space {
padding-top: 400px;
}
}
}
.comment {
position: relative;
// margin-top: 75px;x
.fa-smile-o {
font-size: 30px;
}
.user-input {
width: 530px;
height: 20px;
}
.post {
height: 25px;
border: solid 1px #d3d3d3;
border-radius: 5px;
background-color: #b2dffc;
font-size: 15px;
cursor: pointer;
}
}
}
}
}
.main-right {
position: fixed;
width: 28%;
height: 98%;
top: 11.9%;
right: 4%;
.top {
position: relative;
display: flex;
flex-direction: row;
padding-bottom: 3px;
.selfi {
width: 50px;
height: 50px;
padding: 15px 20px 20px 20px;
border-radius: 50%;
}
.main-right-name {
position: relative;
padding-top: 25px;
#kr-name {
opacity: 0.3;
}
}
a {
margin-left: 40px;
margin-top: 20px;
}
}
.middle {
height: 30%;
padding-bottom: 100px;
.middle-words {
padding-bottom: 25px;
#recommendation {
margin-left: 23px;
}
#view-all {
margin-left: 70px;
}
}
.recommendation-people {
display: flex;
flex-direction: column;
#recommendation-section1 {
#recommendation-people-selfi {
width: 30px;
height: 30px;
margin-top: 13px;
padding: 5px 5px 5px 5px;
border-radius: 50%;
}
span {
position: relative;
right: 5px;
top: -18px;
}
a {
position: absolute;
right: 3px;
font-size: 14px;
}
}
}
}
.footer {
margin-left: 10px;
.footer-top {
.a {
margin: 0px 0px 0px 5px;
opacity: 0.3;
}
}
}
span {
margin-left: 5px;
opacity: 0.3;
}
}
}
}
For the first, replace all class with className.
className work fine with FontAwesomeIcon:
<FontAwesomeIcon icon={faHeart} className="awesome-custom"></FontAwesomeIcon>;
Chech this example: https://codesandbox.io/s/cold-frost-bv362?file=/src/App.js

Drag And Drop Directiv in AngularJS moving cards

I use this directiv : http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types
I have problem to with moving cards, when i move cards higher is ok, if the cards give less the problem starts.
i did this feature :
if ($scope.movingItem.indeksList == index) {
console.log('qrwa')
$scope.lists[$scope.movingItem.indeksList].cards.splice($scope.movingItem.IndexCard +1, 1);
$scope.lists[index].cards = external[index].cards;
} else {
console.log('qrwa2')
$scope.lists[$scope.movingItem.indeksList].cards.splice($scope.movingItem.IndexCard, 1);
$scope.lists[index].cards = external[index].cards;
}
If I do the movement in the same list and i move card higher is ok then must be perform:
$scope.lists[$scope.movingItem.indeksList].cards.splice($scope.movingItem.IndexCard +1, 1);
When from up to down must be perform :
$scope.lists[$scope.movingItem.indeksList].cards.splice($scope.movingItem.IndexCard, 1);
And here is problem I cant get $index on which place I drop card to make If that I move card lower make this perform, If higer make this perform...
Here is whole project:
https://plnkr.co/edit/BVF0KxPrWiCeGDXVpQDV?p=preview
This code works:
$scope.dropCallback = function (index, item, external) {
$scope.lists[$scope.movingItem.indeksList].cards.splice($scope.movingItem.IndexCard, 1);
$scope.lists[index].cards = external[index].cards;
console.log($scope.lists[index].cards)
return item;
};
The watcher is not neccesary in this case, because you are getting informed of changes by the dropCallback function itself.
Your job is simply to remove the item at the index, like you did. Regardless of the moving direction.
EDIT
Here is the working plunker
Not sure why you need to use dropCallback just to move items around in the list. You can use dnd-moved="item.cards.splice($index, 1)" as shown in the demo.
Check out update version of your code:
angular.module("app", ["dndLists"]).controller("c1", function($scope){
$scope.title ="drag and drop";
$scope.lists = [
{
id: 2,
name: "list2",
cards: [
{ name: "card1"},
{ name: "card2"},
{ name: "card3"},
{ name: "card4"},
{ name: "card5"}
]
},
{
id: 3,
name: "list3",
cards: [
{ name: "card1"},
{ name: "card2"},
{ name: "card3"},
{ name: "card4"},
{ name: "card5"}
]
}
];
$scope.logEvent = function (indeksList, IndexCard) {
$scope.movingItem = {
indeksList: indeksList,
IndexCard: IndexCard
}
};
$scope.dropCallback = function (index, item, external) {
return item;
};
})
/* Styles go here */
.tilt {
transform: rotate(3deg);
-moz-transform: rotate(3deg);
-webkit-transform: rotate(3deg);
}
.column {
width: 170px;
float: left;
padding-bottom: 100px;
}
.portlet {
margin: 0 1em 1em 0;
padding: 0.3em;
}
.portlet-header {
padding: 0.2em 0.3em;
margin-bottom: 0.5em;
position: relative;
}
.portlet-toggle {
position: absolute;
top: 50%;
right: 0;
margin-top: -8px;
}
.portlet-content {
padding: 0.4em;
}
.portlet-placeholder {
border: 1px dotted black;
margin: 0 1em 1em 0;
height: 50px;
}
/* <BEGIN> For OS X */
*:focus {
outline: none;
}
html {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* <END> For OS X */
body {
font-family: 'Open Sans', sans-serif;
background-color: #0375AB;
}
#wrapper, #topbar-inner {
width: 95%;
margin: 0 auto;
}
#topbar {
background-color: #036492;
}
#topbar-inner {
height: 42px;
position: relative;
}
#topbar #nav {
float: left;
width: 25%;
background: yellow;
}
#topbar #logo {
width: 100%;
padding-top: 8px;
text-align: center;
}
#topbar #login {
position: absolute;
right: 0px;
bottom: 10px;
}
#topbar #logo h1 {
margin: 0;
display: inline;
font-size: 24px;
font-family: "Ubuntu", sans-serif;
color: rgba(255, 255, 255, 0.3);
}
#topbar #logo h1:hover {
color: rgba(255, 255, 255, 0.8);
cursor: pointer;
}
#wrapper {
margin-top: 30px;
}
#tasks {
width: 260px;
padding: 7px;
background-color: #E2E4E6;
border-radius: 3px;
}
#tasks h3 {
padding: 0;
margin: 0px 0px 5px 0px;
font-weight: 400;
font-size: 14px;
}
#tasks ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#tasks li {
padding: 5px 8px;
margin-bottom: 4px;
background-color: #fff;
border-bottom: 1px #CCCCCC solid;
border-radius: 3px;
font-weight: 300;
}
#tasks li i {
float: right;
margin-top: 5px;
}
#tasks li i:hover {
cursor: pointer;
}
#tasks li i.fa-trash-o {
color: #888;
font-size: 14px;
}
#tasks input[type=text] {
margin: 0;
width: 244px;
padding: 5px 8px;
border-width: 0;
border-radius: 3px;
box-shadow: none;
}
.btn-login {
color: #fff;
background-color: #448DAF;
text-decoration: none;
border-radius: 3px;
padding: 5px 10px;
}
<script data-require="angular.js#1.6.5" data-semver="1.6.5" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script>
<script data-require="angular-drag-and-drop-lists#1.2.0" data-semver="1.2.0" src="https://marceljuenemann.github.io/angular-drag-and-drop-lists/angular-drag-and-drop-lists.js"></script>
<body ng-app="app">
<div ng-controller="c1">
<ul style="list-style-type: none;">
<li ng-repeat="item in lists">
<div style="float: left; margin-left: 5px;">
<div id="tasks">
{{item.name}}
<ul dnd-list="item.cards" dnd-drop="dropCallback($index, item, lists)">
<li ng-repeat="card in item.cards"
dnd-draggable="card"
dnd-dragstart="logEvent($parent.$index, $index)"
dnd-moved="item.cards.splice($index, 1)"
dnd-selected="models.selected = item"
ng-class="{'selected': models.selected === item}"
dnd-effect-allowed="move">
{{card.name}}
</li>
</ul>
<form ng-submit="addTask(item._id, newTask, $index)">
<input type="text" ng-model="newTask" placeholder="add a new task" required />
</form>
</div>
</div>
</li>
</ul>
</div>
</body>
You can find Plunker project here.

Animating movement of other items in ng-repeat with ngAnimate

Sorry for the vague title, but I couldn't find a fitting short description.
So, I have a list of different items which I'm using ng-repeat to show. Some of them might be removed or added to that list.
I'm using ng-enter etc to animate the transition of the items entering and exiting the view. The problem is, the rest of the items, the ones that are not being added or removed, look like they hop and skip around instead of flowing naturally when items between them are being removed or added.
I made a codepen:
If you click any of the players, you remove them. Click reset to bring them back in. If you remove any of the players in the middle, you can see they jump to the left instantly after the removed item is done with its animation. I would like it to slide over to it's new position instead.
http://codepen.io/utrolig/pen/oxQVVZ
HTML:
<div ng-app="test">
<div ng-controller="AnimateController as vm">
<div class="player" ng-repeat="player in vm.items" ng-click="vm.toggleActiveState(player)" ng-if="player.active">
<div class="imgcont">
<img ng-src="{{player.img}}" />
<div class="jerseyno">
<span>#{{::player.jerseyNumber}}</span>
</div>
</div>
<div class="playername">
<span ng-bind="::player.name"></span>
</div>
</div>
<div class="resetbutton" ng-click="vm.resetActiveState(vm.players)">
<span>Reset</span>
</div>
</div>
</div>
JS:
(function(){
'use strict';
angular
.module('test', ['ngAnimate'])
.controller('AnimateController', AnimateController);
function AnimateController(){
var vm = this;
vm.toggleActiveState = toggleActiveState;
vm.resetActiveState = resetActiveState;
vm.items = [
{
name: "Pavel Bure",
active: true,
team: "Vancouver Canucks",
jerseyNumber: 10,
img: "https://nhl.bamcontent.com/images/headshots/current/168x168/8455738.jpg"
},{
name: "Wayne Gretzky",
jerseyNumber: 99,
active: true,
team: "Vancouver Canucks",
img: "https://nhl.bamcontent.com/images/headshots/current/168x168/8447400.jpg"
},{
name: "Jaromir Jagr",
jerseyNumber: 68,
active: true,
team: "Florida Panthers",
img: "https://nhl.bamcontent.com/images/headshots/current/168x168/8448208.jpg"
},{
name: "Mats Zuccarello",
jerseyNumber: 36,
active: true,
team: "New York Rangers",
img:"https://nhl.bamcontent.com/images/headshots/current/168x168/8475692.jpg"
}
];
//////////////
function toggleActiveState(item){
item.active = item.active ? false : true;
}
function resetActiveState(arr){
for (var i = 0; i < vm.items.length; i++){
vm.items[i].active = true;
}
}
}
})();
CSS:
body, html {
min-height: 100vh;
position: relative;
font-family: 'Arial', sans-serif;
background: #1d1f20;
color: rgba(255,255,255,0.7)
}
.imgcont {
border-radius: 8px;
}
.imgcont img {
border-radius: 8px;
}
.jerseyno {
position: absolute;
top: 6px;
right: 6px;
padding: 4px;
background: rgba(0,0,0,.75);
border-radius: 4px;
}
.resetbutton {
display: block;
float: left;
border-radius: 4px;
margin: 24px;
padding: 24px;
background: rgba(0,0,0,.5);
cursor: pointer;
}
.playername {
position: absolute;
bottom: 6px;
left: 6px;
background: rgba(0,0,0,.75);
padding: 4px;
border-radius: 4px;
}
.player {
float: left;
margin-right: 12px;
position: relative;
cursor: hand;
cursor: pointer;
transition: .5s all;
}
.player.ng-enter {
opacity: 0;
transform: translateY(-50%);
}
.player.ng-enter-active {
opacity: 1;
transform: translateY(0%);
}
.player.ng-leave-active {
opacity: 0;
transform: translateY(-50%);
}
Thanks!

Resources