iOS7 Frosted Glass Effect with HTML 5 and Javascript

iOS7 Frosted Glass Effect with HTML 5 and Javascript

With iOS7 Apple introduced a completely new design for the 6 year old OS. Among all the changes, one that really caught everyone’s attention was the blurred background effect. Basically some parts of the UI get a nice frosted glass effect. There are a couple of ways to achieve this effect using HTML and CSS. The easiest way is to use CSS filters, however the performance on phones is far from usable. With that in mind I decided to experiment with Canvas and the result was quite good.

So in this post I want to share a little bit about the idea behind this prototype.

Basic workflow

What we want to accomplish here is a simple way to blur the content once it goes underneath a part of the UI. For this prototype we will use an action bar, or header. To do that in HTML we will have to use a little bit of Javascript. Basically what we want to do is:

  1. Render the HTML
  2. Duplicate the content area and convert it to canvas.
  3. Move the Canvas to the Header part
  4. Sync the scroll of the content with the canvas in the header

Basic code

See the Pen eJlfj by Fabio Sasso (@abduzeedo) on CodePen

Javascript

To convert the content area from HTML to Canvas I used a library called html2canvas (http://html2canvas.hertzen.com/). It’s pretty simple to use if you follow the steps in the documentation:

After the Canvas is rendered I then move it to the Header. I also added an ID so I can play with it in CSS and apply the blur effect in the future.

Blur Effect

To apply the blur, I used another library for that, it’s called Stackblur and it applies Gaussian Blur to a canvas element.

Conclusion

The end result works pretty well for a simple iOS7 prototype. I am still working on fixing the issues with the scrolling, iOS doesn’t have “on scroll event” which complicates things a little bit.

Below you can see a demo of the prototype. You can fork it on GitHub (https://github.com/abduzeedo/ios7-blur-html5) and make it better 🙂

Posted in Blog | Comments Off on iOS7 Frosted Glass Effect with HTML 5 and Javascript

17 Clean Web Designs for Your Inspiration

Advertise here with BSA

A clean web design is one that is uncluttered, has good whitespace, and of course has solid typography. This doesn’t mean that a web site has to be void of color and design elements to be considered clean, but you will notice in most cases clean web designs use both sparingly. For your inspiration, we’ve gathered a collection of web sites that are good examples of what clean design is all about.

Cultivated Wit

17 Inspiring Examples of White Usage in Web Design

Pack

17 Inspiring Examples of White Usage in Web Design

David Yeiser

17 Inspiring Examples of White Usage in Web Design

Goods

17 Inspiring Examples of White Usage in Web Design

Pennant

17 Inspiring Examples of White Usage in Web Design

Karlyn

17 Inspiring Examples of White Usage in Web Design

Alt for Everyone

17 Inspiring Examples of White Usage in Web Design

Jakob Fridholm

17 Inspiring Examples of White Usage in Web Design

Studio Bada Bing

17 Inspiring Examples of White Usage in Web Design

Present Plus

17 Inspiring Examples of White Usage in Web Design

Speed Motion

17 Inspiring Examples of White Usage in Web Design

Simeon

17 Inspiring Examples of White Usage in Web Design

Zinio

17 Inspiring Examples of White Usage in Web Design

Januar

17 Inspiring Examples of White Usage in Web Design

Whatsmynvme

17 Inspiring Examples of White Usage in Web Design

Emanuela Terrile

17 Inspiring Examples of White Usage in Web Design

Rob Wootten

17 Inspiring Examples of White Usage in Web Design

Posted in Blog | Comments Off on 17 Clean Web Designs for Your Inspiration