OSDN Git Service

Version 0.6.138, working X.UI.ScrollBox!, fix Node.prev & Node.next.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 05_XUI_Gesture.js
index 77df8c2..1f7bd1f 100644 (file)
@@ -24,7 +24,7 @@
                // start detection on touchstart\r
                Utils.addEvents( uinode, Hammer.EVENT_TYPES_START, this );\r
                \r
-               this.listen( type );\r
+               this[ 'listen' ]( type );\r
        };\r
        \r
        Hammer.defaults = {};\r
                        type |= POINTER;\r
                        switch( e.pointerType ){\r
                                case 'touch' :\r
-                               case 2       : //e.MSPOINTER_TYPE_TOUCH :\r
                                        type |= TOUCH; break;\r
                                case 'pen' :\r
-                               case 3     : //e.MSPOINTER_TYPE_PEN :\r
                                        type |= PEN; break;\r
                                case 'mouse' :\r
-                               case 4       : //e.MSPOINTER_TYPE_MOUSE :\r
                                        type |= MOUSE; break;\r
                                default :\r
                                        return;\r
                        };\r
-               } else\r
-               if( e.touches ){\r
-                       type |= TOUCH;\r
-               } else {\r
-                       type |= MOUSE;\r
                };\r
                \r
                // onmouseup, but when touchend has been fired we do nothing.\r
                // this is for touchdevices which also fire a mouseup on touchend\r
                if( type & MOUSE && touch_triggered ){\r
-                       return X.Callback.STOP_NOW | X.Callback.PREVENT_DEFAULT;\r
-               }\r
+                       return X_Callback_STOP_NOW | X_Callback_PREVENT_DEFAULT;\r
+               } else\r
                // mousebutton must be down or a touch event\r
-               else if (\r
-                       type & TOUCH || //sourceEventType.match(/touch/) || // touch events are always on screen\r
+               if( type & TOUCH || //sourceEventType.match(/touch/) || // touch events are always on screen\r
                        ( type & POINTER && type & START ) || //sourceEventType.match(/pointerdown/) || // pointerevents touch\r
                        ( type & MOUSE   && e.button === 0 ) //(sourceEventType.match(/mouse/) && e.which === 1) // mouse is pressed\r
                ){\r
                        enable_detect = true;\r
                };\r
 \r
-               console.log( 'Hammer@handleEvent ' + IdToGestureID[ e.type ] + ' ' + e.type + ' ' + X.UI.Event._POINTER_DOWN + ' ' + enable_detect );\r
+               //console.log( 'Hammer@handleEvent ' + IdToGestureID[ e.type ] + ' ' + e.type + ' ' + X.UI.Event._POINTER_DOWN + ' ' + enable_detect );\r
 \r
                // we are in a touch event, set the touch triggered bool to true,\r
                // this for the conflicts that may occur on ios and android\r
                                };\r
                                numTouches = touches.length;\r
                                \r
-                               console.log( 'numTouches ' + numTouches );\r
+                               ///console.log( 'numTouches ' + numTouches );\r
                        } else\r
                        // touch\r
                        if ( type & TOUCH ){ //sourceEventType.match(/touch/)) {\r
                                // only when the instance options have enabled this gesture\r
                                active[ gesture.name ] &&\r
                                        // if a handler returns false, we stop with the detection\r
-                                       ( ret |= ( gesture.handler( e, hammer ) || X.Callback.NONE ) );\r
+                                       ( ret |= ( gesture.handler( e, hammer ) || X_Callback_NONE ) );\r
                        };\r
 \r
                        // endevent, but not the last touch, so dont stop\r
                        Detection.register( Gestures[ name ] );\r
                };\r
 \r
