summaryrefslogtreecommitdiff
path: root/deck.js/extensions/events/README.md
blob: 22d003efb55edf822716204784519f2bf098a192 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# deck.events.js

An extension for [deck.js][] allowing you to execute Javascript when a
  slide becomes/leaves the current, next, or previous slide.

## Requirements

[deck.js][]

## Events

Each event is triggered "on" the slide on which the event occurs (see _Example_)
  and given a single argument -- the direction (see _Direction_)

* **deck.becameCurrent**: Triggered when a slide becomes the current one
  (`to` in `deck.change`).
* **deck.lostCurrent**: The slide is no longer "current"
  (`from` in `deck.change`).
* **deck.becamePrevious**: The slide (by order) just before the current slide.
  (`to - 1` in `deck.change`).
* **deck.becameNext**: The slide (by order) just after the current slide.
  (`to + 1` in `deck.change`).
* **deck.lostPrevious**: The slide (by order) just before the last current slide.
  (`from - 1` in `deck.change`).
* **deck.lostNext**: The slide (by order) just after the last current slide.
  (`from + 1` in `deck.change`).
  

## Direction

Each event is given a direction that helps determine whether the user is
  moving forward or backward in the slide stack. It is provided as an argument
  for the event and can be either `forward` or `reverse`. Essentially:

```
  if(from < to){
    direction = "forward";
  }
  else{
    direction = "reverse";
  }
```


## Example

If you put a placeholder slide `<div id="showGraph" class="slide"></div>` into
  your source, this event will display a Javascript graph when you visit the
  slide (forward) and remove it if you hit the back arrow and return to
  the slide.

```
$("#showGraph").bind('deck.becameCurrent', function(ev, direction) {
  if(direction == "forward"){
    animateGraphIn();
  }
  else{
    animateGraphOut();
  }
});
```


[deck.js]: https://github.com/imakewebthings/deck.js