3.2.0 • Published 6 years ago

flaps v3.2.0

Weekly downloads
3
License
BSD
Repository
github
Last release
6 years ago

Flap

Wat

A tiny module for creating android-like swipe-from-the-side menus.

Flap trys to do as little as possible, and instead you are encouraged to fiddle with them until they suite your needs.

Usage

Make a flap.

var Flap = require('flaps'),
    flap = new Flap();

Assign a side

flap.side = 'right';

Assign a width

flap.width = '50%';

Shuv it somewhere

document.body.appendChild(flap.element);

Shuv something into it

// If you are awesome
flap.content.appendChild(someDOMElement);

// If you are less awesome
flap.content.innerHTML = 'sadface';

You can optionally pass a DOM element to flaps when it is constructed and it will use it as it's DOM elements. a Flap requires at least this structure:

<[element]>
    <[element]></[element]>
</[element]>

and...

var flap = new Flap(<The above DOM structure>);

however you can add whatever you want in addition to this and it should probably still work.

Flaps will raise a few events during their lifecycle.

  • ready: The flap has been rendered, and all styles have been applied.
  • close: The flap was just closed.
  • open: The flap is now open.
  • move: The flap's position just updated.
  • settle: The flap just settled open or closed.

If you want control over how it tweens it's position, you can overwrite the .tween function on the flap:

// A really exaggerated tween
flap.tween = function(direction){
    var step = (this.renderedWidth() - this.distance) / 2 + 1;
    this.distance += direction === 'close' ? -step : step;
};

If you want to change the flap's style in a way other than transform-x, you can override the updateStyle function:

// rotate the content instead.
flap.updateStyle = function(){
    this.content.style[venfix('transform')] = 'rotateY(' + (90 - 90 / 100 * this.percentOpen()) + 'deg)';
};

I will probably change the way flaps animate in the future to be time based rather than position based..

Caveat

Works OK but not perfectly in IE >= 9, Does not work in IE <= 8. Pull requests welcome.

3.2.0

6 years ago

3.1.11

8 years ago

3.1.10

9 years ago

3.1.9

9 years ago

3.1.8

9 years ago

3.1.7

9 years ago

3.1.6

9 years ago

3.1.5

9 years ago

3.1.4

9 years ago

3.1.3

9 years ago

3.1.2

9 years ago

3.1.1

9 years ago

3.1.0

9 years ago

3.0.13

9 years ago

3.0.12

9 years ago

3.0.11

9 years ago

3.0.10

9 years ago

3.0.9

10 years ago

3.0.8

10 years ago

3.0.7

10 years ago

3.0.6

10 years ago

3.0.5

10 years ago

3.0.4

10 years ago

3.0.3

10 years ago

3.0.2

10 years ago

3.0.1

10 years ago

3.0.0

10 years ago

2.1.0

10 years ago

2.0.5

10 years ago

2.0.4

10 years ago

2.0.3

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.19

10 years ago

0.0.18

10 years ago

0.0.17

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago