Skip to Content
jQuery Mobile: Up and Running
book

jQuery Mobile: Up and Running

by Maximiliano Firtman
February 2012
Beginner to intermediate
272 pages
6h 20m
English
O'Reilly Media, Inc.
Content preview from jQuery Mobile: Up and Running

Custom Transitions

In Chapter 3 we have already mentioned all the possible transitions available in jQuery Mobile 1.0. Can we define our own transitions? Yes we can, and there are two ways:

  • Using CSS3 animations

  • Using JavaScript

When we define a data-transition attribute (or by applying a transition from JavaScript), jQuery Mobile first verifies if the name is one of the transitions available in the framework. If not, it looks inside a collection called $.mobile.transitionHandlers. If the transition is unknown and not defined in the collection, a default transition is used.

The default transition can be changed, and must be defined as a handler function. By default, the fallback transition is mapped to a custom transition that must be defined in CSS3 animations (see next chapter).

We can also map the default transition to $.mobile.noneTransitionHandler, which basically shows the new page and hides the previous page without any animation.

For example, we can add an explode transition type:

$.mobile.transitionHandlers.explode = explodeTransitionHandler;

We can also change the default transition and then use whatever name we want using the same handler:

$.mobile.defaultTransitionHandler = explodeTransitionHandler;

A transition handler is a JavaScript function that will receive four arguments:

  • Name of the transition

  • reverse, which when set to true, indicates when the transition should occur in reverse

  • toPage, which is a jQuery DOM object of the destination page

  • fromPage, which is a jQuery DOM object ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

jQuery Mobile

jQuery Mobile

Jon Reid

Publisher Resources

ISBN: 9781449331085Errata Page