UNPKG

wonder.js

Version:
59 lines (52 loc) 1.78 kB
'use strict'; var Curry = require("bs-platform/lib/js/curry.js"); var Log$WonderLog = require("wonder-log/lib/js/src/Log.js"); var ViewService$Wonderjs = require("../../../../record/main/device/ViewService.js"); var HandleDomEventMainService$Wonderjs = require("./HandleDomEventMainService.js"); function getLocationInView(domEvent, getLocationFunc, state) { var viewRecord = state[/* viewRecord */8]; var match = ViewService$Wonderjs.getCanvas(viewRecord); if (match !== undefined) { var match$1 = ViewService$Wonderjs.getOffset(ViewService$Wonderjs.unsafeGetCanvas(viewRecord)); var match$2 = Curry._2(getLocationFunc, domEvent, state); return /* tuple */[ match$2[0] - match$1[0] | 0, match$2[1] - match$1[1] | 0 ]; } else { return /* tuple */[ 0, 0 ]; } } function getMovementDelta($$location, lastXYTuple, state) { var match = lastXYTuple[0]; var exit = 0; if (match !== undefined) { var match$1 = lastXYTuple[1]; if (match$1 !== undefined) { return /* tuple */[ $$location[0] - match | 0, $$location[1] - match$1 | 0 ]; } else { exit = 1; } } else if (lastXYTuple[1] !== undefined) { exit = 1; } else { return /* tuple */[ 0, 0 ]; } if (exit === 1) { return Log$WonderLog.fatal(Log$WonderLog.buildFatalMessage("getMovementDelta", "lastX, lastY should all be None or all be Some", "", "", "")); } } var preventDefault = HandleDomEventMainService$Wonderjs.preventDefault; exports.getLocationInView = getLocationInView; exports.getMovementDelta = getMovementDelta; exports.preventDefault = preventDefault; /* Log-WonderLog Not a pure module */