You can use jQuery for this. Suppose your ancestral element, which is a fixed-position container, has an ancestor class for simplicity. Lets also say that your descendants (Joyride tips) have a descendant class. Both of these assumptions should be something that you can easily add to your HTML, or, alternatively, use an existing class as another jQuery selector. Then you can do something similar to make your discovery.
if ($(".descendant").closest(".ancestor").css("position") == "fixed") {
Update
Since you have given a little more from what you want, I think this question is something like "How to check if an ancestor has a fixed position and if there is a closest ancestor that scrolls?". Adding to this, there is a requirement that none of the ancestors have classes or identifiers. I'm going to assume that your Joyride stops, everyone has a "joyride-stop" class solely for this example. Therefore, to determine whether to apply a fixed position to your Joyride stop or not, you just need to do the following (using jQuery, since zurb joyride has this as a dependency):
var jStops = $(".joyride-stop"); for (var i=0; i<jStops.length; i++) { var pEls = jStops[i].parents(); for (var j=0; j<pEls.length; j++) { if(pEls[j].css("position") == "fixed") { // closest ancestor is fixed. // insert code to fix your Joyride element here break; } else if (pEls[j].css("overflow") == "scroll") { // closest ancestor scrolls so just break and move on break; } } }
Note that I only checked the overflow css property here. If you want a fantasy, you can check overflow-x, overflow-y, and potentially any other attribute that might affect the scroll (for example, some other custom JavaScript widget). The check depends on what you need to worry about on your page,
Is that what you were after?
source share