app/assets/javascripts/pageflow/slideshow/scroller_widget.js in pageflow-0.8.2 vs app/assets/javascripts/pageflow/slideshow/scroller_widget.js in pageflow-0.9.0

- old
+ new

@@ -9,28 +9,33 @@ dragThreshold: 50, maxXDelta: 50, doubleBumpThreshold: 500, _create: function() { - this.iscroll = new IScroll(this.element[0], { + this.iscroll = new IScroll(this.element[0], _.extend({ mouseWheel: true, bounce: false, keyBindings: true, probeType: 2, preventDefault: false - }); + }, _.pick(this.options, 'freeScroll', 'scrollX', 'noMouseWheelScrollX'))); this.iscroll.disable(); - this._initMousewheelBump('up'); - this._initMousewheelBump('down'); + if (pageflow.entryData.getThemingOption('page_change_by_scrolling')) { + this._initMousewheelBump('up'); + this._initMousewheelBump('down'); + this._initDragGestureBump(); + } + this._initKeyboardBump('up'); this._initKeyboardBump('down'); - this._initDragGestureBump(); this._initNearBottomEvents(); this._initNearTopEvents(); this._initMoveEvents(); + + this._onScrollEndCallbacks = new $.Callbacks(); }, enable: function() { this.iscroll.enable(); this.iscroll.refresh(); @@ -47,10 +52,29 @@ else { this.iscroll.scrollTo(0, 0, 0); } }, + scrollBy: function(deltaX, deltaY, time, easing) { + this.scrollTo( + this.iscroll.x + deltaX, + this.iscroll.y + deltaY, + time, + easing + ); + }, + + scrollTo: function(x, y, time, easing) { + this.iscroll.scrollTo( + Math.max(Math.min(x, 0), this.iscroll.maxScrollX), + Math.max(Math.min(y, 0), this.iscroll.maxScrollY), + time, + easing + ); + this._onScrollEndCallbacks.fire(); + }, + refresh: function() { this.iscroll.refresh(); }, afterAnimationHook: function() { @@ -59,19 +83,32 @@ disable: function() { this.iscroll.disable(); }, + positionX: function() { + return this.iscroll.x; + }, + positionY: function() { return this.iscroll.y; }, + maxX: function() { + return this.iscroll.maxScrollX; + }, + + maxY: function() { + return this.iscroll.maxScrollY; + }, + onScroll: function(callback) { this.iscroll.on('scroll', callback); }, onScrollEnd: function(callback) { this.iscroll.on('scrollEnd', callback); + this._onScrollEndCallbacks.add(callback); }, _initMoveEvents: function() { this.iscroll.on('mousewheelup', _.bind(this._triggerMoveEvent, this)); this.iscroll.on('mousewheeldown', _.bind(this._triggerMoveEvent, this)); \ No newline at end of file