diff --git a/index.styl b/index.styl index 2bb3839..6894621 100644 --- a/index.styl +++ b/index.styl @@ -1,4 +1,4 @@ -@import '~flexstyl/index' +@import '~flexstyl/flex' .sled .arrows @@ -6,7 +6,9 @@ width 100% height 100% position absolute - @extend .flex, .between, .acenter + flex styl + align center + justify between .arrow border 0 @@ -15,7 +17,8 @@ width 2.5em height @width - @extend .flex, .center + flex styl + flex center outline none cursor pointer diff --git a/package.json b/package.json index 07c2855..e960cc6 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "@sled/core": "^1.3" }, "dependencies": { - "flexstyl": "0.0.4", - "rx": "^4.0.7" + "flexstyl": "^1.0.1" } } diff --git a/src/Arrows.js b/src/Arrows.js index e142cb7..b77bab8 100644 --- a/src/Arrows.js +++ b/src/Arrows.js @@ -1,5 +1,3 @@ -import rx from 'rx'; - class Arrows { constructor() { this.hidden = null; @@ -9,34 +7,33 @@ class Arrows { let slides = core.modules.slides; this.hide(slides.slide); - this.hide$(slides) - .subscribe(this.hide.bind(this)); - - this - .show$(slides).subscribe(this.show.bind(this)); - - this - .arrow$(slides).subscribe(forward => - forward ? slides.next() : slides.prev()); + this.hide$(slides, this.hide.bind(this)); + this.show$(slides, this.show.bind(this)); + this.arrow$(slides, forward => + forward ? slides.next() : slides.prev()); } - hide$(slides) { - return rx.Observable - .fromEvent(slides, 'change') - .filter(n => this.isEnd(n, slides.$$)); + hide$(slides, cb) { + slides + .addEventListener('change', n => + cb(this.isEnd(n, slides.$$))); } - show$(slides) { - return rx.Observable - .fromEvent(slides, 'change') - .filter(_ => this.hidden !== null) - .filter(n => !this.isEnd(n, slides.$$)); + show$(slides, cb) { + slides + .addEventListener('change', n => { + if (this.hidden === null) return; + if (!this.isEnd(n, slides.$$)) return; + + cb(n); + }); } - arrow$(slides) { - return rx.Observable - .fromEvent(this.$$, 'click') - .pluck('target', 'previousSibling'); + arrow$(slides, cb) { + Array.from(this.$$) + .forEach($ => + $.addEventListener('click', e => + cb(e.target.previousSibling))); } isEnd(n, $slides) {