Skip to main content

Forums

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: JavaScript error function not defined #245992

    Redfredg
    Participant

    Frankly, hoisting should’ve been removed so “var” works correctly, and there would never be a need for “let” (which is a rubbish word and feels like 80s BASIC programming on the ZX Spectrum). It seems ridiculous to just introduce a new declaration that works properly, yet keeping the old one in. Would’ve been backwards compatible too. I can understand your point of view and it’d be quite cleaner. But it wouldn’t be backwards compatible due to the facts named below but also because even if you should declare variables within the corresponding scope, there’s never a guarantee that they really are. Changing the hoisting behavior would crash millions of websites and that’s not acceptable. But it’d have been possible to just allow coders to define something like “use-strict” for the ECMAScript version they’re using in their scripts. That would be backwards compatible since authors would expect var to act like let when they define ECMAScript 6 in their scripts.

    Thanks !!
    Refred@ redgage


    Redfredg
    Participant

    I have proposed a dynamic programming algorithm for packing images in a grid of completely filled rows of uniform widths. By allowing each row to be of a different hight and finding the optimal placements of line-breaks the desired packing is achieved. By performing a scaling post-process each line is guaranteed to be exactly as wide as the desired width.

    in reply to: make page background fullscreen #244603

    Redfredg
    Participant

    //HTML

    //CSS
    #bg {
    position: fixed;
    top: 0;
    left: 0;

    /* Preserve aspet ratio */
    min-width: 100%;
    min-height: 100%;
    }
    Redgage
    OR

    img.bg {
    /* Set rules to fill background */
    min-height: 100%;
    min-width: 1024px;

    /* Set up proportionate scaling */
    width: 100%;
    height: auto;

    /* Set up positioning */
    position: fixed;
    top: 0;
    left: 0;
    }

    @media screen and (max-width: 1024px) { /* Specific to this particular image /
    img.bg {
    left: 50%;
    margin-left: -512px; /
    50% */
    }
    }

    OR

    //HTML

    //CSS
    #bg { position: fixed; top: 0; left: 0; }
    .bgwidth { width: 100%; }
    .bgheight { height: 100%; }

    //jQuery
    $(window).load(function() {

    ` var theWindow = $(window),
    $bg = $(“#bg”),
    aspectRatio = $bg.width() / $bg.height();

    `function resizeBg() {

        if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
            $bg
                .removeClass()
                .addClass('bgheight');
        } else {
            $bg
                .removeClass()
                .addClass('bgwidth');
        }
    

    }

    theWindow.resize(resizeBg).trigger(“resize”);
    `

    `

    });

Viewing 3 posts - 1 through 3 (of 3 total)
icon-link icon-logo-star icon-search icon-star