Wednesday, November 9, 2016

Animating the DOM with Anime.js

Anime.js Animation Library

If you're looking for a fast and lightweight animation library, Anime.js by Julian Garnier is an option you'd like to consider.

This is the first of a series of articles about tools for dynamic DOM animation, including SVG graphics. I don't plan to include specialized canvas-WebGL animation libraries or SVG-specific animation libraries. However, if a library is great at animating HTML elements on a webpage (and ideally also SVG graphics), I will consider it for inclusion in this series.

It is not my intention to dissect each library and delve deeply into its code. Instead, I am going to approach each library from the perspective of someone who mainly works with CSS but would like to explore what JavaScript has to offer when it comes to animating the DOM. Therefore, I will be looking for a tool that is great at manipulating the DOM by dynamically adding and removing CSS styles and/or classes for the purposes of animation by means of a syntax that feels familiar to a CSS developer.

Animation on the Web

As Sarah Drasner explains, when talking about web animation, a useful distinction is between user interface/user experience animation and standalone animation.

Research shows how human perception understands the world better on the basis of moving images. This means that we can understand and assimilate information better when it is presented to us in a moving scene rather than in the form of an image or even a series of static images.

UI/UX animation serves the purpose of aiding users as they navigate a website, absorb information on a webpage, or perform a specific task, e.g., signing up for a newsletter, adding an item to the shopping cart, etc.

By contrast, standalone animation is...

Used to illustrate concepts in the body of the page, either alongside or on it's own.

Sarah Drasner — CSS Conference slides

Here's an amazing CodePen demo by Sarah to illustrate the point.

The distinction is important because when you're animating user interfaces, your aim is to help users perform those tasks which go towards meeting the website's goals. Instead, when creating a standalone animation, you set out to express a certain concept as fully as possible.

That said, both kinds of animation are made for people to enjoy. That's why, when creating your animations, things like performance and accessibility make all the difference between an animation that delights and one that annoys or even hurts users.

Why Use JavaScript for Animation?

Today CSS offers transitions and animations to add movement to the web. However, when it comes to animation on the web, JavaScript is still a big player. Why is this the case? At last we can run an animation using CSS alone, why on earth would anyone need JavaScript to do the job?

To help you decide between CSS and JavaScript animation, consider the following distinctions by Rachel Nabors.

Animation can be:

  • static: the animation runs from the beginning through to the end without decision-making logic. CSS loaders are a case in point. You can create this kind of animation with CSS alone;
  • stateful: a sidebar that opens and closes at the click of a button is a common example of this type of animation. You can build this using CSS and a tiny bit of JavaScript to add and remove the CSS classes responsible for keeping track of the state of the element in your animation;
  • dynamic: this kind of animation can have different outcomes, which depend on various factors like user interaction, DOM events, the state of the animation of other elements on the same document, etc. You can't create dynamic animations with just CSS – in this context, JavaScript is most likely your best friend.

Besides dynamic animations, you could turn to JavaScript for a helping hand with your animations if you come across any of the circumstances below:

  • you need to chain or stagger your animations on more than a few elements. In this case, each subsequent animation needs to occur after the previous one has completed. You can do this with CSS alone by coordinating the delay property on each animated element. However, if you need to change even just one value, making the necessary adjustments on all the chained elements can quickly become unmanageable;
  • you are animating SVG graphics. In this case, the drawback is that CSS animation on SVG is not consistently supported across browsers;
  • if your project needs to support older browsers where CSS animation is not available, resorting to a robust JavaScript solution will make your animations more widely available.

If you'd like to read more on this topic, Myth Busting: CSS Animations vs. JavaScript by Jack Doyle, author of the Greensock Animation Platform, makes some good points.

An Up and Coming Alternative: the Web Animations API

The W3C has been working on a specification that brings together CSS and SVG animation under a unified language without any need for external JavaScript libraries. The API is known as Web Animations and works great for the kind of dynamic animations for which CSS is less suited. You can read this helpful introduction to the Web Animations API (AAPI) by Dudley Storey here on your very own SitePoint.

Work on the Web Animations API has been going on at a sustained pace and a polyfill is also available for browsers that don't provide native support for the API.

All this sounds good and I actively encourage experimenting with the WAAPI. However, at the time of writing, browser support is sketchy and the specification might still change in the future. So, if the WAAPI is not a good fit for your project right now, you can turn to JavaScript animation libraries to get the job done.

