2

I am using CSS3 resize: vertical; to allow the user to resize a Div, and would like to be notified when this happens (so that I can adjust the size of other elements with Dart code if necessary).

How can I attach an event listener for the user resize event? ( DivElement.on.resize does not exist.)

Alexandre Ardhuin
  • 71,959
  • 15
  • 151
  • 132
Peter B
  • 603
  • 1
  • 8
  • 18
  • The browser does not fire resize events, unfortunately. So this is not possible in Dart nor JavaScript, at least not without some tricks (like listening to mouse presses and keeping the size of the input in memory for later comparison, etc.) – Kai Sellgren Jan 06 '13 at 00:41
  • That seems to contradict: [link](http://www.w3schools.com/jsref/event_onresize.asp): "The onresize event is supported in all major browsers. ... onresize is Supported by the Following HTML Tags: ,
    , , ,
    , ,
    – Peter B Jan 06 '13 at 07:41
  • Yes, but I'm talking about this specific scenario. The resize event does not fire for textarea (at least not on Chrome). – Kai Sellgren Jan 08 '13 at 07:36
  • Thanks Kai. I see what you are saying (even though it was a Div, not Textarea I was talking about). Presumably the browsers will implement this in the future... – Peter B Jan 08 '13 at 19:54

1 Answers1

2

When you want to observe event which is not listed under the on getter, you can use $dom_addEventListener to set event listener.

Thus, if you would like to use something like the unexisting divElement.on.resize, you can use :

divElement.$dom_addEventListener("resize", (e) {
  // event occurs
});

That said, unlike click event, the resize event doesn't seem to be fired (even in javascript).

Alexandre Ardhuin
  • 71,959
  • 15
  • 151
  • 132