Using figma animations in JavaScript - frontend

I am totally confused on how to use the animations made in figma to use in a front-end app like a loading spinner, exporting SVGs are easy but how to export a whole animated SVG or I have to animate it with CSS or JS???

In figma the animations are actually transitions.
You can't "export" animations and just add them. But you can copy some parts of the animation code for CSS.
In the edit mode of figma, you can see how the animation is created. But first look
If it is animated in figma: In the inspect tab (right sidebar) look for Interactions, there you will find transition, duration and more info to use when you animate it.
Here is an example on what animation details you can copy:
// On drag
// Navigate to: "Frame 2";
// Animate: Smart animate;
animation-timing-function: ease-out;
animation-duration: 300ms;

Related

How did they do the text graphic set on an angle in TheDailyBeast.com?

How did they do the text graphic set on an angle in TheDailyBeast.com? Go to this link: https://www.thedailybeast.com/msnbc-host-lawrence-odonnell-accuses-cnn-of-helping-trump-spread-lies?ref=scroll
Notice just under the headline, a subquote is positioned on an angle? It's not a graphic. It's live text. How did they get the text to be on an angle like that without making a graphic? And is their site Java? CSS?
For issues like this, inspect the code on the page in question, this is a simple css rotation transform. When you inspect the HTML, you will find it's quite simple:
<div class="Rubric__content">‘WE DON’T BRING ON LIARS’</div>
Then have a look at the styles in the dev tools:
.Rubric__content {
transform: rotate(-3deg);
}

How to play gif with Fabricjs?

I know fabricjs can play Video and sprite sheet, But I have a lot of gif files, can I play these gif directly with fabricjs? I am not able to find method in Fabricjs website.
According to specs about the Canvas 2DRenderingContext drawImage method,
Specifically, when a CanvasImageSource object represents an animated image in an
HTMLImageElement, the user agent must use the default image of the animation (the one
that the format defines is to be used when animation is not supported or is
disabled), or, if there is no such image, the first frame of the animation, when
rendering the image for CanvasRenderingContext2D APIs.
This means that only the first frame of our animated canvas will be drawn on the canvas.
This is because we don't have any control on animations inside an img tag.
And fabricjs is based on canvas API, thus regulated by the same rules.
The solution is you need to parse all the still-images from your animated gif and to export it as a sprite-sheet. You can then easily animate it in fabricjs thanks to the sprite class.

Is there a way I can modify my page background color to show as random shades with svg?

I have a black #000 page background on my web page.
Is there a way that I can change this with SVG to show a random effect of small #111 and #222 colored squares. I was told I could do this with SVG but I don't have any idea where to start. Even a really simple example would be a great help.
I'm looking for a solution for IE9+ browsers.
SVGs can be used as background images they same way that a PNG or JPG can. Create an SVG with any suitable editor - such as Inkscape - and include it the way you normally would.
background-image: url(../images/mybackground.svg);

how can one resize portions of a css-sprite?

I'd like to improve upon jQuery's dialog code by using CSS-sprites, and thus also add animations of the dialog borders.
To do this, i'd like all the artwork to be in 1 png file, a css sprite.
My problem is that in order to support a dialog that maximizes to 2 or 3 monitors, i think i'd have to put 5000px wide / high border graphics in the css sprite file. Because i can't find a way to resize a selected portion of a css sprite image.
Basically i want to resize from the sprite image a region (t,l,w,h) to a DIV or IMG on my page with a different width and height.
I'd like to know, is this even possible? It seems background-position does not support this at all.
I've tried the first solution in How can I scale an image in a CSS sprite, but could not get it to work using that.
I've tried using the new background-size property in conjunction with background-position, but that also does not produce the results i want.
Spent another few hours twiddling with css, but could not get sprites to work for dialogs.
But my animated dialogs don't need many frames (not unless you want to put actual video as a dialog backdrop online), so for the dialog theme i'm designing now i have 8 312x312 png's as frames, 8 requests, 386kb total. Just enough to create a glowing animation for when the dialog is in a "highlighted" state. It's do-able.
I'm using the technique from How can I scale an image in a CSS sprite
See http://mediabeez.ws in about a month for the opensource release of animated dialogs.
I will be developing and testing this standalone component when it's used by my own homegrown CMS, so it will have the ability do be themed, dragged and dropped, things like that.

Rollover overlays with SVG

i want to acheive the effect on this page using SVG. As you can see it uses a series of PNG transparent overlays when the user mouses over a polygonal hotspot drawn on a product.
What i want to achieve is the same thing with SVG, but without messing about with creating a load of PNGs, so that when the user mouses over an area the transparent shape (with link on it) appears over the top. The SVG shape would be built from a set of coordinates exactly as a polygonal hotspot would on an image map.
So i guess my first question is, can this be done with plain old SVG or do i need to use something like Raphael to achieve this? Never seen this effect before with SVG so if anyone has an example like that would be very useful.
Thanks in advance.
There are several ways to get this effect with plain old SVG. Probably the simplest is to use CSS within the SVG. For example:
<style>
.overlay:hover
{
opacity: 0.5;
}
</style>
<svg>
<a xlink:href="http://www.wherever/you/want/to/link/to.com">
<path class="overlay" d="Coordinates of your shape..." />
</a>
</svg>
I've written about various other methods at:
http://www.petercollingridge.co.uk/data-visualisation/mouseover-effects-svgs
Yes it can be done with SVG only, with or without javascript.
One way to get the effect would be to overlay a white semi-transparent path on top of the image that you want to whiten. Another way would be to use an SVG filter to process the image directly, similar to what I've done here or here to recolor a PNG (view page source and feel free to reuse that in any way you like).
You'll want to make use of the 'pointer-events' property most likely. Here's an example showing how to detect mouse-events on the fill and/or stroke of an svg shape, even if the shape is invisible.

Resources