2 * jQuery UI Effects Bounce 1.8.21
4 * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
5 * Dual licensed under the MIT or GPL Version 2 licenses.
6 * http://jquery.org/license
8 * http://docs.jquery.com/UI/Effects/Bounce
11 * jquery.effects.core.js
13 (function( $, undefined ) {
15 $.effects.custombounce = function(o) {
17 return this.queue(function() {
20 var el = $(this), props = ['position','top','bottom','left','right'];
22 var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
23 var direction = o.options.direction || 'up'; // Default direction
24 var gravity = (o.options.gravity == "undefined") ? true : o.options.gravity ; // Default direction
25 var distance = o.options.distance || 20; // Default distance
26 var times = o.options.times || 5; // Default # of times
27 var speed = o.duration || 250; // Default speed per bounce
28 if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE
31 $.effects.save(el, props); el.show(); // Save & Show
32 $.effects.createWrapper(el); // Create Wrapper
33 var ref ,ref2, motion;
35 if(direction == 'up' || direction == 'down') {
37 } else if(direction == 'up right' || direction == 'down right' || direction == 'up left' || direction == 'down left') {
44 var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
46 if (direction == "up" || direction == "left") {
51 var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3);
52 if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
53 if (mode == 'hide') distance = distance / (times * 2);
54 if (mode != 'hide') times--;
57 if (mode == 'show') { // Show Bounce
58 var animation = {opacity: 1};
59 animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
60 el.animate(animation, speed / 2, o.options.easing);
61 distance = distance / 2;
64 for (var i = 0; i < times; i++) { // Bounces
65 var animation1 = {}, animation2 = {};
67 animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
68 animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
69 if(ref2 != "undefined") {
71 if(direction == "up right" || direction == "down left") {
72 animation1[ref2] = (motion == 'pos' ? '-=' : '+=') + distance;
73 animation2[ref2] = (motion == 'pos' ? '+=' : '-=') + distance;
75 animation1[ref2] = (motion == 'pos' ? '+=' : '-=') + distance;
76 animation2[ref2] = (motion == 'pos' ? '-=' : '+=') + distance;
79 if(direction == "down right" || direction == "up left") {
80 animation1[ref2] = (motion == 'pos' ? '-=' : '+=') + distance;
81 animation2[ref2] = (motion == 'pos' ? '+=' : '-=') + distance;
83 animation1[ref2] = (motion == 'pos' ? '+=' : '-=') + distance;
84 animation2[ref2] = (motion == 'pos' ? '-=' : '+=') + distance;
89 el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing);
91 distance = (mode == 'hide') ? distance * 2 : distance / 2;
94 // console.log(distance)
96 if (mode == 'hide') { // Last Bounce
97 var animation = {opacity: 0};
98 animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
99 el.animate(animation, speed / 2, o.options.easing, function(){
101 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
102 if(o.callback) o.callback.apply(this, arguments); // Callback
105 var animation1 = {}, animation2 = {};
106 animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
107 animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
108 if(ref2 != "undefined") {
109 animation1[ref2] = (motion == 'pos' ? '+=' : '-=') + distance;
110 animation2[ref2] = (motion == 'pos' ? '-=' : '+=') + distance;
112 el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){
113 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
114 if(o.callback) o.callback.apply(this, arguments); // Callback
117 el.queue('fx', function() { el.dequeue(); });