Animation Libraries for Dynamic DOM Animation

There is a wide choice of JavaScript animation libraries for you to try out. At the time of writing GreenSock, also known as GSAP (GreenSock Animation Platform), and Velocity.js are among the big players.

Both are fantastic, user-friendly tools and I will talk about them in subsequent articles. However, I'd like to kick off this series with Anime.js, a new JavaScript animation library that's been gaining some significant traction.

Anime's Main Features

The name Anime is Japanese for hand-drawn or computer animation (Japanese: アニメ)

Anime.js JavaScript animation library logo

As for its features, Anime.js...

is a flexible yet lightweight JavaScript animation library. It works with CSS, Individual Transforms, SVG, DOM attributes and JS Objects.

Anime.js supports the following browsers:

  • Chrome
  • Safari
  • Opera
  • Firefox
  • Internet Explorer 10+

With All Animation Libraries Available, Why Anime?

The answer to this question is best left to Anime's author as he explains why he came up with Anime.js when there's something as powerful as GSAP around:

GSAP can do a lot more than Anime. But it’s also way more heavy. My goal with this library was to keep the API simple as possible, focus on the things I really need (multiple timings, easings, playback controls…) while keeping the code super lightweight (9KB minified).

Hacker News

In short, for dynamic animations of HTML and SVG elements which don't require all of the features GSAP and other big libraries offer out of the box, Anime.js can be an excellent option for your project.

Continue reading %Animating the DOM with Anime.js%


by Maria Antonietta Perna via SitePoint

