I had a heck of a time implementing a simple scene fade (or “scroll fades” as they’re also called) in TapNote, mainly thanks to the lack of good information surrounding them. Most folks in the Palm forums recommend looking at the Style Matters example project, but Style Matters was apparently coded by someone who also believed that Coding Style Doesn’t Matter, so screw that.
Sadly, scene fades are only provided for free with some elements (the command menu, for instance), so most of the time you have to implement them by hand.
To get your scene fades up and running, you’ll need to stick a little extra HTML in your scene, add a CSS snippet to your stylesheet, and copy the image resources into your app.
HTML
The HTML is very straight-forward. Just stick this at the very bottom of your scene (don’t nest it in anything):
<div class="scene-fade bottom" x-mojo-scroll-fade="bottom"></div>
<div class="scene-fade top" x-mojo-scroll-fade="top"></div>
Obviously, if you only wanted a top or bottom fade, you’d only include one or the other.
CSS
This CSS snippet is a vastly condensed and improved version of the CSS used by the Style Matters program. Note that you’ll probably need to set height: 100% on your HTML and body elements because otherwise the absolute positioning of the scene fades might not work. If you do so and you’re still not having your bottom scene fade positioned properly, try additionally setting height: 100%
on the wrapper element for your scene.
html, body {
height: 100%;
}
/* === Scene Fades === */
.scene-fade {
height: 54px;
width: 100%;
position: fixed;
left: 0px;
z-index: 100000;
-webkit-palm-mouse-target: ignore;
}
.scene-fade.top {
top: 0px;
background: url(../images/fade-top.png) repeat-x center bottom;
}
.scene-fade.bottom {
bottom: 0px;
background: url(../images/fade-bottom.png) repeat-x center bottom;
}
Images
The images you need are squirreled away in the WebOS SDK. For instance, the ones I ended up using were located in this folder:
PalmSDK/0.1/share/samplecode/stylematters/images/
And were called my-scene-fade-bottom.png
and my-scene-fade-top.png
.
If locating those images is too much effort, though, you can just download the example code.
Finally, you will of course need to drop the images into your root images folder, and adjust the path to them in the CSS if it’s located more than a single level away from the project root. Enjoy!
No responses to “Implementing scene fades in WebOS”
Leave a response