Keilly: Widget Resize Bug

Monday, May 7, 2007

Widget Resize Bug

Looks like there's a bug in Dashboard where if you resize a widget vertically only the widget gets clipped rather than resized. This is really annoying because once the resize corner itself is clipped out it's no longer possible to get it back and the widget is left permanently in the clipped state. Removing and re-adding is the user's only option.

Here's a hack to the resize code that prevents this. Add something similar around the window.resizeTo(x,y) statement in Apple's standard code to do resizing. The code contains some size limiting code too as this also interacts

function sizeWidget(x,y)
if (x == window.innerWidth && y == window.innerHeight)

// size limiting code
if (x<=200)
x = 200;
if (x>=440)
x = 440;
if (y<=130)
y = 130;
if (y>=340)
y = 340;

// prevent vertical resize bug
if (y>130 && y<340 && y != window.innerHeight &&
x == window.innerWidth)

// finally the original resize

All that's happening is that if our condition is met (height changed, width unchanged) then the widget is resized horizontally by one pixel, before being immediately resized to the desired size.

It's not perfect - a slight wobble is barely noticeable on my machine when resizing vertically, but it's nicer than the widget being chopped.


maviada said...

its really works. thanks a lot.

Anonymous said...

Bravo, what necessary words..., a brilliant idea