Skip to content

Commit

Permalink
Add new events: and .
Browse files Browse the repository at this point in the history
  • Loading branch information
pazguille committed Dec 26, 2015
1 parent 96b335e commit 8179c1e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,28 @@ An instance of Slideout emits the following events:
- `close`
- `beforeopen`
- `open`
- `translatestart`
- `translate`
- `translateend`

The slideout emits `translate` event only when it is opening/closing via touch events.
The slideout emits `translatestart`, `translate` and `translateend` events only when it is opening/closing via touch events.

```js
slideout.on('translatestart', function() {
console.log('Start');
});

slideout.on('translate', function(translated) {
console.log(translated); // 120 in px
console.log('Translate: ' + translated); // 120 in px
});

slideout.on('translateend', function() {
console.log('End');
});

// 'Start'
// 'Translate 120'
// 'End'
```

## npm-scripts
Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Slideout.prototype._initTouchEvents = function() {
*/
this._onTouchEndFn = function() {
if (self._moved) {
self.emit('translateend');
(self._opening && Math.abs(self._currentOffsetX) > self._tolerance) ? self.open() : self.close();
}
self._moved = false;
Expand Down Expand Up @@ -251,6 +252,10 @@ Slideout.prototype._initTouchEvents = function() {
return;
}

if (!self._moved) {
self.emit('translatestart');
}

if (oriented_dif_x <= 0) {
translateX = dif_x + self._padding * self._orientation;
self._opening = false;
Expand Down

1 comment on commit 8179c1e

@PawelGlow
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pazguille any idea when this will be merged?

Please sign in to comment.