console.js
/**
     * Handle touchstart and mousedown events.
     * @param  {object} eventTouchStart               Event properties
     */
Handle touchstart and mousedown events.
@param  {object} eventTouchStart               Event properties
Handle touchstart and mousedown events . @param { object } eventTouchStart Event properties
function handleTouchStart(eventTouchStart) {
        eventTouchStart.preventDefault();
        eventTouchStart.stopPropagation();
        if(!momentButtonWasPressed) {
            momentButtonWasPressed = (new Date()).getTime();
            if(eventTouchStart.changedTouches) {
                touchId = eventTouchStart.changedTouches[0].identifier;
            }
            setTimeout(function () {
                if(momentButtonWasPressed) {
                    document.addEventListener('touchmove', handleTouchMove);
                    document.addEventListener('mousemove', handleTouchMove);
                    btnOpenConsole.classList.add('dragging');
                }
            }, buttonPressThreshold);
        }
    }
function handleTouchStart ( eventTouchStart ) { eventTouchStart . preventDefault ( ) ; eventTouchStart . stopPropagation ( ) ; if ( ! momentButtonWasPressed ) { momentButtonWasPressed = ( new Date ( ) ) . getTime ( ) ; if ( eventTouchStart . changedTouches ) { touchId = eventTouchStart . changedTouches [ 0 ] . identifier ; } setTimeout ( function ( ) { if ( momentButtonWasPressed ) { document . addEventListener ( 'touchmove' , handleTouchMove ) ; document . addEventListener ( 'mousemove' , handleTouchMove ) ; btnOpenConsole . classList . add ( 'dragging' ) ; } } , buttonPressThreshold ) ; } }
Handle touchstart and mousedown events.
Handle touchstart and mousedown events .
// prevents bubbling of event
 // Save the time the user touched/clicked the button
 // Create a timeout to check if the user touches/clicks the button more then the threshold
 // We check if momentButtonWasPressed because this variable is cleared on touchend/mouseup
 // add events to the document instead of the button.
 // this is done to continue to drag the button even if the user moves too fast 
 // (and the event listener/dragging is not able to keep up)
