Les nouveautés et Tutoriels de Votre Codeur | SEO | Création de site web | Création de logiciel

Seo Master present to you: On April 7th, Google launched a new version of Gmail for mobile for iPhone and Android-powered devices. We shared the behind-the-scenes story through this blog and decided to share more of what we've learned in a brief series of follow-up blog posts. This week, I'll talk about different ways to animate the floaty bar.

Even from the earliest brainstorming days for our new version of Gmail for iPhone and Android-powered devices, we knew we wanted to try something novel with menu actions: a context-sensitive, always-accessible UI element that follows conveniently as a user scrolls. Thus, the "floaty bar" was born! It took us a surprisingly long time, experimenting with different techniques and interactions, to converge on the design you see today. Let's look under the covers to see how the animation is achieved. You may be surprised to find that the logic is actually quite simple!


Screenshots of the floaty bar in action

In CSS:
.CSS_FLOATY_BAR {
...
top: -50px; /* start off the screen, so it slides in nicely */
-webkit-transition: top 0.2s ease-out;
...
}
In JavaScript:
// Constructor for the floaty bar
gmail.FloatyBar = function() {
this.menuDiv = document.createElement('div');
this.menuDiv.className = CSS_FLOATY_BAR;
...
};

// Called when it's time for the floaty bar to move
gmail.FloatyBar.prototype.setTop = function() {
this.menuDiv.style.top = window.scrollY + 'px';
};

// Called when the floaty bar menu is dismissed
gmail.FloatyBar.prototype.hideOffScreen = function() {
this.menuDiv.style.top = '-50px';
};

gmail.floatyBar = new gmail.FloatyBar();

// Listen for scroll events on the top level window
window.onscroll = function() {
...
gmail.floatyBar.setTop();
...
};
The essence here is that when the viewport scrolls, the floaty bar 'top' is set to the new viewport offset. The -webkit-transition rule specifies the animation parameters. (The 'top' property is to be animated, over 0.2s, using the ease-out timing function.) This is the animation behavior we had at launch, and it works just fine on Android and mobile Safari browsers.

However, there's actually a better way to achieve the same effect, and the improvement is particularly evident on mobile Safari. The trick is to use "CSS transforms". CSS transforms is a mechanism for applying different types of affine transformations to page elements, specified via CSS. We're going to use a simple one which is translateY. Here's the same logic, updated to use CSS transforms.

In CSS:
.CSS_FLOATY_BAR {
...
top: -50px; /* start off the screen, so it slides in nicely */
-webkit-transition: -webkit-transform 0.2s ease-out;
...
}
In JavaScript:
// Called when it's time for the floaty bar to move
gmail.FloatyBar.prototype.setTop = function() {
var translate = window.scrollY - (-50);
this.menuDiv.style['-webkit-transform'] = 'translateY(' + translate + 'px)';
};

// Called when the floaty bar menu is dismissed
gmail.FloatyBar.prototype.hideOffScreen = function() {
this.menuDiv.style['-webkit-transform'] = 'translateY(0px)';
};
Upon every scroll event, the floaty bar is translated vertically to the new viewport offset (modulo the offscreen offset which is important to the floaty bar's initial appearance). And, why exactly is this such an improvement? Even though the logic is equivalent, iPhone OS's implementation of CSS transforms is "performance enhanced", whilst our first iteration (animating the 'top' property) is performed by the OS in software. That's why the experience was unfortunately somewhat chunky at times, depending on the speed of the iPhone hardware.

You'll see smoother looking floaty bars coming very soon to an iPhone near you. This is just the first in a series of improvements we're planning for the mobile Gmail floaty bar. Watch for them in our iterative webapp, rolling out over the next couple of weeks and months!



Previous posts from Gmail for Mobile HTML5 Series:
HTML5 and Webkit pave the way for mobile web applications
Using AppCache to launch offline - Part 1
Using AppCache to launch offline - Part 2
Using AppCache to launch offline - Part 3
A Common API for Web Storage
Suggestions for better performance
Cache pattern for offline HTML5 web application
Using timers effectively
Autogrowing Textareas
Reducing Startup Latency
2013, By: Seo Master
Seo Master present to you:
By Scott Knaster, Google Code Blog Editor

Hackathons are a blast. There are few experiences better than writing code all night with dozens or hundreds of others, consuming free food, and converting that sweet sleep deprivation into creativity as you hack. As hackathons go, this one is spectacular: Hack4Transparency takes place in Brussels at the European Parliament. The goal of this event is to make data more accessible and intelligible to consumers and to government.


You expect food and WiFi at a hackathon. But this is really cool: if you’re selected to attend, the hackathon pays your travel and accommodation expenses, and a couple of the best hacks will win a prize of €3.000. If that got your attention, read the full story on our Open Source Blog, and then apply to attend.

When I was a wee hacker, I would sometimes break up my coding sessions with a primitive videogame called Pong. Physicists at Cambridge University are still playing this game, sort of, except now they’re knocking a single electron back and forth. As if that Pong ball wasn’t small and easy to miss enough already.

Finally, if you have some time this weekend and you’re not coding or playing video games, you can check out this excellent collection of sounds from spaceflights posted by NASA. You can even make them into ringtones, so if you want to hear a 50-year-old Sputnik beep when your friends call, go for it.

2013, By: Seo Master
Seo Master present to you: Alongside the exciting release of Google Sidewiki today, we're also happy to announce the availability of the first version of the Google Sidewiki Data API. Google Sidewiki is a new feature of Google Toolbar (for Firefox and Internet Explorer) that lets everyone contribute helpful information next to any webpage. Our post over on the Google Blog goes into more detail and also has a video that shows Sidewiki in action. To start using it yourself, go to google.com/sidewiki and install Google Toolbar with Sidewiki.

On the developer side, we're releasing a Google Sidewiki Data API today that lets you work freely with the content that's created in Google Sidewiki. You can use it to retrieve all entries written about a particular webpage as well as all entries written by a given Sidewiki author.

So after you've played with Sidewiki in the browser, give it a whirl in your console too -- we have client libraries, documentation and code samples ready to go for you. We'll be excited to see what gadgets, projects and extensions you'll think of. A translation gadget that displays and translates Sidewiki entries on the fly? A Google App Engine-powered browser of all Sidewiki entries? Your own browser extension or Greasemonkey script?

The Google Sidewiki API is available in Google Code Labs and is read-only at the moment. We've set up a developer-oriented discussion group and issue tracker where you can discuss your experiences with the API and where we'd love to hear about your feedback and projects. Keep us posted!

2013, By: Seo Master
Powered by Blogger.