mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
effects.*: More Style Guidance
This commit is contained in:
parent
61cf834081
commit
bcb8f7ed9a
4
ui/jquery.effects.blind.js
vendored
4
ui/jquery.effects.blind.js
vendored
@ -16,11 +16,11 @@ $.effects.blind = function(o) {
|
|||||||
|
|
||||||
return this.queue(function() {
|
return this.queue(function() {
|
||||||
// Create element
|
// Create element
|
||||||
var el = $(this),
|
var el = $( this ),
|
||||||
props = ['position','top','bottom','left','right'],
|
props = ['position','top','bottom','left','right'],
|
||||||
mode = $.effects.setMode( el, o.mode || 'hide' ),
|
mode = $.effects.setMode( el, o.mode || 'hide' ),
|
||||||
direction = o.direction || 'vertical',
|
direction = o.direction || 'vertical',
|
||||||
ref = (direction == 'vertical') ? 'height' : 'width',
|
ref = ( direction == 'vertical' ) ? 'height' : 'width',
|
||||||
animation = {},
|
animation = {},
|
||||||
wrapper, distance;
|
wrapper, distance;
|
||||||
|
|
||||||
|
99
ui/jquery.effects.explode.js
vendored
99
ui/jquery.effects.explode.js
vendored
@ -12,64 +12,63 @@
|
|||||||
*/
|
*/
|
||||||
(function( $, undefined ) {
|
(function( $, undefined ) {
|
||||||
|
|
||||||
$.effects.explode = function(o) {
|
$.effects.explode = function( o ) {
|
||||||
|
|
||||||
return this.queue(function() {
|
return this.queue( function() {
|
||||||
|
|
||||||
var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3;
|
var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3,
|
||||||
var cells = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3;
|
cells = rows,
|
||||||
|
el = $( this ).show().css( 'visibility', 'hidden' ),
|
||||||
|
mode = $.effects.setMode( el, o.mode || 'hide' ),
|
||||||
|
offset = el.offset(),
|
||||||
|
width = el.outerWidth( true ),
|
||||||
|
height = el.outerHeight( true );
|
||||||
|
|
||||||
o.mode = o.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.mode;
|
//Substract the margins - not fixing the problem yet.
|
||||||
var el = $(this).show().css('visibility', 'hidden');
|
offset.top -= parseInt( el.css( "marginTop" ), 10 ) || 0;
|
||||||
var offset = el.offset();
|
offset.left -= parseInt( el.css( "marginLeft" ), 10 ) || 0;
|
||||||
|
|
||||||
//Substract the margins - not fixing the problem yet.
|
for( var i = 0; i < rows ; i++ ) { // =
|
||||||
offset.top -= parseInt(el.css("marginTop"),10) || 0;
|
for( var j = 0; j < cells ; j++ ) { // ||
|
||||||
offset.left -= parseInt(el.css("marginLeft"),10) || 0;
|
el
|
||||||
|
.clone()
|
||||||
var width = el.outerWidth(true);
|
.appendTo('body')
|
||||||
var height = el.outerHeight(true);
|
.wrap('<div></div>')
|
||||||
|
.css({
|
||||||
for(var i=0;i<rows;i++) { // =
|
position: 'absolute',
|
||||||
for(var j=0;j<cells;j++) { // ||
|
visibility: 'visible',
|
||||||
el
|
left: -j*(width/cells),
|
||||||
.clone()
|
top: -i*(height/rows)
|
||||||
.appendTo('body')
|
})
|
||||||
.wrap('<div></div>')
|
.parent()
|
||||||
.css({
|
.addClass('ui-effects-explode')
|
||||||
position: 'absolute',
|
.css({
|
||||||
visibility: 'visible',
|
position: 'absolute',
|
||||||
left: -j*(width/cells),
|
overflow: 'hidden',
|
||||||
top: -i*(height/rows)
|
width: width/cells,
|
||||||
})
|
height: height/rows,
|
||||||
.parent()
|
left: offset.left + j*(width/cells) + (o.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
|
||||||
.addClass('ui-effects-explode')
|
top: offset.top + i*(height/rows) + (o.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
|
||||||
.css({
|
opacity: mode == 'show' ? 0 : 1
|
||||||
position: 'absolute',
|
}).animate({
|
||||||
overflow: 'hidden',
|
left: offset.left + j*(width/cells) + (o.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
|
||||||
width: width/cells,
|
top: offset.top + i*(height/rows) + (o.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
|
||||||
height: height/rows,
|
opacity: mode == 'show' ? 1 : 0
|
||||||
left: offset.left + j*(width/cells) + (o.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
|
}, o.duration || 500);
|
||||||
top: offset.top + i*(height/rows) + (o.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
|
}
|
||||||
opacity: o.mode == 'show' ? 0 : 1
|
|
||||||
}).animate({
|
|
||||||
left: offset.left + j*(width/cells) + (o.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
|
|
||||||
top: offset.top + i*(height/rows) + (o.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
|
|
||||||
opacity: o.mode == 'show' ? 1 : 0
|
|
||||||
}, o.duration || 500);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Set a timeout, to call the callback approx. when the other animations have finished
|
// Set a timeout, to call the callback approx. when the other animations have finished
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
|
||||||
o.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
|
el.css({ visibility: 'visible' });
|
||||||
if(o.complete) o.complete.apply(el[0]); // Callback
|
mode != 'show' && el.hide();
|
||||||
el.dequeue();
|
$.isFunction( o.complete ) && o.complete.apply( el[ 0 ] );
|
||||||
|
el.dequeue();
|
||||||
|
|
||||||
$('div.ui-effects-explode').remove();
|
// Note: This is removing all exploding peices from the dom, rather than the ones for this animation only... Ticket# 6022
|
||||||
|
$('div.ui-effects-explode').remove();
|
||||||
}, o.duration || 500);
|
}, o.duration || 500);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
18
ui/jquery.effects.fade.js
vendored
18
ui/jquery.effects.fade.js
vendored
@ -12,18 +12,20 @@
|
|||||||
*/
|
*/
|
||||||
(function( $, undefined ) {
|
(function( $, undefined ) {
|
||||||
|
|
||||||
$.effects.fade = function(o) {
|
$.effects.fade = function( o ) {
|
||||||
return this.queue(function() {
|
return this.queue( function() {
|
||||||
var elem = $(this),
|
var el = $( this ),
|
||||||
mode = $.effects.setMode(elem, o.options.mode || 'hide');
|
mode = $.effects.setMode( el, o.mode || 'hide' );
|
||||||
|
|
||||||
elem.animate({ opacity: mode }, {
|
el.animate({
|
||||||
|
opacity: mode
|
||||||
|
}, {
|
||||||
queue: false,
|
queue: false,
|
||||||
duration: o.duration,
|
duration: o.duration,
|
||||||
easing: o.options.easing,
|
easing: o.easing,
|
||||||
complete: function() {
|
complete: function() {
|
||||||
(o.callback && o.callback.apply(this, arguments));
|
jQuery.isFunction( o.complete ) && o.complete.apply( this, arguments );
|
||||||
elem.dequeue();
|
el.dequeue();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user