<commit_before>(function (root, factory) {
    if (typeof exports === 'object') {
        module.exports = factory();
    } else if (typeof define === 'function' && define.amd) {
        define(factory);
    } else {
        root.interact = factory();
    }
}(this, function () {
    var interactions = [],
        minMoveDistance = 5,
        interact = {},
        maximumMovesToPersist = 1000; // Should be plenty..

    // document.body.style.webkitTouchCallout = 'none';
    // document.body.style.KhtmlUserSelect = 'none';

    function getActualTarget() {
        // For some reason touch browsers never change the event target during a touch.
        // This is, lets face it, fucking stupid.
        return document.elementFromPoint(this.pageX - window.scrollX, this.pageY - window.scrollY);
    }


    function getMoveDistance(x1,y1,x2,y2){
        var adj = Math.abs(x1 - x2),
            opp = Math.abs(y1 - y2);

        return Math.sqrt(Math.pow(adj,2) + Math.pow(opp,2));
    }

    function destroyInteraction(interaction){
        for(var i = 0; i < interactions.length; i++){
            if(interactions[i].identifier === interaction.identifier){
                interactions.splice(i,1);
            }
        }
    }

    function getInteraction(identifier){
        for(var i = 0; i < interactions.length; i++){
            if(interactions[i].identifier === identifier){
                return interactions[i];
            }
        }
    }

    function setInheritedData(interaction, data){
        interaction.__proto__.__proto__ = data;
    }

    function Interaction(event, interactionInfo){
        // If there is no event (eg: desktop) just make the identifier undefined
        if(!event){
            event = {};
        }
        // If there is no extra info about the interaction (eg: desktop) just use the event itself
        if(!interactionInfo){
            interactionInfo = event;
        }

        // If there is another interaction with the same ID, something went wrong.
        // KILL IT WITH FIRE!
        var oldInteraction = getInteraction(interactionInfo.identifier);
        oldInteraction && oldInteraction.destroy();

        this.identifier = interactionInfo.identifier;

        this.moves = [];

        interactions.push(this);
    }

    Interaction.prototype = {
        constructor: Interaction,
        getActualTarget: getActualTarget,
        destroy: function(){
            trigger('destroy', this.target, this, this);
            destroyInteraction(this);
        },
        start: function(event, interactionInfo){
            // If there is no extra info about the interaction (eg: desktop) just use the event itself
            if(!interactionInfo){
                interactionInfo = event;
            }

            var lastStart = {
                    time: new Date()
                };
            lastStart.__proto__ = interactionInfo;
            this.lastStart = lastStart;

            setInheritedData(this, interactionInfo);

            trigger('start', event.target, event, this);
            return this;
        },
        move: function(event, interactionInfo){
            // If there is no extra info about the interaction (eg: desktop) just use the event itself
            if(!interactionInfo){
                interactionInfo = event;
            }

            var currentTouch = {
                    time: new Date()
                };
            currentTouch.__proto__ = interactionInfo;

            // Update the interaction
            setInheritedData(this, interactionInfo);

            // Memory saver, culls any moves that are over the maximum to keep.
            this.moves = this.moves.slice(-maximumMovesToPersist);

            this.moves.push(currentTouch);

            var lastMove = this.moves[this.moves.length-2];
            lastMove && (currentTouch.angle = Math.atan2(currentTouch.pageY - lastMove.pageY, currentTouch.pageX - lastMove.pageX) * 180 / Math.PI);
            this.angle = currentTouch.angle || 0;

            trigger('move', event.target, event, this);
            return this;
        },
        drag: function(event, interactionInfo){
            // If there is no extra info about the interaction (eg: desktop) just use the event itself
            if(!interactionInfo){
                interactionInfo = event;
            }

            var currentTouch = {
                    time: new Date(),
                    isDrag: true
                };

            currentTouch.__proto__ = interactionInfo;

            // Update the interaction
            setInheritedData(this, interactionInfo);

            if(!this.moves){
                this.moves = [];
            }

            // Memory saver, culls any moves that are over the maximum to keep.
            this.moves = this.moves.slice(-maximumMovesToPersist);

            this.moves.push(currentTouch);

            if(!this.dragStarted && getMoveDistance(this.lastStart.pageX, this.lastStart.pageY, currentTouch.pageX, currentTouch.pageY) > minMoveDistance){
                this.dragStarted = true;
            }

            var lastDrag = this.moves[this.moves.length-2];
            lastDrag && (currentTouch.angle = Math.atan2(currentTouch.pageY - lastDrag.pageY, currentTouch.pageX - lastDrag.pageX) * 180 / Math.PI);
            this.angle = currentTouch.angle || 0;

            if(this.dragStarted){
                trigger('drag', event.target, event, this);
            }
            return this;
        },
        end: function(event, interactionInfo){
            if(!interactionInfo){
                interactionInfo = event;
            }

            // Update the interaction
            setInheritedData(this, interactionInfo);

            trigger('end', event.target, event, this);

            return this;
        },
        cancel: function(event, interactionInfo){
            if(!interactionInfo){
                interactionInfo = event;
            }

            // Update the interaction
            this.__proto__ = interactionInfo;

            trigger('cancel', event.target, event, this);

            return this;
        },
        getMoveDistance: function(){
            if(this.moves.length > 1){
                var current = this.moves[this.moves.length-1],
                    previous = this.moves[this.moves.length-2];

                return getMoveDistance(current.pageX, current.pageY, previous.pageX, previous.pageY);
            }
        },
        getSpeed: function(){
            if(this.moves.length > 1){
                var current = this.moves[this.moves.length-1],
                    previous = this.moves[this.moves.length-2];

                return this.getMoveDistance() / (current.time - previous.time);<commit_msg>reverted back to manual prop copying<commit_after>(function (root, factory) {
    if (typeof exports === 'object') {
        module.exports = factory();
    } else if (typeof define === 'function' && define.amd) {
        define(factory);
    } else {
        root.interact = factory();
    }
}(this, function () {
    var interactions = [],
        minMoveDistance = 5,
        interact = {},
        maximumMovesToPersist = 1000, // Should be plenty..
        propertiesToCopy = 'target,pageX,pageY,clientX,clientY,offsetX,offsetY,screenX,screenY,shiftKey,x,y'.split(','); // Stuff that will be on every interaction.

    // document.body.style.webkitTouchCallout = 'none';
    // document.body.style.KhtmlUserSelect = 'none';

    function getActualTarget() {
        // For some reason touch browsers never change the event target during a touch.
        // This is, lets face it, fucking stupid.
        return document.elementFromPoint(this.pageX - window.scrollX, this.pageY - window.scrollY);
    }


    function getMoveDistance(x1,y1,x2,y2){
        var adj = Math.abs(x1 - x2),
            opp = Math.abs(y1 - y2);

        return Math.sqrt(Math.pow(adj,2) + Math.pow(opp,2));
    }

    function destroyInteraction(interaction){
        for(var i = 0; i < interactions.length; i++){
            if(interactions[i].identifier === interaction.identifier){
                interactions.splice(i,1);
            }
        }
    }

    function getInteraction(identifier){
        for(var i = 0; i < interactions.length; i++){
            if(interactions[i].identifier === identifier){
                return interactions[i];
            }
        }
    }

    function setInheritedData(interaction, data){
        for(var i = 0; i < propertiesToCopy.length; i++) {
            interaction[propertiesToCopy[i]] = data[propertiesToCopy[i]]
        }
    }

    function Interaction(event, interactionInfo){
        // If there is no event (eg: desktop) just make the identifier undefined
        if(!event){
            event = {};
        }
        // If there is no extra info about the interaction (eg: desktop) just use the event itself
        if(!interactionInfo){
            interactionInfo = event;
        }

        // If there is another interaction with the same ID, something went wrong.
        // KILL IT WITH FIRE!
        var oldInteraction = getInteraction(interactionInfo.identifier);
        oldInteraction && oldInteraction.destroy();

        this.identifier = interactionInfo.identifier;

        this.moves = [];

        interactions.push(this);
    }

    Interaction.prototype = {
        constructor: Interaction,
        getActualTarget: getActualTarget,
        destroy: function(){
            trigger('destroy', this.target, this, this);
            destroyInteraction(this);
        },
        start: function(event, interactionInfo){
            // If there is no extra info about the interaction (eg: desktop) just use the event itself
            if(!interactionInfo){
                interactionInfo = event;
            }

            var lastStart = {
                    time: new Date()
                };
            setInheritedData(lastStart, interactionInfo);
            this.lastStart = lastStart;

            setInheritedData(this, interactionInfo);

            trigger('start', event.target, event, this);
            return this;
        },
        move: function(event, interactionInfo){
            // If there is no extra info about the interaction (eg: desktop) just use the event itself
            if(!interactionInfo){
                interactionInfo = event;
            }

            var currentTouch = {
                    time: new Date()
                };
            setInheritedData(currentTouch, interactionInfo);

            // Update the interaction
            setInheritedData(this, interactionInfo);

            // Memory saver, culls any moves that are over the maximum to keep.
            this.moves = this.moves.slice(-maximumMovesToPersist);

            this.moves.push(currentTouch);

            var lastMove = this.moves[this.moves.length-2];
            lastMove && (currentTouch.angle = Math.atan2(currentTouch.pageY - lastMove.pageY, currentTouch.pageX - lastMove.pageX) * 180 / Math.PI);
            this.angle = currentTouch.angle || 0;

            trigger('move', event.target, event, this);
            return this;
        },
        drag: function(event, interactionInfo){
            // If there is no extra info about the interaction (eg: desktop) just use the event itself
            if(!interactionInfo){
                interactionInfo = event;
            }

            var currentTouch = {
                    time: new Date(),
                    isDrag: true
                };

            setInheritedData(currentTouch, interactionInfo);

            // Update the interaction
            setInheritedData(this, interactionInfo);

            if(!this.moves){
                this.moves = [];
            }

            // Memory saver, culls any moves that are over the maximum to keep.
            this.moves = this.moves.slice(-maximumMovesToPersist);

            this.moves.push(currentTouch);

            if(!this.dragStarted && getMoveDistance(this.lastStart.pageX, this.lastStart.pageY, currentTouch.pageX, currentTouch.pageY) > minMoveDistance){
                this.dragStarted = true;
            }

            var lastDrag = this.moves[this.moves.length-2];
            lastDrag && (currentTouch.angle = Math.atan2(currentTouch.pageY - lastDrag.pageY, currentTouch.pageX - lastDrag.pageX) * 180 / Math.PI);
            this.angle = currentTouch.angle || 0;

            if(this.dragStarted){
                trigger('drag', event.target, event, this);
            }
            return this;
        },
        end: function(event, interactionInfo){
            if(!interactionInfo){
                interactionInfo = event;
            }

            // Update the interaction
            setInheritedData(this, interactionInfo);

            trigger('end', event.target, event, this);

            return this;
        },
        cancel: function(event, interactionInfo){
            if(!interactionInfo){
                interactionInfo = event;
            }

            // Update the interaction
            setInheritedData(this, interactionInfo);

            trigger('cancel', event.target, event, this);

            return this;
        },
        getMoveDistance: function(){
            if(this.moves.length > 1){
                var current = this.moves[this.moves.length-1],
                    previous = this.moves[this.moves.length-2];

                return getMoveDistance(current.pageX, current.pageY, previous.pageX, previous.pageY);
            }
        },
        getSpeed: function(){
            if(this.moves.length > 1){
                var current = this.moves[this.moves.length-1],
                    previous = this.moves[this.moves.length-2];

                return this.getMoveDistance() / (current.time - previous.time);
{'fraction_non_alphanumeric': 0.10516445470282747, 'fraction_numerical': 0.005265435660703982, 'mean_word_length': 1.8100932306445074, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1293629', 'n_tokens_mistral': 3679, 'n_tokens_neox': 3520, 'n_words': 871}