PluginProbe
RSVP and Event Management / 1.3.0
RSVP and Event Management v1.3.0
trunk 0.5.0 0.6.0 0.7.0 0.8.0 0.9.0 0.9.5 1.0.0 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.5.0 1.6.0 1.6.1 1.6.2 1.6.5 1.7.0 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 All 136 releases
rsvp / jquery-ui-1.7.2.custom / development-bundle / ui / effects.shake.js

effects.shake.js in RSVP and Event Management 1.3.0, at jquery-ui-1.7.2.custom/development-bundle/ui/effects.shake.js

58 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*
2 * jQuery UI Effects Shake 1.7.2
3 *
4 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
5 * Dual licensed under the MIT (MIT-LICENSE.txt)
6 * and GPL (GPL-LICENSE.txt) licenses.
7 *
8 * http://docs.jquery.com/UI/Effects/Shake
9 *
10 * Depends:
11 * effects.core.js
12 */
13 (function($) {
14
15 $.effects.shake = function(o) {
16
17 return this.queue(function() {
18
19 // Create element
20 var el = $(this), props = ['position','top','left'];
21
22 // Set options
23 var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
24 var direction = o.options.direction || 'left'; // Default direction
25 var distance = o.options.distance || 20; // Default distance
26 var times = o.options.times || 3; // Default # of times
27 var speed = o.duration || o.options.duration || 140; // Default speed per shake
28
29 // Adjust
30 $.effects.save(el, props); el.show(); // Save & Show
31 $.effects.createWrapper(el); // Create Wrapper
32 var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
33 var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
34
35 // Animation
36 var animation = {}, animation1 = {}, animation2 = {};
37 animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
38 animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2;
39 animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2;
40
41 // Animate
42 el.animate(animation, speed, o.options.easing);
43 for (var i = 1; i < times; i++) { // Shakes
44 el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing);
45 };
46 el.animate(animation1, speed, o.options.easing).
47 animate(animation, speed / 2, o.options.easing, function(){ // Last shake
48 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
49 if(o.callback) o.callback.apply(this, arguments); // Callback
50 });
51 el.queue('fx', function() { el.dequeue(); });
52 el.dequeue();
53 });
54
55 };
56
57 })(jQuery);
58