-               //if( X.Dom.EVENT_POINTER ){\r
-                       Hammer.EVENT_TYPES_START = [ X.UI.Event._POINTER_DOWN ];\r
-                       types = [ X.UI.Event._POINTER_MOVE, X.UI.Event._POINTER_UP, X.UI.Event._POINTER_CANCEL ];\r
-               /*} else\r
-               if( X.Dom.EVENT_TOUCH ){\r
-                       Hammer.EVENT_TYPES_START = [ X.UI.Event._TOUCH_START, X.UI.Event._MOUSE_DOWN ];\r
-                       types = [ X.UI.Event._MOUSE_MOVE, X.UI.Event._MOUSE_UP, X.UI.Event._MOUSE_CANCEL,\r
-                               X.UI.Event._TOUCH_MOVE, X.UI.Event._TOUCH_END, X.UI.Event._TOUCH_CANCEL ];\r
-               } else {\r
-                       Hammer.EVENT_TYPES_START = [ X.UI.Event._MOUSE_DOWN ];\r
-                       types = [ X.UI.Event._MOUSE_MOVE, X.UI.Event._MOUSE_UP, X.UI.Event._MOUSE_CANCEL ];\r
-               }; */\r
+               Hammer.EVENT_TYPES_START = [ X.UI.Event._POINTER_DOWN ];\r
+               types = [ X.UI.Event._POINTER_MOVE, X.UI.Event._POINTER_UP, X.UI.Event._POINTER_CANCEL ];\r
 \r
                // Add touch events on the document\r
                Utils.addEvents( uinodeRoot, types, Hammer.prototype.handleEvent );\r
                if( !this.types[ type ] ) return;\r
                var e = Utils.extend( {}, gesture );\r
                e.type = type;\r
-               return this.uinode.dispatch( e );\r
+               return this.uinode[ 'dispatch' ]( e );\r
        };\r
        \r
        Hammer.prototype.listen = function( type ){\r
        /*\r
         *  "Android version < 2.2" return ev.touches.length === 1 when touchend, others return ev.touches.length === 0\r
         */\r
-       Hammer.DO_TOUCHES_FIX = Hammer.HAS_TOUCHEVENTS && ( X.UA.Android < 2.2 || X.UA.Blink || X.UA.Opera );\r
+       Hammer.DO_TOUCHES_FIX = Hammer.HAS_TOUCHEVENTS && ( X_UA[ 'Android' ] < 2.2 || X_UA[ 'Blink' ] || X_UA[ 'Opera' ] );\r
        \r
        // detect touchevents\r
        Hammer.HAS_POINTEREVENTS = true; // navigator.pointerEnabled || navigator.msPointerEnabled;\r
        IdToGestureID[ X.UI.Event._POINTER_UP     ] = END;\r
        IdToGestureID[ X.UI.Event._POINTER_CANCEL ] = END;\r
        \r
-       IdToGestureID[ X.UI.Event._TOUCH_START  ] = START;\r
-       IdToGestureID[ X.UI.Event._TOUCH_MOVE   ] = MOVE;\r
-       IdToGestureID[ X.UI.Event._TOUCH_END    ] = END;\r
-       IdToGestureID[ X.UI.Event._TOUCH_CANCEL ] = END;\r
-       \r
-       IdToGestureID[ X.UI.Event._MOUSE_DOWN   ] = START;\r
-       IdToGestureID[ X.UI.Event._MOUSE_MOVE   ] = MOVE;\r
-       IdToGestureID[ X.UI.Event._MOUSE_UP     ] = END;\r
-       IdToGestureID[ X.UI.Event._MOUSE_CANCEL ] = END;\r
-       \r
        Utils = {\r
                \r
                /**\r
                 */\r
                addEvents : function( uinode, types, context ){\r
                        for( var i = 0; i < types.length; ++i ){\r
-                               uinode.listen( types[ i ], context );\r
+                               uinode[ 'listen' ]( types[ i ], context );\r
                        };\r
                },\r
                \r
                        switch( e.eventType ){\r
                                case START :\r
                                        // clear any running timers\r
-                                       this.timerID && X.Timer.remove( this.timerID );\r
+                                       this.timerID && X_Timer_remove( this.timerID );\r
 \r
                                        // set the gesture so we can check in the timeout if it still is\r
                                        Detection.current.name = this.name;\r
                                        \r
                                        // set timer and if after the timeout it still is hold,\r
                                        // we trigger the hold event\r
-                                       this.timerID = X.Timer.add( hammer.options.hold_timeout, 1, Gestures.Hold._onTimer, [ e, hammer ] );\r
+                                       this.timerID = X_Timer_add( hammer.options.hold_timeout, 1, Gestures.Hold._onTimer, [ e, hammer ] );\r
                                        return;\r
 \r
                                // when you move or end we clear the timer\r
                                case MOVE :\r
                                        if( e.distance <= hammer.options.hold_threshold ) return;\r
                                case END :\r
-                                       this.timerID && X.Timer.remove( this.timerID );\r
+                                       this.timerID && X_Timer_remove( this.timerID );\r
                                        if( Gestures.Hold.holding === true ){\r
                                                Gestures.Hold.holding = false;\r
                                                return hammer.trigger( X.UI.Event.HOLD_END, e );\r