javascript - AngularJS watch element height change in directive -


i realize there several similar questions, checked them don't seem cover case. have fluid flexbox-based layout. of window used container block, shrinks when siblings appear. like

<body>     <div class="menu"></div>     <div class="contact"></div>     <div class="container"></div> </body> 

the container height not changed directly, it's recalculated browser when toggle other elements, such menu.

i want watch container height , recalculate elements in directive. watch height this

scope.$watch(()=>parentelement.prop('offsetheight'), resize); resize=()=>{console.log('resize called');}; 

problem resize triggered on next digest. when toggle menu first time nothing happens, on second resize called previous (first call) dimensions , on.

i realize it's because browser resize not trigger digest, functions show menu use $rootscope, digest call should occur.

is there way watch element dimensions in case?

upd: if remove watch filter , listen every event, resize function when trigger menu (obviously it's rootscope caused call) parent element height still old. maybe there way defer watcher? ideally not timeout event.


Comments