Categories
Obecto Blogs
Popular Tags
Blogroll
By Imogen Riley, Digital Marketing Manager, Adobe APAC
Looking to boost your business’ online engagement? Learn how Murdoch University in Perth, Australia leveraged the Adobe Digital Marketing Suite to engage customers with content through s… More
By Imogen Riley, Digital Marketing Manager, Adobe APAC
Want to learn how to gain a competitive advantage, strengthen customer relationships and extend brand value – and top it off by hitting the ski slopes? Then you’ll want to book a tripSta… More
With the addition of CSS transitions and transforms, web developers can create interactive content with relatively simple markup. Understanding how to use these features with SVG, which has its own transform and animation systems, can be a little difficult.
For example, let’s take a look at a simple interactive element, which animates its color and rotation when moused over.
Note: The demos use features still under development. These features have full support in the latest versions of Safari, Firefox, Chrome, and Opera. IE9 has limited support, and you must disable the compatibility view list under Tools -> Compatibility View Settings.
[sourcecode language="xml" title="main.svg"]
<svg xmlns="http://www.w3.org/2000/svg">
<rect x="50" y="50" width="100" height="100"
rx="20" ry="20" fill="blue">
<animate attributeName="fill" to="green"
begin="mouseover" dur="0.5s" fill="freeze" />
<animate attributeName="fill" to="blue"
begin="mouseout" dur="0.5s" fill="freeze" />
<animateTransform attributeName="transform"
type="rotate" from="0 100 100" to="30 100 100"
begin="mouseover" end="mouseout" dur="0.5s"
fill="freeze"/>
<animateTransform attributeName="transform"
type="rotate" from="30 100 100" to="0 100 100"
begin="mouseout" end="mouseover" dur="0.5s"
fill="freeze"/>
</rect>
</svg>
[/sourcecode]
The SVG markup involves four declarative animations, one for the mouseover fill animation to green, one for the mouseover rotation to 30 degrees about the point 100, 100, one for the mouseout fill animation to blue, and one for the mouseout rotation to 0 degrees about the point 100, 100. This type of SVG animation (SMIL) offers a large degree of customization, but in exchange the markup can become quite dense, especially in the case of a simple state animation.
CSS transitions and transforms give us another method of specifying the same animation. We can generate a similar effect using two styled divs.
[sourcecode lang="css" title="styles.css"]
#csscontainer {
position: relative;
width: 200px;
height: 200px;
}
#cssrect {
position: absolute;
left: 50px;
top: 50px;
width: 100px;
height: 100px;
background-color: blue;
border-radius: 20px;
transition: all .5s ease-in-out;
}
#cssrect:hover {
background-color: green;
transform: rotate(30deg);
}
[/sourcecode]
[sourcecode lang="html" title="main.html"]
<div id="csscontainer">
<div id="cssrect"></div>
</div>
[/sourcecode]
In this example, the inner “rect” div has two different styled states, normal and hovered. The states differ only in background color and transform. Using the CSS transition property, we can tell browsers to animate between the two.
Can we use the same CSS styling in SVG? Well, almost. SVG already has some existing support for CSS. If we were to draft the following markup, most of it would already work.
[sourcecode lang="css" title="styles.css"]
rect {
fill: blue;
transition: all .5s ease-in-out;
}
rect:hover {
fill: green;
transform: rotate(30);
}
[/sourcecode]
[sourcecode lang="xml" title="main.svg"]
<svg xmlns="http://www.w3.org/2000/svg">
<rect width="100" height="100" rx="20" ry="20" />
</svg>
[/sourcecode]
The only missing piece is support for CSS transforms on SVG elements (transform: rotate(30)). We might not have to wait too long though. A couple of folks here at Adobe, together with Apple and the web community, are drafting a proposal to bring together CSS and SVG transforms. The proposal would allow you to choose whatever combination of transforms, CSS transitions, and SMIL animations best suits your needs.
Visiting Chicago? This is the only app you need. Get details on hotels, restaurants, museums, shopping, theater and more, plus up-to-date happenings and hot spots.
Inside:
► Calendar of shows, events and festivals
► Maps of downtown and public tran… More
We recently caught up with esDot Studio’s owner Shawn Blais to learn about some of his recent projects using Flash and AIR for game and app development. Check out the Q&A below to see what Shawn is creating, monetizing and having fun doing w… More
I’m working on an HTML/JS application that lets users work with local files directly in the browser, and I’m using some new HTML5 APIs to access local files. It works great (in Chrome and Firefox, anyway — see note below), however my … More
New After Effects Course by Jeff Foster
Jeff Foster, and video2brain, have just released a new video tutorial series, “Fundamentals of Compositing, Tracking, and Roto Techniques with After Effects.”
In this workshop Jeff Foster — video pr… More
- Neal Davies
I’m pleased to announce that the first service pack for ADEP/LiveCycle v10 is now available. It is made up of two parts; Document Services SP1 for the LiveCycle Modules (Forms, Output, Reader Extensions, Process management …) and Expe… More
Sencha is hosting a webinar on February 14 about moving from Flex to their HTML/JS based solution. http://pages.sencha.com/flex-to-sencha-webinar.html?ls=Website&ss=Events Learn how to easily build rich, cross browser applications with HTML5 a… More
Our globetrotting photo evangelist has created a slideshow of images taken during her travels.
I would not expect the images to hold the same significance to you, the viewer, as they did for me. But that is not the point.
I am sharing this slideshow t… More