Giter Site home page Giter Site logo

Incorrect view on first loading page about sly HOT 4 CLOSED

temsc avatar temsc commented on August 19, 2024
Incorrect view on first loading page

from sly.

Comments (4)

darsain avatar darsain commented on August 19, 2024

You are missing the common sense when working with images. What is happening is that you are calling sly on DOM load when images are not ready, and thus haven't had the chance to resize their containers, so sly is working with elements that are 0x0 px big.

You can confirm that by calling sly('reload') on your frame after the site has been loaded, which fixes the issue immediately.

I suggest you to use plugin like desandro/imagesloaded, and let it to tell you when to call sly, or even better, if the size of the elements is not dynamic, assign it manually in CSS. That will fix the issue, and won't introduce any new dependency or a code requirement.


Not a bug, closing the issue.

from sly.

temsc avatar temsc commented on August 19, 2024

I puted this on document.ready section:

            $("ul.slidee").css("display", "none");
            $(".slidee").imagesLoaded( function( $images, $proper, $broken ) {
                $("ul.slidee").css("display", "block");

                $('#frame').sly(
                {
                    horizontal: 1,
                    itemNav: "forceCentered",
                    prev: ".prev",
                    next: ".next",
                    dragContent: 1,
                    scrollBy: 1,
                    speed: 200,
                    dynamicHandle: 0,
                    scrollBar: ".scrollbar",
                    //easing: "easeOutBack" // with jQuery easing v1.3
                });
            });

Thank you so much! Yours js-libraries are the greatest! :)

P.S.: trick with $("ul.slidee").css("display", "none"); is to hide all images then they loading.

from sly.

darsain avatar darsain commented on August 19, 2024

Your "trick" might cause images not to load at all. Browsers won't load images that are display: none; or within a container with display: none;. If it works, it is only because you are setting the display: none; after the images have started with loading, and that is a highly unreliable assumption.

Also, I mentioned that setting the size of your li elements manually in CSS is a better solution than including ImagesLoaded plugin. But, whatever suits you...

from sly.

temsc avatar temsc commented on August 19, 2024

Width of element "#frame" setting then Sly activated, so I can not to know width of this element before.

Btw, maybe I can to calculate width of #frame by sum of all images widths, by using $images parameter of imagesLoaded( function... ??

from sly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.