noelwelsh / flan

An animation library for the Javascript functional reactive library Flapjax

This URL has Read+Write access

flan / effects.js
100644 33 lines (24 sloc) 0.665 kb
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
//
// Flapjax Effects
//
 
//
// Core functions
//
 
// slideDownE : Element -> EventStream Boolean
//
// Scrolls height of an element from 0 to 100%. Returned event fires when the animation ends.
function slideDownE(elt) {
  var height = elt.getHeight();
  var steps = 20;
  var interval = 20;
  var height_e = rangeE(0, height, steps, interval);
 
  insertValueB({style: {height: height_e.startsWith(0)}}, elt);
  return height_e.stopE;
}
 
 
// fadeInE : Element Int -> Unit
function fadeInE(elt) {
  var steps = 20;
  var interval = 20;
 
  var opacity_e = rangeE(0, 1.0, steps, steps, interval);
 
  insertValueB({style: {opacity: opacity_e.startsWith(0)}}, elt);
}