index.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@most/scheduler')) :
  3. typeof define === 'function' && define.amd ? define(['exports', '@most/scheduler'], factory) :
  4. (factory((global.mostDomEvent = {}),global.mostScheduler));
  5. }(this, (function (exports,scheduler) { 'use strict';
  6. /** @license MIT License (c) copyright 2015-2016 original author or authors */
  7. /** @author Brian Cavalier */
  8. // domEvent :: (EventTarget t, Event e) => String -> t -> boolean=false -> Stream e
  9. var domEvent = function (event, node, capture) {
  10. if ( capture === void 0 ) capture = false;
  11. return new DomEvent(event, node, capture);
  12. };
  13. var blur = function (node, capture) {
  14. if ( capture === void 0 ) capture = false;
  15. return domEvent('blur', node, capture);
  16. };
  17. var focus = function (node, capture) {
  18. if ( capture === void 0 ) capture = false;
  19. return domEvent('focus', node, capture);
  20. };
  21. var focusin = function (node, capture) {
  22. if ( capture === void 0 ) capture = false;
  23. return domEvent('focusin', node, capture);
  24. };
  25. var focusout = function (node, capture) {
  26. if ( capture === void 0 ) capture = false;
  27. return domEvent('focusout', node, capture);
  28. };
  29. var click = function (node, capture) {
  30. if ( capture === void 0 ) capture = false;
  31. return domEvent('click', node, capture);
  32. };
  33. var dblclick = function (node, capture) {
  34. if ( capture === void 0 ) capture = false;
  35. return domEvent('dblclick', node, capture);
  36. };
  37. var mousedown = function (node, capture) {
  38. if ( capture === void 0 ) capture = false;
  39. return domEvent('mousedown', node, capture);
  40. };
  41. var mouseup = function (node, capture) {
  42. if ( capture === void 0 ) capture = false;
  43. return domEvent('mouseup', node, capture);
  44. };
  45. var mousemove = function (node, capture) {
  46. if ( capture === void 0 ) capture = false;
  47. return domEvent('mousemove', node, capture);
  48. };
  49. var mouseover = function (node, capture) {
  50. if ( capture === void 0 ) capture = false;
  51. return domEvent('mouseover', node, capture);
  52. };
  53. var mouseenter = function (node, capture) {
  54. if ( capture === void 0 ) capture = false;
  55. return domEvent('mouseenter', node, capture);
  56. };
  57. var mouseout = function (node, capture) {
  58. if ( capture === void 0 ) capture = false;
  59. return domEvent('mouseout', node, capture);
  60. };
  61. var mouseleave = function (node, capture) {
  62. if ( capture === void 0 ) capture = false;
  63. return domEvent('mouseleave', node, capture);
  64. };
  65. var change = function (node, capture) {
  66. if ( capture === void 0 ) capture = false;
  67. return domEvent('change', node, capture);
  68. };
  69. var select = function (node, capture) {
  70. if ( capture === void 0 ) capture = false;
  71. return domEvent('select', node, capture);
  72. };
  73. var submit = function (node, capture) {
  74. if ( capture === void 0 ) capture = false;
  75. return domEvent('submit', node, capture);
  76. };
  77. var keydown = function (node, capture) {
  78. if ( capture === void 0 ) capture = false;
  79. return domEvent('keydown', node, capture);
  80. };
  81. var keypress = function (node, capture) {
  82. if ( capture === void 0 ) capture = false;
  83. return domEvent('keypress', node, capture);
  84. };
  85. var keyup = function (node, capture) {
  86. if ( capture === void 0 ) capture = false;
  87. return domEvent('keyup', node, capture);
  88. };
  89. var input = function (node, capture) {
  90. if ( capture === void 0 ) capture = false;
  91. return domEvent('input', node, capture);
  92. };
  93. var contextmenu = function (node, capture) {
  94. if ( capture === void 0 ) capture = false;
  95. return domEvent('contextmenu', node, capture);
  96. };
  97. var resize = function (node, capture) {
  98. if ( capture === void 0 ) capture = false;
  99. return domEvent('resize', node, capture);
  100. };
  101. var scroll = function (node, capture) {
  102. if ( capture === void 0 ) capture = false;
  103. return domEvent('scroll', node, capture);
  104. };
  105. var error = function (node, capture) {
  106. if ( capture === void 0 ) capture = false;
  107. return domEvent('error', node, capture);
  108. };
  109. var hashchange = function (node, capture) {
  110. if ( capture === void 0 ) capture = false;
  111. return domEvent('hashchange', node, capture);
  112. };
  113. var popstate = function (node, capture) {
  114. if ( capture === void 0 ) capture = false;
  115. return domEvent('popstate', node, capture);
  116. };
  117. var load = function (node, capture) {
  118. if ( capture === void 0 ) capture = false;
  119. return domEvent('load', node, capture);
  120. };
  121. var unload = function (node, capture) {
  122. if ( capture === void 0 ) capture = false;
  123. return domEvent('unload', node, capture);
  124. };
  125. var pointerdown = function (node, capture) {
  126. if ( capture === void 0 ) capture = false;
  127. return domEvent('pointerdown', node, capture);
  128. };
  129. var pointerup = function (node, capture) {
  130. if ( capture === void 0 ) capture = false;
  131. return domEvent('pointerup', node, capture);
  132. };
  133. var pointermove = function (node, capture) {
  134. if ( capture === void 0 ) capture = false;
  135. return domEvent('pointermove', node, capture);
  136. };
  137. var pointerover = function (node, capture) {
  138. if ( capture === void 0 ) capture = false;
  139. return domEvent('pointerover', node, capture);
  140. };
  141. var pointerenter = function (node, capture) {
  142. if ( capture === void 0 ) capture = false;
  143. return domEvent('pointerenter', node, capture);
  144. };
  145. var pointerout = function (node, capture) {
  146. if ( capture === void 0 ) capture = false;
  147. return domEvent('pointerout', node, capture);
  148. };
  149. var pointerleave = function (node, capture) {
  150. if ( capture === void 0 ) capture = false;
  151. return domEvent('pointerleave', node, capture);
  152. };
  153. var touchstart = function (node, capture) {
  154. if ( capture === void 0 ) capture = false;
  155. return domEvent('touchstart', node, capture);
  156. };
  157. var touchend = function (node, capture) {
  158. if ( capture === void 0 ) capture = false;
  159. return domEvent('touchend', node, capture);
  160. };
  161. var touchmove = function (node, capture) {
  162. if ( capture === void 0 ) capture = false;
  163. return domEvent('touchmove', node, capture);
  164. };
  165. var touchcancel = function (node, capture) {
  166. if ( capture === void 0 ) capture = false;
  167. return domEvent('touchcancel', node, capture);
  168. };
  169. var DomEvent = function DomEvent (event, node, capture) {
  170. this.event = event;
  171. this.node = node;
  172. this.capture = capture;
  173. };
  174. DomEvent.prototype.run = function run (sink, scheduler$$1) {
  175. var this$1 = this;
  176. var send = function (e) { return tryEvent(scheduler.currentTime(scheduler$$1), e, sink); };
  177. var dispose = function () { return this$1.node.removeEventListener(this$1.event, send, this$1.capture); };
  178. this.node.addEventListener(this.event, send, this.capture);
  179. return { dispose: dispose }
  180. };
  181. function tryEvent (t, x, sink) {
  182. try {
  183. sink.event(t, x);
  184. } catch (e) {
  185. sink.error(t, e);
  186. }
  187. }
  188. exports.domEvent = domEvent;
  189. exports.blur = blur;
  190. exports.focus = focus;
  191. exports.focusin = focusin;
  192. exports.focusout = focusout;
  193. exports.click = click;
  194. exports.dblclick = dblclick;
  195. exports.mousedown = mousedown;
  196. exports.mouseup = mouseup;
  197. exports.mousemove = mousemove;
  198. exports.mouseover = mouseover;
  199. exports.mouseenter = mouseenter;
  200. exports.mouseout = mouseout;
  201. exports.mouseleave = mouseleave;
  202. exports.change = change;
  203. exports.select = select;
  204. exports.submit = submit;
  205. exports.keydown = keydown;
  206. exports.keypress = keypress;
  207. exports.keyup = keyup;
  208. exports.input = input;
  209. exports.contextmenu = contextmenu;
  210. exports.resize = resize;
  211. exports.scroll = scroll;
  212. exports.error = error;
  213. exports.hashchange = hashchange;
  214. exports.popstate = popstate;
  215. exports.load = load;
  216. exports.unload = unload;
  217. exports.pointerdown = pointerdown;
  218. exports.pointerup = pointerup;
  219. exports.pointermove = pointermove;
  220. exports.pointerover = pointerover;
  221. exports.pointerenter = pointerenter;
  222. exports.pointerout = pointerout;
  223. exports.pointerleave = pointerleave;
  224. exports.touchstart = touchstart;
  225. exports.touchend = touchend;
  226. exports.touchmove = touchmove;
  227. exports.touchcancel = touchcancel;
  228. Object.defineProperty(exports, '__esModule', { value: true });
  229. })));
  230. //# sourceMappingURL=index.js.map