question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: problems when creating a map inside display:none element

See original GitHub issue

This has been reported several times by users: #72 and #63

Here is a working example of the problem: http://jsfiddle.net/VqwUZ/361/ We hide the container, draw the map, then show the container. As a result, no text is visible on the legend, and the map is not set to the screen width (a resize of the window is needed to force redraw).

This is related to Raphael issue DmitryBaranovskiy/raphael#760

If you call getBBox() to get the bounding box of a text element when the whole Raphael element is hidden (e.g. if it is inside a <div> with display: none) then the properties of the returned object are all set to NaN rather than the actual bounding box values of the element.

My solution was to avoid using display:none and prefer using this kind of class:

.map_hide {
    /* display:none is doing some weird stuff on SVG
     * Solution: hide it, then position it far away
     */
    position:absolute !important;
    visibility: hidden !important;
    top:-1000px !important;
    left:-1000px !important; 
}

However, when using a CSS framework such as Bootstrap, you may not be able to change the behavior of certain element. I don’t know what we can do.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Indigo744commented, Mar 4, 2018

Hello

Instead of using display: none as usual to hide a tab, you should use the tab_hidden class below. Essentially, it moves the element far away so it is not seen by the user.

You just need to toggle the tab_hidden class to the tab element.

/* Default tab style, may not be needed */
.tab {
    position: static;
    visibility: visible;
    top: 0;
    left: 0; 
}
/* Hidden tab style, to be toggled to show/hide tab */
.tab_hidden {
    /* because display:none not compatible with Mapael */
    position:absolute !important;
    visibility: hidden !important;
    top:-1000px !important;
    left:-1000px !important; 
}
0reactions
inqdev03commented, Mar 21, 2022

Well, I post this here if anyone will face this issue : Under Bootstrap :

$('a[href="#idTab"]').on('shown.bs.tab', function (e) {
$(".worldMap").mapael(...)};
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Rendering bug while toggling "display: none" and "display
This works but a weird display bug occurs where initially the buttons are much larger than they should be, and quickly return to...
Read more >
display NONE not working - possible conflict on stylesheet?
i know from past experience that glitches with my html on the aspx page will break the stylesheets, but again, nothing detected and...
Read more >
CSS 'display: none' causes problems for screenreaders
The issue is that using CSS 'display:none', will actually hide the content contained in the <div> that the declaration is attached to from...
Read more >
contents" to "display: none" fails to hide the element
Created attachment 346382 [details] screenshot of bug I have an element that's default setting is "display: none;".
Read more >
SVG resource don't work in display: none subtrees - Monorail
<patter style="display: none"> <!-- pattern won't work --> Spec says: "The 'display' property does not apply to the 'pattern' element; thus, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found