WebMess

Informatica, Web ed altro… il blog di Alessio Caprari.
  • rss
  • Home
  • Chi Sono

SteerMe – Firefox Orientation Bookmarklet

alessio | 6 November 2009

Just a few days ago, the guys at Mozilla released the first beta version of the incoming Firefox 3.6.

While playing with it, I was wondering, which is the coolest feature introduced in this new release? Well, if you are a user, it should be the full screen support for native HTML5 video. If you are a developer, it may be the new CSS enhancements. But, what if you are a Macbook user?

If you are a Macbook user, it will surely be the detection of the notebook orientation using its integrated accelerometer.

There are a bunch of demo showing this new functionality, they were so exciting I wanted to build one on my own. So, here it is a brand new orientation bookmarklet:

SteerMe

Simply drag and drop the SteerMe button into the bookmarks toolbar of Firefox, or copy its link and manually create a new bookmark. Then, go to a new web page, press the newly created bookmark and begin to rotate your Macbook.

You will see the page still vertical while you rotate the notebook on the left and on the right, you will see it stretched and tightened while you move the keyboard up and down. And you will see the page bounce when, ehm…, you drop your precious notebook!

Tablet-like visualization with Macbook rotated on the left

Tablet-like visualization with Macbook rotated on the left

Stretched page with keyboard upside down

Stretched page with keyboard upside down

How does it work? This is the bookmarklet code with extra spaces:

1
2
3
4
5
6
7
8
9
10
11
12
window.addEventListener &&
window.addEventListener("MozOrientation", function(e) {
    var h = innerHeight,
        ox = scrollX + innerWidth / 2,
        oy = scrollY + h / 2,
        bs = document.body.style;
    bs.MozTransformOrigin = ox + "px " + oy + "px";
    bs.MozTransform = "rotate(" + (90 * e.x) + "deg) " +
                      "scaleY(" + (e.y + 1) + ") " +
                      "translateY(" + (-h * (e.z + 1)) + "px)";
}, true);
void(0);

As with every bookmarklet, its Javascript code must be as short as possible and tends to be quite obfuscated, but it is very simple. First of all, we will listen to the new MozOrientation event on the window object. Then we will apply a CSS transform to the body of the page using the event orientation data.

Comments
No Comments »
Categories
Javascript
Tags
accelerometer, bookmarklet, CSS, firefox, Javascript, macbook, orientation
Comments rss Comments rss
Trackback Trackback

La scomparsa della mela

alessio | 14 October 2008

Sbaglio o dalla tastiera dei nuovi MacBook è scomparso il simbolo della mela?

Update: Giulio nei commenti fa giustamente notare che il simbolo era scomparso dalle tastiere Apple già da qualche mese. La tastiera dei MacBook appena usciti è comunque nuova, sono infatti scomparsi tutti i simboli ad eccezione di quello del punto di interesse, niente simboli per Shift, Caps Lock, Tab e Delete e addirittura per il tasto Enter!

Comments
5 Comments »
Categories
Computer
Tags
apple, Computer, macbook, mela, notebook, portatile, tastiera
Comments rss Comments rss
Trackback Trackback

Recent Posts

  • SteerMe – Firefox Orientation Bookmarklet
  • Gli anni passano…
  • Questionario Creative Commons
  • Bell’articolo sul Corriere della Sera
  • Android, libertà o controllo?
  • La scomparsa della mela
  • www.webmess.it: nuovo dominio
  • Qui, qui e qui
  • Statistiche sui click in uscita
  • CSS transform in Firefox 3.1

Blogroll

  • A List Apart
  • John Resig
  • Quinta’s weblog
  • Surfin’ Safari
  • The WHATWG Blog

Info

RSS Feed

Creative Commons License

WordPress link

Design by Jide

Friends

  • My Little Vineyard
  • Nerdsopolis

Tag Cloud

android apple benvenuto Blog Browser chrome click Computer contenuto corriere CSS dominio feed filosofia firefox free software gecko google hacker html html5 indirizzo Javascript kill switch lavoro link macbook mela notebook notizia ogg Open Source portatile prestazioni rss script sito statistiche stile tastiera theora video vorbis webkit wordpress
Creative Commons License Tutto il contenuto di questo blog è tutelato da una licenza Creative Commons Attribuzione-Non commerciale 2.5