Created
December 12, 2016 19:54
-
-
Save developit/fb4676468c3ae22beea15018b3dde49b to your computer and use it in GitHub Desktop.
paste this into any preact app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [].filter.call(document.querySelectorAll('*'), el => { | |
| if (el._component) { | |
| var p = el._priority = el.offsetHeight ? (1 - el.getBoundingClientRect().top/window.innerHeight) : -1; | |
| if (p>0) { | |
| el.setAttribute('data-priority', p); | |
| return true; | |
| } | |
| } | |
| }); | |
| var style = document.createElement('style'); | |
| style.appendChild(document.createTextNode(` | |
| [data-priority] { | |
| position: relative; | |
| } | |
| [data-priority]::before { | |
| content:attr(data-priority); | |
| position:absolute; left:0; top:0; padding:3px; | |
| background:orange; color:white; | |
| font-size: 11px; line-height: 1.2; height:auto; | |
| z-index: 999; | |
| } | |
| `)); | |
| document.head.appendChild(style); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment