I have this Angular project where I'm making a todo list. I'm using a Masonry directive so that all my todo post it notes are arranged smoothly on the screen. It looks a lot like Google Keep.
What I'm struggling with is clicking on a note in the masonry grid and having it come up front and center as a model dialog for editing the note's contents. I want to animate the note from wherever the masonry plugin has decided to put it to the center of the screen while stretching it out giving the user enough space to work with the note. Then when the user is done I want to unstretch the note and place it back where it was (after that I can have the plugin reshuffle the bricks around in case the note changed size).
Here's what I have for displaying a note as a masonry brick:
<div masonry='{ "transitionDuration" : "0.2s" , "itemSelector" : ".brick", "isFitWidth": true}' class="center-x">
<div ng-repeat="note in Todo.GetNotes()" class="brick">
<div class="mdl-card mdl-shadow--4dp demo-card-event" ng-class="[note.Color, {done: note.Done}]">
<div class="mdl-card__title mdl-card--expand">
<h4>
{{ note.Content }}
</h4>
</div>
<div class="mdl-card__menu">
<button class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect" ng-class="{'done-check': !note.Done}" ng-click="Todo.toggleDone(note)">
<i class="material-icons">done</i>
</button>
</div>
</div>
</div>
</div>
It's a little messy due to the wordiness of Material Design Lite but here's it boiled down to just the DOM elements and important parts:
<div masonry='{ "itemSelector" : ".brick" }'>
<div ng-repeat="note in Todo.MyNotesArray" class="brick">
<div>
<div>
<h4>
{{ note.Content }}
</h4>
</div>
<div>
<button ng-click="Todo.toggleDone(note)">
<i class="material-icons">done</i>
</button>
</div>
</div>
</div>
</div>
Any of the generated .bring
elements are what I'm wanting to animate.
However I'm no good with CSS animations yet and I haven't found a library to do exactly what I want.
I have a fiddle where I'm toying with this but I can't get the transition to move to the center of the screen instead of snap. Also it puts the corner in the center. I was eventually going to figure out how to put the center in the center.
.brick {
height: 100px;
width: 100px;
background-color: red;
transition: all 1s;
}
.modal {
position: fixed;
top: 50%;
left: 50%;
width: 200px;
height: 300px;
transition: all 1s;
z-index: 10;
}