JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/luciferous/cats/gh-pages/dist/cats.min.js"></script>
JavaScript
var Cont = cats.monad.Cont;
var Monad = cats.monad.Monad;
var el = document.createElement("div");
document.body.appendChild(el);
el.style.border = "1px solid black";
el.style.position = "absolute";
el.style.height = "20px";
el.style.width = "20px";
function move(down, move) {
var x = move.clientX - (down.offsetX || down.layerX),
y = move.clientY - (down.offsetY || down.layerY);
down.target.style.left = x + "px";
down.target.style.top = y + "px";
}
var drag = function(down) {
return Cont(function(next) {
$(window).on("mousemove", move.bind(null, down));
$(window).on("mouseup", function() {
$(window).off("mousemove mouseup");
});
});
};
var click = function(x) {
return Cont(function(next) {
$(x).mousedown(next);
});
};
var dragdrop = function(x) {
return click(x).then(drag);
};
dragdrop(el).run();