What is best practice for handling resize events in a polymer element?
OnResize works for me inside a custom element.
@overridevoid attached() { super.attached(); window.onResize.listen((e) { print(e.currentTarget.innerWidth); });}
This is how I will achieve this in Polymer.
connectedCallback() { super.connectedCallback(); this._onResize = this.onResize.bind(this); window.addEventListener("resize", this._onResize); } onResize(e) { console.log('width', e.currentTarget.innerWidth); } disconnectedCallback() { super.disconnectedCallback(); window.removeEventListener("resize", this._onResize); }