From 1303f55c142403ac3f1141ad099c15f64175a93b Mon Sep 17 00:00:00 2001 From: Joey Arnold Date: Fri, 5 Feb 2016 00:35:59 -0700 Subject: [PATCH] changed to jandres:iscroll (gulpified) --- components/ionScroll/ionScroll.js | 37 ++++++++++++++++++++----------- package.js | 4 ++-- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/components/ionScroll/ionScroll.js b/components/ionScroll/ionScroll.js index 9be5b91..6af1c15 100644 --- a/components/ionScroll/ionScroll.js +++ b/components/ionScroll/ionScroll.js @@ -4,23 +4,30 @@ Template.ionScroll.onCreated(function() { this.locking = new ReactiveVar(true); this.paging = new ReactiveVar(true); this.onRefresh = new ReactiveVar(true); - this.onScroll = new ReactiveVar(true); + this.onScroll = new ReactiveVar(() => {}); this.scrollBarX = new ReactiveVar(true); this.scrollBarY = new ReactiveVar(true); - this.zooming = new ReactiveVar(true); - this.minZoom = new ReactiveVar(true); - this.maxZoom = new ReactiveVar(true); + this.zooming = new ReactiveVar(false); + this.minZoom = new ReactiveVar(0.5); + this.maxZoom = new ReactiveVar(3); this.hasBouncing = new ReactiveVar(true); + this.scroller = null; + _.extend(this, { set_direction: direction => this.direction.set(_.isUndefined(direction) ? 'y' : direction), set_locking: locking => this.locking.set(_.isUndefined(locking) ? true : locking), set_paging: paging => this.paging.set(!!paging), set_onRefresh: onRefresh => this.onRefresh.set(onRefresh), - set_onScroll: onScroll => this.onScroll.set(onScroll), + set_onScroll: onScroll => { + if (_.isFunction(onScroll)) { + if (!!this.scroller) this.scroller.off(this.onScroll.get(onScroll)); + this.onScroll.set(onScroll); + } + }, set_scrollBarX: scrollBarX => this.scrollBarX.set(_.isUndefined(scrollBarX) ? true : scrollBarX), set_scrollBarY: scrollBarY => this.scrollBarY.set(_.isUndefined(scrollBarY) ? true : scrollBarY), - set_zooming: zooming => this.zooming.set(zooming), + set_zooming: zooming => this.zooming.set(!!zooming), set_minZoom: minZoom => this.minZoom.set(_.isUndefined(minZoom) ? minZoom : 0.5), set_maxZoom: maxZoom => this.maxZoom.set(_.isUndefined(maxZoom) ? maxZoom : 3), set_hasBouncing: hasBouncing => this.hasBouncing.set(_.isUndefined(hasBouncing) ? true: hasBouncing) // todo: Make this platform dependent. @@ -46,26 +53,30 @@ Template.ionScroll.onCreated(function() { Template.ionScroll.onRendered(function() { if (!this.nativeScrolling.get()) { // todo: make this reactive? Is there a use case? - let scroller = new IScroll(this.$(".scroller-wrapper").get(0)); + this.scroller = new IScroll(this.$(".scroller-wrapper").get(0)); + + if (!!this.onScroll.get()) { this.scroller.on('scroll', this.onScroll.get()); } this.autorun(() => { - scroller.options = _.extend(scroller.options, { + this.scroller.options = _.extend(this.scroller.options, { scrollX: this.direction.get().indexOf('x') !== -1, scrollY: this.direction.get().indexOf('y') !== -1, freeScroll: !this.locking.get(), + zoom: this.zooming.get(), zoomMin: this.minZoom.get(), zoomMax: this.maxZoom.get(), bounce: this.hasBouncing.get() }); - // todo: add a removeEvent or .off - //scroller.on('scroll', !!this.onScroll.get() ? this.onScroll.get() : () => {}); // Have a way to remove events. - //scroller.on('zooming'); // todo: modify iscroll. + this.scroller.refresh(); + }); - scroller.refresh(); + this.autorun(() => { + // only available in ionscroll-probe. + //if (_.isFunction(this.onScroll.get())) { console.log(this.onScroll.get()); this.scroller.on('onScroll', this.onScroll.get()); } }); - this.$(".scroller-wrapper").children().load(() => scroller.refresh()); + this.$(".scroller-wrapper").children().load(() => this.scroller.refresh()); } }); diff --git a/package.js b/package.js index 2d2f0e8..c745900 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ Package.describe({ name: "jandres:ionic", summary: "Ionic components for Meteor. No Angular!", - version: "0.1.42", + version: "0.1.43", git: "https://github.com/JoeyAndres/meteor-ionic.git" }); @@ -25,7 +25,7 @@ Package.onUse(function(api) { "tracker", "session", "jquery", - "raix:iscroll@0.0.3", + "jandres:iscroll-zoom@5.1.4", "jandres:snapjs@2.0.2", "fourseven:scss@3.3.3" ], "client");