test/bundle.js
/**
     * the core touch event handler.
     * this finds out if we should to detect gestures
     * @method onTouch
     * @param {HTMLElement} element
     * @param {String} eventType matches `EVENT_START|MOVE|END`
     * @param {Function} handler
     * @return onTouchHandler {Function} the core event handler
     */
the core touch event handler.
the core touch event handler .
function onTouch(element, eventType, handler) {
        var self = this;
        var onTouchHandler = function onTouchHandler(ev) {
            var srcType = ev.type.toLowerCase(),
                isPointer = Hammer.HAS_POINTEREVENTS,
                isMouse = Utils.inStr(srcType, 'mouse'),
                triggerType;
            if(isMouse && self.preventMouseEvents) {
                return;
            } else if(isMouse && eventType == EVENT_START && ev.button === 0) {
                self.preventMouseEvents = false;
                self.shouldDetect = true;
            } else if(isPointer && eventType == EVENT_START) {
                self.shouldDetect = (ev.buttons === 1 || PointerEvent.matchType(POINTER_TOUCH, ev));
            } else if(!isMouse && eventType == EVENT_START) {
                self.preventMouseEvents = true;
                self.shouldDetect = true;
            }
            if(isPointer && eventType != EVENT_END) {
                PointerEvent.updatePointer(eventType, ev);
            }
            if(self.shouldDetect) {
                triggerType = self.doDetect.call(self, ev, eventType, element, handler);
            }
            if(triggerType == EVENT_END) {
                self.preventMouseEvents = false;
                self.shouldDetect = false;
                PointerEvent.reset();
            }
            if(isPointer && eventType == EVENT_END) {
                PointerEvent.updatePointer(eventType, ev);
            }
        };
        this.on(element, EVENT_TYPES[eventType], onTouchHandler);
        return onTouchHandler;
    }
function onTouch ( element , eventType , handler ) { var self = this ; var onTouchHandler = function onTouchHandler ( ev ) { var srcType = ev . type . toLowerCase ( ) , isPointer = Hammer . HAS_POINTEREVENTS , isMouse = Utils . inStr ( srcType , 'mouse' ) , triggerType ; if ( isMouse && self . preventMouseEvents ) { return ; } else if ( isMouse && eventType == EVENT_START && ev . button === 0 ) { self . preventMouseEvents = false ; self . shouldDetect = true ; } else if ( isPointer && eventType == EVENT_START ) { self . shouldDetect = ( ev . buttons === 1 || PointerEvent . matchType ( POINTER_TOUCH , ev ) ) ; } else if ( ! isMouse && eventType == EVENT_START ) { self . preventMouseEvents = true ; self . shouldDetect = true ; } if ( isPointer && eventType != EVENT_END ) { PointerEvent . updatePointer ( eventType , ev ) ; } if ( self . shouldDetect ) { triggerType = self . doDetect . call ( self , ev , eventType , element , handler ) ; } if ( triggerType == EVENT_END ) { self . preventMouseEvents = false ; self . shouldDetect = false ; PointerEvent . reset ( ) ; } if ( isPointer && eventType == EVENT_END ) { PointerEvent . updatePointer ( eventType , ev ) ; } } ; this . on ( element , EVENT_TYPES [ eventType ] , onTouchHandler ) ; return onTouchHandler ; }
the core touch event handler.
the core touch event handler .
// if we are in a mouseevent, but there has been a touchevent triggered in this session // we want to do nothing. simply break out of the event. // mousebutton must be down // just a valid start event, but no mouse // update the pointer event before entering the detection // we are in a touch/down state, so allowed detection of gestures // ...and we are done with the detection // so reset everything to start each detection totally fresh // update the pointerevent object after the detection