author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
18 | 1 |
/*! |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2 |
* jQuery UI Effects Bounce 1.13.3 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3 |
* https://jqueryui.com |
18 | 4 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5 |
* Copyright OpenJS Foundation and other contributors |
18 | 6 |
* Released under the MIT license. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
7 |
* https://jquery.org/license |
18 | 8 |
*/ |
9 |
||
10 |
//>>label: Bounce Effect |
|
11 |
//>>group: Effects |
|
12 |
//>>description: Bounces an element horizontally or vertically n times. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
13 |
//>>docs: https://api.jqueryui.com/bounce-effect/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
14 |
//>>demos: https://jqueryui.com/effect/ |
18 | 15 |
|
16 |
( function( factory ) { |
|
19 | 17 |
"use strict"; |
18 |
||
18 | 19 |
if ( typeof define === "function" && define.amd ) { |
20 |
||
21 |
// AMD. Register as an anonymous module. |
|
22 |
define( [ |
|
23 |
"jquery", |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
24 |
"../version", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
25 |
"../effect" |
18 | 26 |
], factory ); |
27 |
} else { |
|
28 |
||
29 |
// Browser globals |
|
30 |
factory( jQuery ); |
|
31 |
} |
|
19 | 32 |
} )( function( $ ) { |
33 |
"use strict"; |
|
18 | 34 |
|
35 |
return $.effects.define( "bounce", function( options, done ) { |
|
36 |
var upAnim, downAnim, refValue, |
|
37 |
element = $( this ), |
|
38 |
||
39 |
// Defaults: |
|
40 |
mode = options.mode, |
|
41 |
hide = mode === "hide", |
|
42 |
show = mode === "show", |
|
43 |
direction = options.direction || "up", |
|
44 |
distance = options.distance, |
|
45 |
times = options.times || 5, |
|
46 |
||
47 |
// Number of internal animations |
|
48 |
anims = times * 2 + ( show || hide ? 1 : 0 ), |
|
49 |
speed = options.duration / anims, |
|
50 |
easing = options.easing, |
|
51 |
||
52 |
// Utility: |
|
53 |
ref = ( direction === "up" || direction === "down" ) ? "top" : "left", |
|
54 |
motion = ( direction === "up" || direction === "left" ), |
|
55 |
i = 0, |
|
56 |
||
57 |
queuelen = element.queue().length; |
|
58 |
||
59 |
$.effects.createPlaceholder( element ); |
|
60 |
||
61 |
refValue = element.css( ref ); |
|
62 |
||
63 |
// Default distance for the BIGGEST bounce is the outer Distance / 3 |
|
64 |
if ( !distance ) { |
|
65 |
distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3; |
|
66 |
} |
|
67 |
||
68 |
if ( show ) { |
|
69 |
downAnim = { opacity: 1 }; |
|
70 |
downAnim[ ref ] = refValue; |
|
71 |
||
72 |
// If we are showing, force opacity 0 and set the initial position |
|
73 |
// then do the "first" animation |
|
74 |
element |
|
75 |
.css( "opacity", 0 ) |
|
76 |
.css( ref, motion ? -distance * 2 : distance * 2 ) |
|
77 |
.animate( downAnim, speed, easing ); |
|
78 |
} |
|
79 |
||
80 |
// Start at the smallest distance if we are hiding |
|
81 |
if ( hide ) { |
|
82 |
distance = distance / Math.pow( 2, times - 1 ); |
|
83 |
} |
|
84 |
||
85 |
downAnim = {}; |
|
86 |
downAnim[ ref ] = refValue; |
|
87 |
||
88 |
// Bounces up/down/left/right then back to 0 -- times * 2 animations happen here |
|
89 |
for ( ; i < times; i++ ) { |
|
90 |
upAnim = {}; |
|
91 |
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; |
|
92 |
||
93 |
element |
|
94 |
.animate( upAnim, speed, easing ) |
|
95 |
.animate( downAnim, speed, easing ); |
|
96 |
||
97 |
distance = hide ? distance * 2 : distance / 2; |
|
98 |
} |
|
99 |
||
100 |
// Last Bounce when Hiding |
|
101 |
if ( hide ) { |
|
102 |
upAnim = { opacity: 0 }; |
|
103 |
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; |
|
104 |
||
105 |
element.animate( upAnim, speed, easing ); |
|
106 |
} |
|
107 |
||
108 |
element.queue( done ); |
|
109 |
||
110 |
$.effects.unshift( element, queuelen, anims + 1 ); |
|
111 |
} ); |
|
112 |
||
19 | 113 |
} ); |