This Week in Mobile Web Development (#133)

Read this on the Web

Mobile Web Weekly November 9, 2016   #133
Peter Cooper recommends
Google's Mobile-First Indexing Approach — Google has begun experiments to make their index mobile-first. Their algorithms will eventually primarily use the mobile version of a site’s content to rank pages.
Google
Chris Brandrick recommends
Browsers, Not Apps, Are The Future of Mobile — Proclamations of an all-native mobile app world ignore the fact that browsers and the web are fast becoming the mobile operating system of the future.
Hugh Durkin
Holly Schinsky recommends
Native Apps are Doomed — As mobile web traffic numbers rise, mobile devs should be considering the Progressive Web App standard as part of their app distribution strategy.
Eric Elliott
Sponsored
Heap is like Google Analytics, except it works automatically — Heap auto-records all events users take in your web or iOS app, so you can graph behaviour, visualize funnels and drill into what leads to conversion.
Heap Analytics

Brian Rinaldi recommends
Building Angular 2 Web and Native Apps from a Single Codebase — Jen Looper walks through the Angular 2 Advanced Seed project designed to optimize sharing code between a mobile, desktop and web application.
Telerik Developer Network
Holly Schinsky recommends
Progressive Web Applications: What Exactly Are They? — An in-depth walkthrough of Progressive Web Apps, their components, features, pros and cons and when to consider using them.
Mark Pedersen
Peter Cooper recommends
A State of Mobile Web Q3 2016 Report — Includes a PDF infographic showing the most popular devices in different regions of the world. There’s also a 36-minute roundup video of the report’s findings.
Jon Arne S.
Chris Brandrick recommends
What Everyone Should Know About The Process Behind App Design — Michael Flarup explains how the process of designing an app has stayed pretty much the same, and how we go through the many phases that constitute the creation of an app.
Smashing Magazine
Brian Rinaldi recommends
The State of Responsive 3D Shapes — Can you create responsive 3D shapes? Ana Tudor explains that the answer is a bit more complex than a simple yes/no.
CSS Tricks
Chris Brandrick recommends
Rethinking Responsive Design ”..the future of the web exists beyond screens.”
Una Kravets
Chris Brandrick recommends
New Relic Adds Infrastructure and Mobile App Tracking to Its Monitoring Service — New Relic is adding new Infrastructure, Unified Dashboards and Mobile Crash Analysis services, to its Digital Intelligence Platform.
TC Currie
Holly Schinsky recommends
PhoneGap Push Plugin 1.9.0 — PhoneGap has released v1.9.0 of the Push Plugin with updates for: a default SENDER_ID, CocoaPod Support, and Force Start on Android.
PhoneGap Blog
Chris Brandrick recommends
Announcing Ionic 2 RC 2 — You can see the changelog here.
Brandy Carney
Holly Schinsky recommends
An Example of the Ionic Auth Service with Ionic 2 — A complete sample app and tutorial on how to use the Ionic 2 Authentication service.
Raymond Camden
Brian Rinaldi recommends
CSS Grids, Flexbox And Box Alignment: Our New System For Web Layout — Rachel Andrew explains that by understanding flexbox you are very close to understanding much of grid layout. Plenty of great CodePen examples.
Rachel Andrew
Brian Rinaldi recommends
Ionic 2 Form Handling & Validation — Several examples to help you master data collection using forms, along with some techniques to excel the user experience.
Gonza Di Giovanni
Chris Brandrick recommends
The Golden Rules Of Bottom Navigation Design — “Navigation is a conversation. It doesn’t matter how good your site or app is if users can’t find their way around.”
Nick Babich
Holly Schinsky recommends
How to Debug Android WebView Content — Quick start info for remotely debugging Android webviews.
Kip Russell
Sponsored
One Application, 4,000+ Opportunities - Try Hired — On Hired companies apply to interview you. Get 1:1 support for your job search plus upfront compensation details.
Hired

Curated by Brian Rinaldi and Holly Schinsky for Cooperpress.
Cooperpress is located at Office 30, Fairfield Enterprise Centre, Louth, LN11 0LS, UK
Update your email address
or stop receiving MWW here


by via Mobile Web Weekly

Lettering.js – jQuery Plugin for Radical Web Typography

Lettering.js is a lightweight, easy to use Javascript span injector for radical Web Typography.


by via jQuery-Plugins.net RSS Feed

This Week's HTML5, CSS and Browser Tech News #265

Read this e-mail on the Web
FrontEnd Focus
Issue 265 — November 9, 2016
Rachel Andrew explains that by understanding flexbox you’re very close to understanding much of grid layout. Plenty of great CodePen examples here.
Rachel Andrew

Zell sets outs to prep you with the knowledge needed to build a custom-made grid in this tutorial.
Zell Liew

Handy insights and approaches for reaching the much desired 60fps for your site’s animations.
Anand Sharma

Frontend Masters
Starting this week, Frontend Masters is offering all their LIVE online workshops from world-class experts, 100% free for members! Get unlimited access to ALL live online workshops, plus 50+ courses for just $39/mo.
Frontend Masters   Sponsor

A large CodePen collection collated by Sarah Drasner featuring techniques that may prove useful in everyday front-end dev.
Sarah Drasner

Why you should be inlining your critical CSS, as well as how to do it using Grunt, npm modules and other tools.
Asha Laxmi

A library built on top of the W3C web component specs for writing functional and performant web components with a small footprint.
Trey Shugart

Firefox Nightly has support for requestIdleCallback, a method for having a function be called in the main thread during a window of idle time.
Mozilla Hacks

A collection of web browsers without a graphical user interface, controlled programmatically. Useful for automation, testing, and other purposes.
Asad Dhamani

Jobs

  • Want Multiple Job Offers? - Try HiredOn Hired, engineers typically get 5+ job offers in 1 week. Find that new opportunity you've been craving and get access to 4,000+ companies instantly. Hired

In brief

Google's Mobile-First Indexing Approach news
Google’s algorithms will eventually primarily use the mobile version of a site’s content.
Google

Announcing Dart Sass: A Dart Implementation of the Sass CSS Pre-Processor news
It’s fast, and compatible with JavaScript, naturally.
Sass

CSS 'position: sticky' To Be Enabled by Default in Chrome 56 news
Chrome Platform Status

CSS Round Display Specifications news
A look at support for round displays in CSS and how to use the features in Crosswalk.
Joone Hur

Download 'Intelligent Caching' from O'Reilly Media 
Use 'Intelligent Caching' as a resource & guide for optimizing performance on your site or app. Download now.
StackPath  Sponsor

Rendering the Mandelbrot Set with WebGL tutorial
nicebyte

Generating Sounds Programmatically in the Browser with JavaScript tutorial
Marc G Gauthier

Get Started on the CSS of the Future with PostCSS-cssnext tutorial
Sitepoint

Capturing an Image from the User via the Browser tutorial
Paul Kinlan

The State of Responsive 3D Shapes tutorial
An incredibly thorough guide.
Ana Tudor

Building a responsive HTML5 app? Learn the must-know techniques in this whitepaper 
If you're a HTML5/JS dev, responsive web design is or will be a requirement in the near future. This whitepaper will give you the must-know on responsive web.
Progress  Sponsor

WebVR: Developing for the Immersive Web slidedeck
Tony Parisi

A Look at the Chinese Language and Typography on the Web story
A thorough look into how Chinese typography is displayed on the web.
Chen Hui Jing

Custom Elements: An Ecosystem Still Being Worked Out opinion
Paul Kinlan

Web Fonts, Boy, I Don't Know opinion
“Web fonts are okay”, but Monica proclaims it’s your “responsibility to make your site load super fast” when using them.
Monica Dinculescu

Rethinking Responsive Design opinion
”..the future of the web exists beyond screens.”
Una Kravets

Why I Won’t Be Using the Fetch API in My Apps opinion
Shahar Talmi

CSS Architecture for Design Systems opinion
Brad Frost

Tool to Produce Gradient Fallbacks for An Image That Resembles The Original tools
Inspired by Harry Roberts’ article.
Ben Briggs

ChaosSocket: A WebSocket Mocking Interface code
Hector Zarco

Curated by Peter Cooper and published by Cooperpress. If you like this, you may also enjoy: JavaScript Weekly, Node Weekly, and React Status.

Stop getting FrontEnd Focus : Change email address : Read this issue on the Web

© Cooper Press Ltd. Office 30, Lincoln Way, Louth, LN11 0LS, UK


by via FrontEnd Focus

Getting Started with Fuse

In this tutorial we'll be creating a Hacker News Reader app with Fuse, a tool for developing cross-platform apps that runs on both Android and iOS devices.

In a nutshell, Fuse is a tool for building cross-platform apps using JavaScript. If you're familiar with React Native and NativeScript, the idea behind Fuse is pretty similar. It uses a JavaScript VM to run JavaScript, UI components are converted to native UI, and it allows access to the different platform APIs. The motivation behind it is to create a tool that's both developer- and designer-friendly. And from what I've seen so far, I can say that they're really on the right track. Some of the highlights of Fuse includes native UI performance, powerful and expressive animation, and instant live-reloading across multiple devices.

Once you've installed the Android SDK or XCode, download the Fuse installer from the downloads page. Just enter your email address, accept the license agreement and click on the "Let's Fuse" button. Once you've done that, it should show you the buttons for downloading the installer for each development platform. Download the one applicable to you. But for this tutorial we'll be using the Windows version.

You can create a new project by launching the Fuse dashboard and click on the "New Project" button. This will ask for the project name and the path to where to save the project.

Once the project is created, it should get listed under "Recent Projects" in the dashboard. Click on that and click on "Open in Sublime Text 3". Fuse has some nice integrations with Sublime Text so it's the text editor that I recommend when working with Fuse projects. But in order for these integrations to work, you first have to install the Fuse plugin using package control. Once installed, it should add features like code completion and showing the build result so you know exactly what's wrong with your code. If you're new to Sublime Text, you can download it here. Package control install instructions can be found here. Once that's done, you can install the Fuse package by pressing ctrl + shift + P on your keyboard and selecting Package Control: Install Package. From there you can search for "Fuse" and select the first result that shows up.

Continue reading %Getting Started with Fuse%


by Wern Ancheta via SitePoint

AtoZ CSS Quick Tip: Using Y-Axis Transforms and Matrices

Y is for Y-Axis transforming and matrices

We can perform all sorts of interesting transformations on elements along various different axis. In this tip, we’ll provide a rundown of all the common options and then look at a lesser known value of transform which allows us to set multiple transform via the matrix() value.

transform along the y-axis

Since the original screencast focused around rotateY(), I thought it would be useful to look at all other available transformations that happen along the vertical y-axis.

We can apply the following transformations:

  • transform:translateY(100px)
  • transform:rotateY(45deg)
  • transform:scaleY(1.5)
  • transform:skewY(30deg)

These values are all limited to the y-axis and can be used to communicate intent that the only transformation along this single axis is being performed.

rotateY() is the only one of these values that performs a 3D transformation, where the element is rotated around the y-axis. If performing any kind of 3D transform, be sure to set transform-style:preserve-3d on the parent element.

Multiple transform

If you want to combine multiple transform together, this can be done by space separating the different transformation functions. The following snippet combines a translation with a skew for example:

Continue reading %AtoZ CSS Quick Tip: Using Y-Axis Transforms and Matrices%


by Guy Routledge via SitePoint

Customizer JavaScript APIs: Panel, Section, and Control