PDA

View Full Version : Real Time Resize Function and Mozilla


Graeme Hackston
06-27-2002, 11:38 PM
The example below works in real time in IE. In NN6.2.1, when the window is grabbed and resized, the resize function is only executed after the mouse button is released.

Thinking it was something I was doing I downloaded Mozilla 1 to test in it and it acts exactly the same.

Is this how Mozilla reads scripts onresize? If so, is there a fix?

Thanks for your help.

<edit>Please note, there is a space (again LOL) between "java" and "script:void" in the link that needs to be removed if you test this (I can't by editing)</edit>

<html>
<head>
<title>Test</title>
<script type="text/javascript" language="JavaScript">
function getElement(id) {
if (typeof document.all != 'undefined') return document.all(id);
if (typeof document.getElementById != 'undefined') return document.getElementById(id);
if (typeof document.layers != 'undefined') return document.layers[id];
return null;
}

function showById() {
for (var a=0; a<arguments.length; ++a) {
var el = getElement(arguments[a]);
if (!el) return;
if (typeof el.style != 'undefined') el.style.visibility = 'visible';
else if (typeof el.visibility != 'undefined') el.visibility = 'show';
}
}

function hideById() {
for (var a=0; a<arguments.length; ++a) {
var el = getElement(arguments[a]);
if (!el) return;
if (typeof el.style != 'undefined') el.style.visibility = 'hidden';
else if (typeof el.visibility != 'undefined') el.visibility = 'hide';
}
}

function hide() {
hideById('test');
}
</script>
</head>
<body onresize="hide()">
<div id="test">
content content content<br>
content content content<br>
content content content
</div>
<a href="javascript:void(0);" onClick="showById('test')">show</a>
</body>
</html>

jkd
06-28-2002, 12:31 AM
http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-htmlevents

There is where the resize event is specified in the DOM2 HTML Events spec.

Since it doesn't describe a precise behavior of when to fire it, I suppose it is up to the individual vendor to decide.

Now, what makes more sense? onresize firing when the user isn't done resizing, or firing after he has completely finished the action?

The click event doesn't fire before mouseup, because the user hasn't completed clicking yet. I believe the people at Mozilla who implemented the resize event were probably thinking along the same lines.

Now, you can experiment with

window.watch('innerWidth', someFunction);

But I'm not too sure if it would work.

Graeme Hackston
06-28-2002, 12:43 AM
Thanks jkd

In my specific case, divisions will overlap that aren't supposed to and when the user releases the mouse they will jump to their positions and look erratic.

I can, however, see what you mean by it being a gray area and can see why Mozilla might make that decision.

I was experimenting with setTimeout to no avail, I'll see if I can do something with window.watch

Thanks for your speedy reply.