Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Aybee opened this issue Nov 7, 2017 · 0 comments
Open

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

Aybee opened this issue Nov 7, 2017 · 0 comments

Comments

@Aybee
Copy link

Aybee commented Nov 7, 2017

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}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@Aybee and others