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

Ticket #7105: Improving internal effects api #146

Closed
wants to merge 12 commits into from
Next Next commit
effects: $.effects.$ and $.effects.effect[]
  • Loading branch information
gnarf committed Mar 8, 2011
commit 6963889f73beda7aca6018de58728d28d0656db0
22 changes: 9 additions & 13 deletions ui/jquery.effects.blind.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,31 @@
*/
(function( $, undefined ) {

$.effects.blind = function( o ) {
$.effects.effect.blind = function( o ) {

return this.queue( function() {

// Create element
var el = $( this ),
var el = $.effects.$( this ),
props = [ 'position', 'top', 'bottom', 'left', 'right' ],
mode = $.effects.setMode( el, o.mode || 'hide' ),
direction = o.direction || 'vertical',
ref = ( direction == 'vertical' ) ? 'height' : 'width',
animation = {},
wrapper, distance;

$.effects.save( el, props );
el.show();
wrapper = $.effects.createWrapper( el ).css({
overflow: 'hidden'
});
wrapper = el.save( props ).show().createWrapper({
overflow: 'hidden'
}),
distance;

animation[ ref ] = ( mode == 'show' ? wrapper[ ref ]() : 0 );

// start at 0 if we are showing
// reset to 0 if we are showing
( mode == 'show' && wrapper.css( ref, 0 ) );

// Animate
wrapper.animate( animation, o.duration, o.easing, function() {
( mode == 'hide' && el.hide() );
$.effects.restore( el, props );
$.effects.removeWrapper( el );
( mode == 'hide' && el.hide() );
el.restore( props ).removeWrapper();
$.isFunction( o.complete ) && o.complete.apply( el[ 0 ], arguments );
el.dequeue();
});
Expand Down
20 changes: 9 additions & 11 deletions ui/jquery.effects.bounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

var rshowhide = /show|hide/;

$.effects.bounce = function(o) {
$.effects.effect.bounce = function(o) {

return this.queue(function() {

// Create element
var el = $( this ),
var el = $.effects.$( this ),
props = [ 'position', 'top', 'bottom', 'left', 'right' ],
// defaults:
mode = $.effects.setMode( el, o.mode || 'effect' ),
mode = el.setMode( o.mode || 'effect' ),
direction = o.direction || 'up',
distance = o.distance || 20,
times = o.times || 5,
Expand All @@ -37,9 +37,7 @@ $.effects.bounce = function(o) {
props.push( 'opacity' );
}

$.effects.save( el, props );
el.show();
$.effects.createWrapper( el ); // Create Wrapper
el.save( props ).show().createWrapper();

if ( !distance ) {
distance = el[ ref == 'top' ? 'outerHeight' : 'outerWidth' ]({ margin:true }) / 3;
Expand Down Expand Up @@ -76,9 +74,9 @@ $.effects.bounce = function(o) {
};
animation[ ref ] = ( motion ? '-=' : '+=' ) + distance;
el.animate( animation, speed / 2, o.easing, function(){
el.hide();
$.effects.restore( el, props );
$.effects.removeWrapper( el );
el.hide()
.restore( props )
.removeWrapper();
$.isFunction( o.complete ) && o.complete.apply( this, arguments );
});
} else {
Expand All @@ -89,11 +87,11 @@ $.effects.bounce = function(o) {
el
.animate( animation1, speed / 2, o.easing )
.animate( animation2, speed / 2, o.easing, function() {
$.effects.restore( el, props );
$.effects.removeWrapper( el );
el.restore( props ).removeWrapper();
$.isFunction( o.complete ) && o.complete.apply( this, arguments );
});
}

el.dequeue();
});

Expand Down
25 changes: 9 additions & 16 deletions ui/jquery.effects.clip.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,25 @@
*/
(function( $, undefined ) {

$.effects.clip = function( o ) {
$.effects.effect.clip = function( o ) {

return this.queue( function() {

// Create element
var el = $( this ),
var el = $.effects.$( this ),
props = ['position','top','bottom','left','right','height','width'],
mode = $.effects.setMode( el, o.mode || 'hide' ),
mode = el.setMode( o.mode || 'hide' ),
direction = o.direction || 'vertical',
ref = {
size: (direction == 'vertical') ? 'height' : 'width',
position: (direction == 'vertical') ? 'top' : 'left'
},
animation = {},
wrapper, animate, distance;

// Save & Show
$.effects.save( el, props ); el.show();

// Create Wrapper
wrapper = $.effects.createWrapper( el ).css({
overflow: 'hidden'
});
animate = ( el[0].tagName == 'IMG' ) ? wrapper : el;
distance = animate[ ref.size ]();
wrapper = el.save( props ).show().createWrapper({
overflow: 'hidden'
}),
animate = ( el[0].tagName == 'IMG' ) ? wrapper : el,
distance = animate[ ref.size ]();

// Shift
if ( mode == 'show' ) {
Expand All @@ -55,8 +49,7 @@ $.effects.clip = function( o ) {
easing: o.easing,
complete: function() {
mode == 'hide' && el.hide();
$.effects.restore( el, props );
$.effects.removeWrapper( el );
el.restore( props ).removeWrapper();
$.isFunction( o.complete ) && o.complete.apply( el[ 0 ], arguments );
el.dequeue();
}
Expand Down
Loading