Skip to content

Fx.Scroll toElementEdge doesn't account current scroll #1205

@megawac

Description

@megawac

The Fx.Scroll toElementEdge doesnt consider the parent elements scroll position when determining if scrolling is necessary. This causes the effect not to run when it should be valid.

I updated the function in my project with the following quick fix which seems to do the trick:

toElementEdge: function(el, axes, offset){
        axes = axes ? Array.from(axes) : ['x', 'y'];
        el = document.id(el);
        var to = {},
            coords = el.getCoordinates(this.element),
            scroll = this.element.getScroll(),
            containerSize = this.element.getSize(),
            edge = {
                x: coords.right + scroll.x,
                y: coords.bottom + scroll.y
            };

        ['x', 'y'].each(function(axis){
            if (axes.contains(axis)){
                if (edge[axis] > scroll[axis] + containerSize[axis])
                    to[axis] = edge[axis] - containerSize[axis];
                // if (edge[axis] < scroll[axis])
                //  to[axis] = edge[axis];
            }
            if (to[axis] == null) to[axis] = scroll[axis];
            if (offset && offset[axis]) to[axis] = to[axis] + offset[axis];
        }, this);

        if (to.x != scroll.x || to.y != scroll.y)
            this.start(to.x, to.y);
        return this;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions