File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change 230230 nextTheme : function ( ) {
231231 state . setTheme ( ( state . theme + 1 ) % Object . keys ( Theme ) . length ) ;
232232 } ,
233- touchType : function ( ) {
233+ getTouchDirection : function ( x , width ) {
234+ if ( ! x || ! width ) {
235+ return null ;
236+ }
237+ if ( x > width * 2 / 3 ) {
238+ return TouchDirection . RIGHT ;
239+ } else if ( x > width / 2 ) {
240+ return TouchDirection . CENTER ;
241+ } else {
242+ return TouchDirection . LEFT ;
243+ }
244+ } ,
245+ getTouchType : function ( ) {
234246 if ( ! state . touch . start ) {
235247 return null ;
236248 }
287299 return ;
288300 }
289301 var touch = event . touches [ 0 ] ;
290- var pageCenter = document . body . clientWidth / 2 ;
291- state . setTouch (
292- touch . pageX < pageCenter ? TouchDirection . LEFT : TouchDirection . RIGHT
293- ) ;
302+ var direction = state . getTouchDirection ( touch . pageX , document . body . clientWidth ) ;
303+ state . setTouch ( direction ) ;
294304 } ,
295305 handleTouchmove : function ( event ) {
296306 event . preventDefault ( ) ;
301311 if ( event . touches . length > 0 ) {
302312 return ;
303313 }
304- var type = state . touchType ( ) ;
314+ var type = state . getTouchType ( ) ;
305315 var direction = state . touch . direction ;
306316 if ( type === TouchType . HOLD ) {
307317 state . nextTheme ( ) ;
You can’t perform that action at this time.
0 commit comments