Mootools update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// MooTools: the javascript framework.
|
||||
// Load this file's selection again by visiting: http://mootools.net/more/13115b95c0560a5c35a61ccf237f3ed9
|
||||
// Or build this file again with packager using: packager build More/Element.Forms More/Element.Shortcuts More/Fx.Slide More/Sortables More/Request.JSONP More/Request.Periodical More/Spinner
|
||||
// Load this file's selection again by visiting: http://mootools.net/more/2bb87efbb3e2cfe85537fcfe52571fb4
|
||||
// Or build this file again with packager using: packager build More/Element.Forms More/Element.Shortcuts More/Fx.Scroll More/Fx.Slide More/Sortables More/Request.JSONP More/Request.Periodical More/Spinner
|
||||
/*
|
||||
---
|
||||
|
||||
@@ -406,6 +406,179 @@ Document.implement({
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
---
|
||||
|
||||
script: Fx.Scroll.js
|
||||
|
||||
name: Fx.Scroll
|
||||
|
||||
description: Effect to smoothly scroll any element, including the window.
|
||||
|
||||
license: MIT-style license
|
||||
|
||||
authors:
|
||||
- Valerio Proietti
|
||||
|
||||
requires:
|
||||
- Core/Fx
|
||||
- Core/Element.Event
|
||||
- Core/Element.Dimensions
|
||||
- /MooTools.More
|
||||
|
||||
provides: [Fx.Scroll]
|
||||
|
||||
...
|
||||
*/
|
||||
|
||||
(function(){
|
||||
|
||||
Fx.Scroll = new Class({
|
||||
|
||||
Extends: Fx,
|
||||
|
||||
options: {
|
||||
offset: {x: 0, y: 0},
|
||||
wheelStops: true
|
||||
},
|
||||
|
||||
initialize: function(element, options){
|
||||
this.element = this.subject = document.id(element);
|
||||
this.parent(options);
|
||||
|
||||
if (typeOf(this.element) != 'element') this.element = document.id(this.element.getDocument().body);
|
||||
|
||||
if (this.options.wheelStops){
|
||||
var stopper = this.element,
|
||||
cancel = this.cancel.pass(false, this);
|
||||
this.addEvent('start', function(){
|
||||
stopper.addEvent('mousewheel', cancel);
|
||||
}, true);
|
||||
this.addEvent('complete', function(){
|
||||
stopper.removeEvent('mousewheel', cancel);
|
||||
}, true);
|
||||
}
|
||||
},
|
||||
|
||||
set: function(){
|
||||
var now = Array.flatten(arguments);
|
||||
if (Browser.firefox) now = [Math.round(now[0]), Math.round(now[1])]; // not needed anymore in newer firefox versions
|
||||
this.element.scrollTo(now[0], now[1]);
|
||||
return this;
|
||||
},
|
||||
|
||||
compute: function(from, to, delta){
|
||||
return [0, 1].map(function(i){
|
||||
return Fx.compute(from[i], to[i], delta);
|
||||
});
|
||||
},
|
||||
|
||||
start: function(x, y){
|
||||
if (!this.check(x, y)) return this;
|
||||
var scroll = this.element.getScroll();
|
||||
return this.parent([scroll.x, scroll.y], [x, y]);
|
||||
},
|
||||
|
||||
calculateScroll: function(x, y){
|
||||
var element = this.element,
|
||||
scrollSize = element.getScrollSize(),
|
||||
scroll = element.getScroll(),
|
||||
size = element.getSize(),
|
||||
offset = this.options.offset,
|
||||
values = {x: x, y: y};
|
||||
|
||||
for (var z in values){
|
||||
if (!values[z] && values[z] !== 0) values[z] = scroll[z];
|
||||
if (typeOf(values[z]) != 'number') values[z] = scrollSize[z] - size[z];
|
||||
values[z] += offset[z];
|
||||
}
|
||||
|
||||
return [values.x, values.y];
|
||||
},
|
||||
|
||||
toTop: function(){
|
||||
return this.start.apply(this, this.calculateScroll(false, 0));
|
||||
},
|
||||
|
||||
toLeft: function(){
|
||||
return this.start.apply(this, this.calculateScroll(0, false));
|
||||
},
|
||||
|
||||
toRight: function(){
|
||||
return this.start.apply(this, this.calculateScroll('right', false));
|
||||
},
|
||||
|
||||
toBottom: function(){
|
||||
return this.start.apply(this, this.calculateScroll(false, 'bottom'));
|
||||
},
|
||||
|
||||
toElement: function(el, axes){
|
||||
axes = axes ? Array.from(axes) : ['x', 'y'];
|
||||
var scroll = isBody(this.element) ? {x: 0, y: 0} : this.element.getScroll();
|
||||
var position = Object.map(document.id(el).getPosition(this.element), function(value, axis){
|
||||
return axes.contains(axis) ? value + scroll[axis] : false;
|
||||
});
|
||||
return this.start.apply(this, this.calculateScroll(position.x, position.y));
|
||||
},
|
||||
|
||||
toElementEdge: function(el, axes, offset){
|
||||
axes = axes ? Array.from(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;
|
||||
},
|
||||
|
||||
toElementCenter: function(el, axes, offset){
|
||||
axes = axes ? Array.from(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();
|
||||
|
||||
['x', 'y'].each(function(axis){
|
||||
if (axes.contains(axis)){
|
||||
to[axis] = position[axis] - (containerSize[axis] - size[axis]) / 2;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
function isBody(element){
|
||||
return (/^(?:body|html)$/i).test(element.tagName);
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
|
||||
/*
|
||||
---
|
||||
|
||||
@@ -1164,7 +1337,7 @@ var Sortables = new Class({
|
||||
|
||||
this.idle = false;
|
||||
this.element = element;
|
||||
this.opacity = element.get('opacity');
|
||||
this.opacity = element.getStyle('opacity');
|
||||
this.list = element.getParent();
|
||||
this.clone = this.getClone(event, element);
|
||||
|
||||
@@ -1175,7 +1348,7 @@ var Sortables = new Class({
|
||||
onSnap: function(){
|
||||
event.stop();
|
||||
this.clone.setStyle('visibility', 'visible');
|
||||
this.element.set('opacity', this.options.opacity || 0);
|
||||
this.element.setStyle('opacity', this.options.opacity || 0);
|
||||
this.fireEvent('start', [this.element, this.clone]);
|
||||
}.bind(this),
|
||||
onEnter: this.insert.bind(this),
|
||||
@@ -1189,7 +1362,7 @@ var Sortables = new Class({
|
||||
|
||||
end: function(){
|
||||
this.drag.detach();
|
||||
this.element.set('opacity', this.opacity);
|
||||
this.element.setStyle('opacity', this.opacity);
|
||||
if (this.effect){
|
||||
var dim = this.element.getStyles('width', 'height'),
|
||||
clone = this.clone,
|
||||
|
||||
Reference in New Issue
Block a user