Currently, I am utilizing the AngularJS range slider directive created by prajwalkman. The slider functions properly when it is visible; however, an issue arises when it is placed within a hidden options screen using ng-show. This prevents the DOM manipulation from functioning correctly due to the utilization of "offsetWidth". My setup involves these sliders being integrated into a panel that remains hidden upon initial launch, yet I still want the sliders to be initialized so that the pointers are positioned accurately and the colored selection bar is visible once the user toggles the panel.
wholeBar = element.children()[0].offsetWidth;
When the element is concealed, offsetWidth returns 0 causing errors in the calculations. It seems like the solution may involve displaying the panel first, then executing the DOM update code after the current apply/digest cycle concludes. However, I have not yet determined how to schedule this operation accordingly.
To demonstrate the issue, I have created a simplified fiddle - when the DIV is visible, the code works as expected because offsetWidth is not 0. Yet, when it is hidden, the selection bar fails to expand to 50%.