Browsing Posts in HTML5/CSS3

Way back in the day, you could customize scrollbars in IE (5.5) with non-standard CSS properties like scrollbar-base-color which you would use on the element that scrolls (like the ) and do totally rad things. IE dropped that.

These days, customizing scrollbars is back, but it's WebKit this time. It's a bit better now, because the properties are vendor-prefixed (e.g. ::-webkit-scrollbar) and use the "Shadow DOM". This has been around for a couple of years. David Hyatt blogged it in early 2009 and put together an example page of just about every combination of scrollbar possibilities you could ever want.

- https://css-tricks.com/custom-scrollbars-in-webkit/

Update - Feb 2015

After implementing Scroll n' Scrub on one of our own websites here's a few things I learnt along the way. In the end we opted for a video piece that was exported into single images as "frames", we reduced the frame rate and heavily optimized the images for decreased image count and faster load times. Very similar concept to animated "flick books". Different frame on each page, as you flick through the book the illusion of animation is created. In this analogy, scrolling is our paradigm to flicking through the pages.

The hardest part was seamlessly getting the images to load in the background as the user scrolled/animated. We didn't want to pre-load all 320 images upfront with more traditional Javascript, it kind of defeated the purpose of a seamless animation. In the end we opted for a "double buffering (Slide #25)" technique using the canvas tag. Two canvases are created, one hidden/off-screen; the other being the actual canvas the animation takes place in. Loading images into canvas is surprisingly easy.

Animation was handled through Javascript's requestAnimationFrame(); (rAF) method, but a polyfill was used for cross browser compatibility. rAF has the advantage of leveraging GPU instead of regular client-side processing/CPU.

Some simple Javascript scroll calculation was used to compute user scroll as a % of total scroll, based on total number of frames. As the user scrolled images were preloaded into the canvas off screen and painted onto the main canvas once they were loaded. This had the benefit of reducing "black-outs" or "tearing". These were issues we came across using regular JS preload techniques and then injecting to DOM. If an image (frame) had only half-loaded as the (user) scroll requested it, it resulted in some undesirable flickering or "blacking out". With the canvas technique, the image was only rendered once fully loaded creating a much more seamless animation.

We also added in some gravity to the scroll "Kinetic Scroll" for good measure based on this work by Ariya Hidayat, it uses the same computation as the iOS kinetic scroll.

Original

Scroll n' Scrub™. A phrase I feel sums up this technique beautifully, a technique I'm noticing a lot more on the Internet that introduces some really stunning and immersive front-end presentations.

With numbers for IE8 slowly dwindling and front-end support for this browser falling, front-end developers can now really begin to look forward to some true cross-browser HTML5. IE9, the lethargic example of modern browsers, finally allows front-end developers to introduce some of the more exciting features of HTML5.

This particular technique focuses on the ability to "scrub" HTML5 video using Javascript events such as defaultPlaybackRate(), playbackRate(), and currentTime(). (http://www.w3schools.com/tags/ref_av_dom.asp).

The concept is simple. Take a well directed, orchestrated video. Hide the controls and turn the vertical scroll-bar into the play seek bar. As a user scrolls the video plays forwards or backwards to create a truly immersive experience.

Combine that with some well-timed and placed div overlays, some parallax action and you have some really compelling webpages.

As part of the B2G (Boot 2 Gecko) or, as it's more commonly known, FirefoxOS project (Mozilla is creating an HTML5 operating system), they have created the pdf.js library.

pdf.js is an HTML5 technology experiment that explores building a faithful and efficient Portable Document Format (PDF) renderer without native code assistance.

pdf.js is community-driven and supported by Mozilla Labs. Our goal is to create a general-purpose, web standards-based platform for parsing and rendering PDFs, and eventually release a PDF reader extension powered by pdf.js. Integration with Firefox is a possibility if the experiment proves successful.

- https://mozillalabs.com/en-US/pdfjs/

So, you may have been wondering why PDF's viewed in Firefox are no longer using Adobe Acrobat reader, and, on occasion may not be faithfully recreating the artwork originally saved.

A quick check in (address bar) about:config will reveal a (boolean) pdfjs.disabled value. By default this is false.

If you want to revert to the more traditional Adobe Acrobat viewer then you can set this flag to true.

You can set the pdfjs.disabled pref to true on the about:config page to disable the build-in PDF viewer and use the Adobe Reader instead.

- https://support.mozilla.org/en-US/questions/950988

It also turns out there is support for this in other major browsers such as IE9+, Chrome/Chromium, and (albeit rather buggy) in Safari.

If you're having issues with PDF's not rendering correctly in the browser just have a quick look for pdf.js and maybe revert back to the native Adobe Acrobat PDF viewer.

  • Page
    of 5
  • Next