<commit_before>var EventEmitter = require('events').EventEmitter
var inherits = require('inherits')
var events = require('dom-events')
var offset = require('mouse-event-offset')

function ClickDrag(element, opt) {
	if (!(this instanceof ClickDrag)) 
		return new ClickDrag(element, opt)
	opt = opt||{}
	EventEmitter.call(this)

	this.enabled = true
	this.element = element
	this._dragging = null

	this._mousedown = mousedown.bind(this)
	this._mousemove = mousemove.bind(this)
	this._mouseup = mouseup.bind(this)
	
	events.on(element, 'mousedown', this._mousedown)

	if (opt.parent instanceof EventEmitter) {
		opt.parent.on('mousemove', this._mousemove)
		opt.parent.on('mouseup', this._mouseup)
	} else {
		var parent = opt.parent || document
		events.on(parent, 'mousemove', this._mousemove)
		events.on(parent, 'mouseup', this._mouseup)
	}
}

inherits(ClickDrag, EventEmitter)

function getOffset(ev, element) {
	return offset(ev, { clientRect: element.getBoundingClientRect() }) 
}

function empty() {
	return { x:0, y: 0 }
}

function delta(start, off) {
	var d = empty()
	d.x = start.x - off.x
	d.y = start.y - off.y
	return d
}

function mousedown(ev) {
	if (!this.enabled) 
		return

	if (this._dragging === null) {<commit_msg>allowing clickdrag to be disposed<commit_after>var EventEmitter = require('events').EventEmitter
var inherits = require('inherits')
var events = require('dom-events')
var offset = require('mouse-event-offset')

function ClickDrag(element, opt) {
	if (!(this instanceof ClickDrag)) 
		return new ClickDrag(element, opt)
	opt = opt||{}
	EventEmitter.call(this)

	this.enabled = true
	this.element = element
	this._dragging = null

	this._mousedown = mousedown.bind(this)
	this._mousemove = mousemove.bind(this)
	this._mouseup = mouseup.bind(this)

	events.on(element, 'mousedown', this._mousedown)


	if (opt.parent instanceof EventEmitter) {
		opt.parent.on('mousemove', this._mousemove)
		opt.parent.on('mouseup', this._mouseup)
	} else {
		opt.parent = opt.parent || document

		events.on(opt.parent, 'mousemove', this._mousemove)
		events.on(opt.parent, 'mouseup', this._mouseup)
	}
	this._parent = opt.parent
}

inherits(ClickDrag, EventEmitter)

ClickDrag.prototype.dispose = function() {
	if (this._parent instanceof EventEmitter) {
		this._parent.off('mousemove', this._mousemove)
		this._parent.off('mouseup', this._mouseup)
	} else {
		events.off(this._parent, 'mousemove', this._mousemove)
		events.off(this._parent, 'mouseup', this._mouseup)
	}

	if (this.element && this.element.parentNode) 
		this.element.parentNode.removeChild(this.element)
	this.element = null
}

function getOffset(ev, element) {
	return offset(ev, { clientRect: element.getBoundingClientRect() }) 
}

function empty() {
	return { x:0, y: 0 }
}

function delta(start, off) {
	var d = empty()
	d.x = start.x - off.x
	d.y = start.y - off.y
	return d
}

function mousedown(ev) {
	if (!this.enabled) 
		return

	if (this._dragging === null) {
{'fraction_non_alphanumeric': 0.14372675008454514, 'fraction_numerical': 0.0013527223537368955, 'mean_word_length': 4.570621468926554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '543730', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1028, 'n_words': 222}