var simpleSwipeEvents = (function (element) {
    var gestureInput = ('ontouchstart' in window) ? 'touch' : 'mouse',
    baseElement = element || document,
    noMovement = true,
    buttonDown = false,
    startingX,
    startingY,
    endingX,
    endingY,
    xMovement,
    yMovement,
    minimumMovement = 30,
    previousBaseElement,
    events = {
        touch: {
            touchstart: function (e) {
                startingX = e.touches[0].pageX;
                startingY = e.touches[0].pageY;
                customEvent(e, 'initial-touch');
            },
            touchmove: function (e) {
                noMovement = false;
                endingX = e.touches[0].pageX;
                endingY = e.touches[0].pageY;
            },
            touchend: function (e) {
                customEvent(e, determineEvent());
            },
            touchcancel: function (e) {
                noMovement = false;
            }
        },
        mouse: {
            mousedown: function (e) {
                //skip if this isn't button 0 (left mouse button)
                if (e.button) {
                    return;
                }
                buttonDown = true;
                startingX = e.x;
                startingY = e.y;
                customEvent(e, 'initial-touch');
            },
            mousemove: function (e) {
                //only do stuff if the button is down
                if (buttonDown) {
                    noMovement = false;
                    endingX = e.x;
                    endingY = e.y;
                }
            },
            mouseup: function (e) {
                //skip if this isn't the left button
                if (e.button) {
                    return;
                }
                buttonDown = false;
                customEvent(e, determineEvent());
            }
        }
    };

    handleListeners(baseElement);
    
    return {
        setMinimumMovement: setMinimumMovement,
        setBaseElement: handleListeners
    }
    
    function setMinimumMovement(distance) {
        minimumMovement = typeof distance === "number" ? distance : minimumMovement;
    }
    
    function customEvent(e, eventName) { // rename to eventFactory
        var event = new CustomEvent(eventName, {
            detail: e.target,
            bubble: true
        });
        e.target.dispatchEvent(event);
    }
    
    function handleListeners(baseElement) {
        if (baseElement == null) {
            return;
        }
        for (var event in events[gestureInput]) {
            if (previousBaseElement) {
                previousBaseElement.removeEventListener(event, events[gestureInput][event], false);
            }
            baseElement.addEventListener(event, events[gestureInput][event], false);
        }
        previousBaseElement = baseElement;
    }

    function determineEvent() {
        if (noMovement) {
            return;
        } else {
            xMovement = endingX - startingX;
            yMovement = endingY - startingY;
            //reset no movement
            noMovement = true;
            // if we've moved more than the minimum movement we care about pixels
            if (Math.max(Math.abs(xMovement), Math.abs(yMovement)) > minimumMovement) {
                // did we move more on the x or y plane?
                if (Math.abs(xMovement) > Math.abs(yMovement)) {
                    if (xMovement < 0) {
                        return 'swipe-left';
                    } else {
                        return 'swipe-right'; // can return without else
                    }
                } else {
                    if (yMovement < 0) {
                        return 'swipe-up';
                    } else {
                        return 'swipe-down'; // can return without else
                    }
                }
            } else {
                // didn't move more than the minimum movement we care about so this was just a click
                return 'fast-click';  // can return without else and just return;
            }
        }
    }
}());


@@ -512,35 +512,36 @@
             
-customEvent
+eventFactory
 (e, 'initial
@@ -803,37 +803,36 @@
     
-customEvent
+eventFactory
 (e, 
-d
+g
 et
-ermine
 Event
+Type
 ());
@@ -1260,35 +1260,36 @@
             
-customEvent
+eventFactory
 (e, 'initial
@@ -1805,37 +1805,36 @@
     
-customEvent
+eventFactory
 (e, 
-d
+g
 et
-ermine
 Event
+Type
 ());
@@ -2174,19 +2174,20 @@
 ion 
-customEvent
+eventFactory
 (e, 
@@ -2202,34 +2202,8 @@
 e) %7B
- // rename to eventFactory
 %0A   
@@ -2839,22 +2839,20 @@
 ion 
-d
+g
 et
-ermine
 Event
+Type
 () %7B

rename some functions