Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

CHAPTER 8: Animation and Effects > Adding a Little JavaScript

Adding a Little JavaScript

Because the hover CSS selector does not work in iOS, in order to be effective with using our animations we need to use a little JavaScript. Specifically we can use JavaScript and its events such as tap or swipe to initiate a className change, which can start an animation.

Companion Site Reference

Example 8-5. Follow the link below to run these examples on the companion site.

http://www.learnhtml5book.com/chapter8/addingjs.php

Zooming

The first thing I want to test is zooming into an element when I tap it. This can be extremely useful given the size of an iOS device when it comes to viewing high-resolution images.

The example below sets two classNames, scaledimg is the default class name and scaledimg2 is the image when it's zoomed.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint