Skip to content

Document the offset of Fx.Scroll.toElementEdge() #1354

Description

@Aybee

Function:

toElementEdge: function(el, axes, offset){
axes = axes ? Array.convert(axes) : ['x', 'y'];
el = document.id(el);
var to = {},
position = el.getPosition(this.element),
size = el.getSize(),
scroll = this.element.getScroll(),
containerSize = this.element.getSize(),
edge = {
x: position.x + size.x,
y: position.y + size.y
};
['x', 'y'].each(function(axis){
if (axes.contains(axis)){
if (edge[axis] > scroll[axis] + containerSize[axis]) to[axis] = edge[axis] - containerSize[axis];
if (position[axis] < scroll[axis]) to[axis] = position[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;
},

Docu:
https://github.com/mootools/mootools-more/blob/master/Docs/Fx/Fx.Scroll.md
offset is missing.

Syntax

myFx.toElementEdge(el[, axes[, offset]]);

Arguments

  1. el - (mixed) A string of the Element's id or an Element reference to scroll to.
  2. axes - (array or string, optional) An array or string specifying which axes to scroll on, can be 'x', 'y', or ['x', 'y']. It defaults to both axes.
  3. offset - (object, optional) An object specifying which axes should get an offset. Examples: {x: 0; y: 100}, {y: 100}.

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