Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $9.99/month after trial. Cancel anytime.

Learning AngularJS Animations
Learning AngularJS Animations
Learning AngularJS Animations
Ebook315 pages2 hours

Learning AngularJS Animations

Rating: 4 out of 5 stars

4/5

()

Read preview

About this ebook

AngularJS is an extensive framework used to make full-blown websites with minimal code. Animations in AngularJS are achieved through CSS3 transitions, CSS animations, and JavaScript. AngularJS allows you to create animations with outstanding effects. There are a variety of effects that can be integrated with AngularJS and different ways to achieve the same result. Learning AngularJS Animation swill help you choose a way that best fits your needs. This guide is a complete step-by-step tutorial to improving UX by using animations in AngularJS projects. The first few chapters explain the basics of CSS3 transitions and animations and all the available features such as CSS3 keyframes to be used together with AngularJS, also covering how to move beyond JavaScript animations. The book then shows you how to choose an appropriate approach for creating web apps. It provides you with an understanding of how AngularJS native directives can be animated with CSS or JavaScript and how to animate custom directives using the $animate service.

Finally, you will learn powerful optimization tricks to improve the speed and quality of your animations.

LanguageEnglish
Release dateOct 31, 2014
ISBN9781783984435
Learning AngularJS Animations

Related to Learning AngularJS Animations

Related ebooks

Internet & Web For You

View More

Related articles

Reviews for Learning AngularJS Animations

Rating: 4 out of 5 stars
4/5

