March 25th, 2009
Whilst implementing my new Wordpress theme, I came up with this quick snippet to achieve the ‘max-width’ CSS rule in Internet Explorer. Crucially, it avoids nasty CSS expression hacks, yet only comes into effect if a ‘max-width’ rule is explicitly set for the given element in your stylesheet, which hopefully means less housekeeping if you happen to alter your presentation in the future. Both IE6 and IE7 are capable of retrieving the computed style values despite not implementing them (IE7 actually implements max-width under a strict DOCTYPE).
function applyMaxWidth() {
if(this.currentStyle) {
var desiredMaxWidth = this.currentStyle["maxWidth"] || this.currentStyle["max-width"];
if(desiredMaxWidth && this.offsetWidth > parseInt(desiredMaxWidth, 10)) {
this.style.width = desiredMaxWidth;
}
}
}
applyMaxWidth.call(myElement);
June 14th, 2008
Over at bragster.com we’re hard at work on a site-wide upgrade in which web video is going to play a big part. In preparation, I’ve been prototyping a number of flash widgets including a carousel [see it in action]. Carousels are a great way to provide a list of rich media links in a small area of a page and technologies like flash/actionscript or javascript provide the opportunity to implement some creative interactivity.
Click here to see the flash video carousel in action.
Feedback has been positive but admittedly this implementation is far from ideal. Were I to ‘productionize’ this prototype I would need to optimize some of the effects for lower-spec computers (the blurred scrolling effect is particularly sluggish). The cursor based navigation would also need fine tuning, my friend Andy suggested modeling the velocity control on a bell-curve.
Annoyingly, I ran into problems when creating the reflection effect in that I couldn’t redraw/duplicate the thumbnail file with the BitmapData class. As a consequence the carousel currently loads each thumbnail twice. This morning I found a solution at developer Ryan Taylor’s blog, using the checkPolicyFile property on movieClipLoader.
No doubt I’ll post another update should this prototype ever make it into a production environment.