Created
June 5, 2014 15:53
-
-
Save Plou/f50bfa3e1b1a59fbac06 to your computer and use it in GitHub Desktop.
Snippet to help debuging scroll related scripts
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
| Ruler = function (label, top, color, $container){ | |
| return $('<p class="ruler">'+label+'</p>').css({ | |
| "position": "absolute", | |
| "width": "100%", | |
| "margin": "0", | |
| "padding": "0", | |
| "border-top": "2px solid "+color, | |
| "top": top, | |
| "background": "rgba(255,255,255,.6)" | |
| }).appendTo($container); | |
| } | |
| // DEBUG | |
| $container = timeline.$container; | |
| timeline.$dates.each(function(){ | |
| offsetTop = $(this).offset().top-$($container).offset().top+$($container).scrollTop(); | |
| label = 'data-id = '+$(this).attr("data-id")+', offesetTop= '+offsetTop+'px'; | |
| $ruler = new Ruler(label, offsetTop, "red", $container); | |
| }); | |
| ""; | |
| // /DEBUG | |
| printScroll = function(){ | |
| new Ruler("scrollTop:"+$($container).scrollTop()+"px", $($container).scrollTop(), "blue", $container); | |
| ""; | |
| } | |
| clearRulers = function(){ | |
| $('.ruler').remove(); | |
| ""; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment