@@ -31,7 +31,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
3131 this . background = options . background || SidebarJS . create ( sidebarjs + '-background' ) ;
3232 this . documentMinSwipeX = options . documentMinSwipeX || 10 ;
3333 this . documentSwipeRange = options . documentSwipeRange || 40 ;
34- this . swipeOpen = options . swipeOpen !== false ;
34+ this . nativeSwipe = options . nativeSwipe !== false ;
35+ this . nativeSwipeOpen = options . nativeSwipeOpen !== false ;
3536
3637 if ( ! options . component && ! options . container && ! options . background ) {
3738 this . container . innerHTML = this . component . innerHTML ;
@@ -40,16 +41,18 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
4041 this . component . appendChild ( this . background ) ;
4142 }
4243
43- if ( this . swipeOpen ) {
44- document . addEventListener ( 'touchstart' , this . onDocumentTouchStart . bind ( this ) ) ;
45- document . addEventListener ( 'touchmove' , this . onDocumentTouchMove . bind ( this ) ) ;
46- document . addEventListener ( 'touchend' , this . onDocumentTouchEnd . bind ( this ) ) ;
44+ if ( this . nativeSwipe ) {
45+ this . component . addEventListener ( 'touchstart' , this . onTouchStart . bind ( this ) ) ;
46+ this . component . addEventListener ( 'touchmove' , this . onTouchMove . bind ( this ) ) ;
47+ this . component . addEventListener ( 'touchend' , this . onTouchEnd . bind ( this ) ) ;
48+ if ( this . nativeSwipeOpen ) {
49+ document . addEventListener ( 'touchstart' , this . onDocumentTouchStart . bind ( this ) ) ;
50+ document . addEventListener ( 'touchmove' , this . onDocumentTouchMove . bind ( this ) ) ;
51+ document . addEventListener ( 'touchend' , this . onDocumentTouchEnd . bind ( this ) ) ;
52+ }
4753 }
4854
4955 this . addAttrsEventsListeners ( ) ;
50- this . component . addEventListener ( 'touchstart' , this . onTouchStart . bind ( this ) ) ;
51- this . component . addEventListener ( 'touchmove' , this . onTouchMove . bind ( this ) ) ;
52- this . component . addEventListener ( 'touchend' , this . onTouchEnd . bind ( this ) ) ;
5356 this . background . addEventListener ( 'click' , this . close . bind ( this ) ) ;
5457 }
5558
@@ -212,11 +215,12 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
212215
213216 var container = this . elem . children [ 0 ] ;
214217 var background = this . elem . children [ 1 ] ;
215- this . _SidebarJS . init ( {
218+ var options = Object . assign ( { } , this . sidebarjsConfig , {
216219 component : this . elem ,
217220 container : container ,
218221 background : background
219222 } ) ;
223+ this . _SidebarJS . init ( options ) ;
220224
221225 var wasVisible = false ;
222226 container . addEventListener ( 'transitionend' , function ( ) {
@@ -283,7 +287,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
283287 controller : SidebarJSCtrl ,
284288 bindings : {
285289 onOpen : '&?' ,
286- onClose : '&?'
290+ onClose : '&?' ,
291+ sidebarjsConfig : '<?'
287292 }
288293 } ) . directive ( 'sidebarjsOpen' , SidebarJSDirective . bind ( null , 'open' ) ) . directive ( 'sidebarjsClose' , SidebarJSDirective . bind ( null , 'close' ) ) . directive ( 'sidebarjsToggle' , SidebarJSDirective . bind ( null , 'toggle' ) ) ;
289294} ) ( ) ;
0 commit comments