2 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Learning AngularJS Animations - Richard Keller

    Table of Contents

    Learning AngularJS Animations

    Credits

    About the Author

    About the Reviewers

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    Why subscribe?

    Free access for Packt account holders

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Conventions

    Reader feedback

    Customer support

    Downloading the example code

    Downloading the color images of this book

    Errata

    Piracy

    Questions

    1. Getting Started

    The definition of animation and the web context

    The need for AngularJS animation

    Choosing when to use JavaScript for animations

    AngularJS – combining JavaScript and CSS3

    Do it yourself exercises

    Summary

    2. Understanding CSS3 Transitions and Animations

    CSS3 transitions

    The transition-timing-function property

    The transition-delay property

    Animatable properties

    CSS3 keyframe animations

    Defining an animation using keyframes

    Separating timing functions for each keyframe interval

    Other CSS keyframe animations' properties

    CSS3 transforms

    The scale function

    The translate function

    The skew function

    Exercise

    Summary

    3. Creating Our First Animation in AngularJS

    The ngAnimate module setup and usage

    AngularJS directives with native support for animations

    Fade animations using AngularJS

    The AngularJS animations convention

    AngularJS animation with CSS transitions

    The ng-enter class

    The ng-leave class

    AngularJS animation with CSS keyframe animations

    The CSS naming convention

    The ngClass directive animation sample

    The ngHide and ngShow animation sample

    The ngModel directive and form animations

    The ngMessage and ngMessages directive animations

    The ngView directive animation

    The ngSwitch directive animation

    The ngInclude directive sample

    Do it yourself exercises

    Summary

    4. JavaScript Animations in AngularJS

    Creating AngularJS animation without CSS3

    The ngHide JavaScript animation

    The ngIf JavaScript animation

    The ngRepeat JavaScript animation

    JavaScript animations as a fallback for CSS animations

    Do it yourself exercises

    Summary

    5. Custom Directives and the $animate Service

    Triggering animations on custom directives

    Animating the enter and leave events

    Using the $animate.move method

    Creating a custom directive animated with JavaScript

    Exercises

    Summary

    6. Animations for Mobile Devices

    Enhance UX on mobile devices with animations

    Transition between views

    Mobile AngularJS frameworks

    Summary

    7. Staggering Animations

    Creating staggering animations

    Staggering animations with a CSS transition

    Staggering animations with a CSS keyframes animation

    Creating staggering animations for other native directives

    Create staggering animations for custom directives

    Summary

    8. Animations' Performance Optimization

    The display and the frame rate

    Finding performance bottlenecks using Chrome DevTools

    Checking FPS using Show fps meter

    Measuring browser layers and Jank on Chrome

    CSS styles in animations you should avoid

    Summary

    Index

    Learning AngularJS Animations


    Learning AngularJS Animations

    Copyright © 2014 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    First published: October 2014

    Production reference: 1251014

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham B3 2PB, UK.

    ISBN 978-1-78398-442-8

    www.packtpub.com

    Credits

    Author

    Richard Keller

    Reviewers

    Douglas Duteil

    Amit Gharat

    Daniel Mackay

    Sathish VJ

    Commissioning Editor

    Pramila Balan

    Acquisition Editor

    Greg Wild

    Content Development Editor

    Rohit Kumar Singh

    Technical Editors

    Mrunmayee Patil

    Shruti Rawool

    Copy Editors

    Deepa Nambiar

    Stuti Srivastava

    Project Coordinator

    Mary Alex

    Proofreaders

    Simran Bhogal

    Ameesha Green

    Paul Hindle

    Clyde Jenkins

    Indexer

    Rekha Nair

    Production Coordinator

    Arvindkumar Gupta

    Cover Work

    Arvindkumar Gupta

    About the Author

    Richard Keller obtained his BSc in Computer Science from State University of Campinas (UNICAMP), Brazil. He is currently a software engineer at Spring Mobile Solutions in the Latin America headquarters located in São Paulo. His work there includes analysis and implementation of systems used by customer's headquarters and development of internal tools to enhance the company's productivity. He works with the AngularJS framework on a daily basis and with a variety of other technologies including TypeScript, C#, and SQL Server.

    He previously worked for an online marketplace for handmade items, a mobile payment company, and an open source e-learning project in an institute at UNICAMP.

    I would like to thank my parents and family for all their support for my education and personal growth. In addition, I would like to thank the open source community of AngularJS and the AngularJS core team for developing and improving this great framework every day. Finally, I am thankful to my girlfriend for supporting me while writing this book.

    About the Reviewers

    Douglas Duteil is a young open source contributor and a part of the Directory team of the Angular UI organization since 2012. He's passionate about web user interfaces, web user experience, and web components.

    While pursuing his Master's degree in Computer Science at University of Paris 8, Douglas had the opportunity to work on digital literature with a group of artists such as Kalamar-e Kidz and the New Fire Tree Press.

    He's now working with SFEIR, Paris, a software development company, and participates in the ngParis meetup.

    Amit Gharat is a full stack engineer, open source contributor, and co-author for AngularJS UI Development, Packt Publishing. He has built and made some of his personal projects open source, such as Directives, SPAs, and Chrome Extensions written in AngularJS. He has an urge to share his programming experiences in an easy-to-understand language through his personal blog (http://amitgharat.wordpress.com) in order to inspire and help others. When not programming, Amit enjoys reading and watching YouTube and comedy shows with his family.

    I would like to thank my family who has encouraged me to do so.

    Daniel Mackay has 9 years of commercial experience, primarily in the Microsoft stack, and is currently a lead developer at a software consultancy in Sydney, Australia.

    He is passionate about all things in web and particularly enjoys working with ASP.NET MVC, Web API, and Entity Framework. He considers himself a very well-rounded developer and is not afraid to get thrown into the deep end of frontend development. Over the past few years, he has been concentrating on full-stack web development, including technologies such as HTML5, JavaScript, and CSS3. He has built a large commercial single-page application with AngularJS, which is used by a major telecommunications company in Australia. He is a big believer of process and is always searching for the most productive tool for the job.

    He is very passionate about technology and is continually improving himself whenever possible through conferences, blogs, books, and personal projects.

    When not coding, you'll probably find him halfway up a cliff in the Blue Mountains, or catching a wave at one of Sydney's many beautiful beaches.

    Sathish VJ is a technologist who is passionate about software specifically—where he is most prolific—and all science, engineering, and technology in general. He regularly attends hackathons, quickly prototyping new ideas on various emerging technologies. He has always been particularly interested in AngularJS, conducting many workshops and training events for the community and has created almost all his recent apps in AngularJS.

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    You might want to visit www.PacktPub.com for support files and downloads related to your book.

    Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details.

    At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

    http://PacktLib.PacktPub.com

    Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.

    Why subscribe?

    Fully searchable across every book published by Packt

    Copy and paste, print and bookmark content

    On demand and accessible via web browser

    Free access for Packt account holders

    If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

    Preface

    The AngularJS framework is a turning point in the evolution of web development. It really helps developers to produce professional web apps by writing less JavaScript code.

    The ngAnimate module, developed by the core team of AngularJS and the open source community, integrated AngularJS features with animation web standards, providing all the benefits from standardization with AngularJS development patterns.

    Before animations were introduced to AngularJS, integrating animations was a bit tricky, as in AngularJS, changes to the model affect the view implicitly (it's part of the two-way data binding concept). In other words, the DOM life cycle management is often controlled by the AngularJS core and animations should be triggered in between those manipulations. To solve this problem, the ngAnimate module was written and redesigned to be completely based on CSS classes. This means that animations should be applied based on element classes. Classes are appended or removed from elements on specific events, so we are able to apply animations as the entry of an element on DOM and the imminent exit of an element from DOM.

    This book will help you learn from the beginning how to add animations to AngularJS web apps, focusing on the ngAnimate module. It's an optional module in AngularJS because the framework is going in a direction that will allow you to choose which modules to use so that the module can fit your needs and be as light as you desire.

    What this book covers

    Chapter 1, Getting Started, will introduce you to the history of animations in web development and explain why the AngularJS animation module is so important. Then, you will get started on the modern web standards of animation, introducing you to when to use each of them.

    Chapter 2, Understanding CSS3 Transitions and Animations, will teach you how to create animations using CSS transitions, CSS animations, and how to animate using the CSS transform, giving us a good base to start using animations with the AngularJS framework in the next chapter.

    Chapter 3, Creating Our First Animation in AngularJS, will walk you through setting up an AngularJS application using the ngAnimate module. Then, we will

    Enjoying the preview?
    Page 1 of 1