Giter Site home page Giter Site logo

Comments (6)

ptitgraig avatar ptitgraig commented on September 21, 2024

Same issue when the width of the scroll wrapper changes without page reload.

from smooth-div-scroll.

ptitgraig avatar ptitgraig commented on September 21, 2024

Hi.
I fixed the issue with a new function called on resize event. It's basically a lighter version of recalculateScrollableArea().

recalculateHotSpotsPos: function() {
    var el = this.element;
    el.data("scrollerOffset", el.offset());
    var tempScrollableAreaWidth = 0, foundStartAtElement = false, o = this.options, el = this.element, self = this;
    // Add up the total width of all the items inside the scrollable area
    el.data("scrollableArea").children(o.countOnlyClass).each(function () {
        // Check to see if the current element in the loop is the one where the scrolling should start
        if ((o.startAtElementId.length > 0) && (($(this).attr("id")) === o.startAtElementId)) {
            el.data("startingPosition", tempScrollableAreaWidth);
            foundStartAtElement = true;
        }
        // PATCH : outerWidth(true) makes a bad calculation with margin:0 auto (IE only)
        var this_width = ($.browser.msie) ? $(this).outerWidth() : $(this).outerWidth(true);        
        tempScrollableAreaWidth = tempScrollableAreaWidth + this_width;
    });
    // Set the width of the scrollable area
    el.data("scrollableAreaWidth", tempScrollableAreaWidth);
    el.data("scrollableArea").width(el.data("scrollableAreaWidth"));
},

This function needs to be called on resize :

/*****************************************
SET UP EVENT FOR RESIZING THE BROWSER WINDOW
*****************************************/
$(window).bind("resize", function () {
    self._showHideHotSpots();
    self.recalculateHotSpotsPos();
    self._trigger("windowResized");
});

from smooth-div-scroll.

ptitgraig avatar ptitgraig commented on September 21, 2024

There might be a more elegant way to do it but this does the job.

from smooth-div-scroll.

dariohead avatar dariohead commented on September 21, 2024

Hi! I have one question.

When having multiple scrollers (using version 1.3) on a single page hotspot scrolling behaves oddly: it scrolls slowly to the right and when you want to scroll to the left it always jumps at the first picture.

I noticed that this patch here remedies that behaviour, i.e. when I resize the window, suddenly hotspots work perfectly.

How could I call this new "recalculateHotSpotsPos" function onclick when loading a particular part of the page/slider?

from smooth-div-scroll.

dariohead avatar dariohead commented on September 21, 2024

Hi.

I found the cause of my specific problem. I am using plugin "Full window width content slider by Karl Oskar Engdahl" which uses Jquery Tools for scrolling content. It somehow messes with the hotspot scrolling.

Since your Resize Window Patch helps my issue, I did a workaround for this conflict issue by firing your patch function not only on window resize but also when hovering the "makeMeScrollable" divs.

I don't know if this is "ok to do" since I am a JS beginner, but it does the job and I need it only for this 1 scrolling minisite...?

Thanks for the patch function!

from smooth-div-scroll.

tkahn avatar tkahn commented on September 21, 2024

A plugin developers nightmare is when you start mixing different jQuery plugins, but I know how easy it is to end up there: "If I could just combine the functionality with plugin A with the functionality of function B I'm done!" :-)

I have added one example where I combine Smooth Div Scroll with Colorbox since I think it's a very common user case. But I would of course be impossible to cover all possible combinations. But if you have have a combination of one plugin that would be a great mix together with Smooth Div Scroll let me know and perhaps I can provide an example.

from smooth-div-scroll.

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.