-
Notifications
You must be signed in to change notification settings - Fork 3.4k
clientWidth on hidden tabs returns 0 #578
Comments
Not sure if this is the place to put all my findings however I figured I will put it here. Please let me know if there is a better way than this. I worked this out some more. I found a good article about getting width of a hidden element taking into account a parent might have set it to hidden. The code was a little dated and didn't fit angularjs so I modified it a little and came up with the following: function getVisibleObj(elem) {
} function Swap(elem, els, styles, callback) {
} function getElementDimensions(el) {
} With the new method that finds dimension of a hidden element calculating the tabswidth can be done as follows: An interesting side issue is that the ink will not correctly show up for the same reason (hidden element). Using the new method that gets the element dimension you can resolve that issue as well. Instead of: You end up doing the following: |
Closed with Tabs rearchitecture and improvements [in #master] targeted for 0.9. |
npm -> yarn more updates from Angular Material -> Angular Components add details on material2-docs-content repo correct development setup steps Fixes angular#578. Closes angular#583.
Part of the mdTabs directive is to check if pagination is needed. This is done by checking if the width of the header tab is wide enough to take on the minimum size a tab header can be. If the tab header is hidden the update pagination (element.parent().prop("clientWidth") return 0. This means the tab assumes pagination and it does not render the tabs correctly (adds pagination and does not fill in the tabs).
Timing is important since when the page first renders it all might look correct but if you hide the tabs then set "selected" on the mdTabs element it will call updatePagination and find get this error.
Workaround I made (which is ugly) in method updatePagination. This allows clientWidth to be correctly read regardless of the visibility of the element.
The text was updated successfully, but these errors were encountered: