Skip to content

Commit b7985e6

Browse files
bobholtajpiano
authored andcommitted
add core styles to Effects code examples
1 parent 4e5f859 commit b7985e6

File tree

3 files changed

+220
-124
lines changed

3 files changed

+220
-124
lines changed

page/effects/custom-effects.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ jQuery makes it possible to animate arbitrary CSS properties via the
1010
value, or to a value relative to the current value.
1111

1212
```
13-
// Custom effects with $.fn.animate
14-
$('div.funtimes').animate(
15-
{
16-
left : "+=50",
17-
opacity : 0.25
18-
},
19-
300, // duration
20-
function() { console.log('done!'); // calback
21-
});
13+
// Custom effects with `$.fn.animate`">
14+
$("div.funtimes").animate({
15+
16+
left : "+=50",
17+
opacity : 0.25
18+
19+
},
20+
300, // duration
21+
function() {
22+
23+
console.log("done!"); // callback
24+
25+
}
26+
});
2227
```
2328

2429
<div class="note">
@@ -39,14 +44,15 @@ As of jQuery 1.4, it is possible to do per-property easing when using the
3944
`$.fn.animate` method.
4045

4146
```
42-
// Per-property easing
43-
$('div.funtimes').animate(
44-
{
45-
left : [ "+=50", "swing" ],
46-
opacity : [ 0.25, "linear" ]
47-
},
48-
300
49-
);
47+
// Per-property easing">
48+
$("div.funtimes").animate({
49+
50+
left : [ "+=50", "swing" ],
51+
opacity : [ 0.25, "linear" ]
52+
53+
},
54+
300
55+
);
5056
```
5157

5258
For more details on easing options, see

page/effects/queue_and_dequeue_explained.md

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,38 @@ adding a job on to the fx queue.By default, using queue and passing a function,
99
will add to the fx queue. So we’re creating our own bespoke animation step:
1010

1111
```
12-
$('.box').animate({
13-
height : 20
14-
}, 'slow')
15-
.queue(function () {
16-
$('#title').html("We're in the animation, baby!");
12+
$(".box").animate(
13+
{
14+
height : 20
15+
},
16+
"slow"
17+
).queue(function() {
18+
19+
$("#title").html("We"re in the animation, baby!");
20+
1721
});
1822
```
1923

2024
As I said though, these methods come in pairs, so anything you add using queue,
2125
you need to dequeue to allow the process to continue. In the code above, if I
22-
chained more animations on, until I call $(this).dequeue(), the subsequent
26+
chained more animations on, until I call `$( this ).dequeue()`, the subsequent
2327
animations wouldn’t run:
2428

2529
```
26-
$('.box').animate({
27-
height : 20
28-
}, 'slow')
29-
.queue(function () {
30-
$('#title').html("We're in the animation, baby!");
31-
$(this).dequeue();
32-
})
33-
.animate({
30+
$(".box").animate({
31+
32+
height : 20
33+
34+
},"slow").queue(function() {
35+
36+
$("#title").html("We"re in the animation, baby!");
37+
38+
$( this ).dequeue();
39+
40+
}).animate({
41+
3442
height: 150
43+
3544
});
3645
```
3746

@@ -41,24 +50,36 @@ that sets a timer and triggers after n milliseconds, at which time, it dequeues
4150
the element:
4251

4352
```
44-
$.fn.pause = function (n) {
45-
return this.queue(function () {
53+
$.fn.pause = function( n ) {
54+
55+
return this.queue(function() {
56+
4657
var el = this;
47-
setTimeout(function () {
48-
return $(el).dequeue();
49-
}, n);
58+
59+
setTimeout( function () {
60+
61+
return $( el ).dequeue();
62+
63+
}, n );
64+
5065
});
66+
5167
};
5268
53-
$('.box').animate({
69+
$
70+
(".box").animate(
71+
72+
{
5473
height : 20
55-
}, 'slow')
56-
.pause(1000) // 1000ms == 1 second
57-
.animate({
58-
height: 150
59-
});
74+
},
75+
"slow"
76+
).pause( 1000 ).animate({
77+
height: 150
78+
});
79+
6080
```
6181

82+
6283
Remember that the first argument for queue and dequeue are `fx`, and that in
6384
all of these examples I’m not including it because jQuery set the argument to
6485
`fx` by default - so I don’t have to specify it.

0 commit comments

Comments
 (0)