How to animate Angular ui-grid when rows are added - angular-ui-grid

I have an Angular UI Grid element. I am periodically adding new items at the front of the data array. I'm only adding a few at a time (like 1 to 5 new items)
I would like the UI Grid to animate the new rows being added. Right now the rows are added immediately, which makes it jumpy. I want to the new rows to animate in so the UI Grid looks like it smoothly adds them in.
Is this easily possible? Is there an option for this?

It's a bit of a difficult problem because UI-Grid virtualizes the data, so there's no actual DOM elements being added and removed, or hidden and shown. That means you can't use regular Angular animation directives.
Instead you can use the $animate service to manually trigger animations on user interactions like adding and deleting rows. This "fakes" the transition, making it look like the DOM has been altered when it hasn't.
Say you wanted to fade in new rows. You'd need to have some identifier on the row data coming in, and selectively apply & remove a class based on that. You'd set opacity: 0 immediately, then use $animate.removeClass() to transition to opacity: 1. The CSS might look like this:
.new-row {
opacity: 0;
}
.new-row-remove {
-webkit-transition: 1s linear all;
-moz-transition: 1s linear all;
-o-transition:1s linear all;
transition: 1s linear all;
opacity: 0;
}
.new-row-remove-active {
opacity: 1;
}
For deleting rows, you would need to reverse the operation: add a delete-row class that would transition from full opacity to 0, then use a promise handler to actually remove the row once $animate.addClass() is done. Here's the CSS:
.delete-row-add {
-webkit-transition: 0.5s linear all;
-moz-transition: 0.5s linear all;
-o-transition: 0.5s linear all;
transition: 0.5s linear all;
opacity: 1;
}
.delete-row-add-active {
opacity: 0;
}
That's the short answer. For a much longer explanation and a demo, I have a write-up available here: http://brianhann.com/ui-grid-and-row-animations

Related

iOS 11 fixed input bug + jitter on scroll

iOS 11 has issues with inputs inside a fixed container more here, specifically with iOS 11 on focus + the keyboard cursor is misaligned to the input:
I have an element .rn-drawer that ought to be fixed to the top of page, while the rest of the page content is scrollable. The fixed element contains an input.
.rn-drawer {
position: fixed;
transition: all 0.25s ease-in-out;
display: flex;
height: 260px;
}
By simply applying the following .iOS-fix to the parent/root container I can resolve the misalignment of my input to keyboard.
.iOS-fix {
position: fixed; // causes jitter on scroll, but resolves fixed input alignment bug
/*position: sticky; // no jitter, but doesn't resolve fixed input alignment bug*/
/*transform: translate3d(0, 0, 0); // no jitter + resolves fixed input alignment, BUT loses fixed position on children (like .rn-drawer)*/
overflow-y: scroll;
height: 100%;
width: 100%;
}
BUT there is a really bad jitter/stutter on scroll, which after some research I believe that a solution for this is forcing GPU acceleration in the CSS by applying a transformation.
Ok, this solves this jitter and the fixed input alignments issue BUT now the postion:fixed; on .rn-drawer no longer applies; as transformations change the coordinate system for children elements (and thus my drawer is not fixed).
position: sticky; stops the jitter, but same issue with input misalignment.
Is there any viable solution that will solve the input alignment bug, but also allow my input container to be fixed AND not cause any jitter on scroll?
Thanks.

VS code minimap "location highlighting"

I was really excited to see VS Code finally added a minimap option for easier navigation. However, I've been really frustrated that the translucent rectangle showing your current location in a file only shows up when you hover over the minimap. A visual example of what I mean:
Without cursor:
With cursor:
When using this feature in other editors, I find a lot of value comes from quickly seeing where I am in a file. Does anyone know if there is a setting/extension/hack that will keep the rectangle visible?
From the stable version 1.14 (June 2017) there is an option in settings.json:
"editor.minimap.showSlider": "always"
It appears this is already being tracked in a feature request:
https://github.com/Microsoft/vscode/issues/21784
Of interest to some may be that v1.43 added three new colorCustomizations that affect the minimap slider color, including opacity (last two digits in the settings:
"workbench.colorCustomizations": {
"minimapSlider.background": "#ff000060",
"minimapSlider.hoverBackground": "#ff0000",
"minimapSlider.activeBackground": "#2f00ff50"
}
See https://github.com/microsoft/vscode/pull/90631 and https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_43.md#minimap-background-and-slider-colors
I can't see a way to do it without building VS Code from source as it's just a small change to the minimap.css file of setting the opacity: 0; to opacity: 1;
.monaco-editor .minimap-slider {
opacity: 0;
transition: opacity 100ms linear;
}
I can't override the default css from the user settings with
"editor.minimap-slider.opacity": 1,
But I am a noob at this kind of hack.

How to increase the caption area for vaadin timeline

If I add too many/too long captions to a vaadin7 timeline, they will only be displayed partially (i.e. the part we have space for is displayed and the remainder is truncated)
How can I increase this area in order to allocate enough space for all?
timeline.setGraphCaption(container, h.toString());
You need to add these rules in your scss file:
.v-timeline-widget .v-timeline-widget-modelegend{
background: inherit;
}
.v-timeline-widget-legend-label{
height: auto !important;
white-space: normal !important;
}
Before:
After
3 points:
While these rules may not met criteria of well-written CSS or good practice rules (I am looking at you !important), they do the trick. Still, better approach would be to get your hand dirty by editing Vaadin Timeline addon sources.
As you surely noticed text background has changed. That's because we override default background which was designed for only one line (you should provide your own background image)
Bottom of the widget is cut off by few pixels. Well, the only way to fix it is to jump into DOM and css and try fix it. Doable but I haven't tried.

Animation in angular ui bootstrap alerts

Is it possible to add animations to the alerts provided by angular ui bootstrap?
I am particularly interested in fading in an alert that lingers for a while before it automatically fades out again.
Sure, I created the following classes to do just that:
.alert.ng-hide-add,
.alert.ng-hide-remove {
-moz-transition: 0.5s linear all;
-o-transition: 0.5s linear all;
-webkit-transition: 0.5s linear all;
transition: 0.5s linear all;
display: block !important;
opacity: 1;
}
.alert.ng-hide {
opacity: 0;
}
The documentation for animating the ng-hide directive can be found here see the Animations section.

link rollover to change the background image

is there a way to alter a background when you rollover a link? im making a degree show website and want a large sample image to appear in the background when you rollover the link of persons name. i have an image appearing, however its covering all the text and in a fixed position over the link. is there a way to do this so it just alters the background image and stays behind all the other text on the page?
heres what im working with
#hover_img img
{
display:none;
}
#hover_img:hover img
{
display:block;
position:absolute;
top:0px;
padding-top:0px;
}
html
<div id="hover_img">LINK<img src="image" alt="" /></a></div>
thanks!
** fiddle http://jsfiddle.net/5yhsL/ **
Add z-index: -1 to the image on hover:
#hover_img:hover img
{
display:block;
position:absolute;
top:0px;
padding-top:0px;
z-index: -1;
}
You can accomplish this by putting the text inside another element adjacent to your image element. Absolutely positioned elements will take dominance over their neighbors, and one way you can get around that is by assigning a value to the position property for subsequent elements.
Here is a jsfiddle I've whipped up:
http://jsfiddle.net/93mpW/3/

Resources