diff --git a/src/slidingview/slidingview.js b/src/slidingview/slidingview.js index 343fcdf..32bda89 100644 --- a/src/slidingview/slidingview.js +++ b/src/slidingview/slidingview.js @@ -162,17 +162,30 @@ SlidingView.prototype.snapToPosition = function() { //console.log( currentPosition, halfWidth, targetX ); if ( currentPosition != targetX ) { - - this.body.stop(true, false).animate({ - left:targetX, - avoidTransforms:false, - useTranslate3d: true - }, 100); - - this.sidebar.trigger( "slidingViewProgress", { current:targetX, max:this.sidebarWidth } ); + this.slideView(targetX); } } +SlidingView.prototype.slideView = function(targetX) { + this.body.stop(true, false).animate({ + left:targetX, + avoidTransforms:false, + useTranslate3d: true + }, 100); + + this.sidebar.trigger( "slidingViewProgress", { current:targetX, max:this.sidebarWidth } ); +} + +SlidingView.prototype.close = function() { + this.bodyOffset = 0; + this.slideView(0); +} + +SlidingView.prototype.open = function() { + this.bodyOffset = this.sidebarWidth; + this.slideView(this.sidebarWidth); +} + SlidingView.prototype.unbindEvents = function() { this.body.get()[0].removeEventListener( this.MOVE_EVENT, this.touchMoveHandler, false ); this.body.get()[0].removeEventListener( this.END_EVENT, this.touchUpHandler, false );