Last active
December 17, 2015 23:49
-
-
Save imeckler/5692041 to your computer and use it in GitHub Desktop.
Elm runtime patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Elm.Native.EltMouse = function(elm){ | |
'use strict'; | |
elm.Native = elm.Native || {}; | |
if (elm.Native.EltMouse) return elm.Native.EltMouse; | |
var Utils = Elm.Native.Utils(elm); | |
function EltClicks(input) { | |
this.id = Utils.guid(); | |
this.value = false; | |
this.kids = []; | |
var self = this; | |
var oldElt = input.value; | |
var down = function(e) { | |
self.value = true; | |
} | |
var up = function(e) { | |
self.value = false; | |
} | |
this.recv = function(timestep, changed, parentID) { | |
if (changed) { | |
oldElt.removeEventListener('mousedown', down); | |
oldElt.removeEventListener('mouseup' , up); | |
input.value.addEventListener('mousedown', down); | |
input.value.addEventListener('mouseup', up); | |
oldElt = input.value; | |
} | |
}; | |
input.kids.push(this); | |
} | |
function eltClicks(eltSignal) { | |
return new EltClicks(eltSignal); | |
} | |
return elm.Native.EltMouse = { | |
eltClicks: eltClicks | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment