Came across intro.js - a very cool way to guide users on how to use software interfaces. I havnt looked at the source in depth but was wondering if anyone could briefly explain what the code does to achieve the highlighted areas (specifically dimensions/position/zindexing) to achieve the effect.
Thanks in advance Jay
Link: http://usablica.github.com/intro.js/
I'm Afshin, the author of Intro.js. Let me introduce you how it works actually.
In a focused/highlighted element, two separate things happend:
1) Make a helper layer. Helper layer is the white rounded corner layer in focused element.
2) Change z-index
and position
of the target element in order to bring the element to front of all other elements in the page.
If the position of target element (the element that should be focused/highlighted) is:
Absolute/Relative:
IntroJs just set the target element z-index
to 9999999
, so the target element goes to front of all other elements in the page.
Static:
Now, IntroJs set the target element position to relative
and then set the z-index
to 9999999
.
Now, the target element is in the front of all other elements in the page. So, one last step remains, create the helper element.
For creating the helper layer, IntroJs just get the height, width, top and left of the target element and then create a div
with class introJs-helperLayer
(and position absolute
) and append it to the body
.
Conclusion
In order to focus on an element, IntroJs does two steps, first creating a helper layer (rounded corner layer in the page) and then make the target element content relative
in order to bring it to front of the all elements in the page.
Well - pretty simple.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With