darcyclarke / Repo.js

:page_facing_up: A plugin to embed Github repos on your site
MIT License
911 stars 83 forks source link

Bottom of the Repo cut off when opening first file in Chrome with clear cache #28

Open boozelclark opened 11 years ago

boozelclark commented 11 years ago

If I have an empty html document with nothing but a div to hold the repo when I first open a file it seems like the div calculates it height before all the GitHub like formatting has been applied so the bottom of the file is cut-off. After the first one has loaded all the rest of the files in the repo work fine because their formatting is applied before they are shown. I suspect it has something to do with the fonts not being downloaded the first time.

malcomio commented 9 years ago

If the element that you call the repo function on has the class of repo then the height will not be calculated correctly.

SMJSGaming commented 5 years ago

I personally tested this because I got the same problem, an easy fix is to force height auto when you open a file (not in the tree)

here's a simple jquery I made to fix this, be aware, this checks if there's any pre tags which exists, so if you got more than one pre in the file make it not just check for 1 but for the ammount you got on default +1

var fixedfirst = false;
setInterval(function check() {
    if (!fixedfirst) {
        if ($("pre").length) {
            $(".repo").height('auto');
            fixedfirst = true;
        }
    }
}, 200);