index.es.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. import { currentTime } from '@most/scheduler';
  2. /** @license MIT License (c) copyright 2015-2016 original author or authors */
  3. /** @author Brian Cavalier */
  4. // domEvent :: (EventTarget t, Event e) => String -> t -> boolean=false -> Stream e
  5. var domEvent = function (event, node, capture) {
  6. if ( capture === void 0 ) capture = false;
  7. return new DomEvent(event, node, capture);
  8. };
  9. var blur = function (node, capture) {
  10. if ( capture === void 0 ) capture = false;
  11. return domEvent('blur', node, capture);
  12. };
  13. var focus = function (node, capture) {
  14. if ( capture === void 0 ) capture = false;
  15. return domEvent('focus', node, capture);
  16. };
  17. var focusin = function (node, capture) {
  18. if ( capture === void 0 ) capture = false;
  19. return domEvent('focusin', node, capture);
  20. };
  21. var focusout = function (node, capture) {
  22. if ( capture === void 0 ) capture = false;
  23. return domEvent('focusout', node, capture);
  24. };
  25. var click = function (node, capture) {
  26. if ( capture === void 0 ) capture = false;
  27. return domEvent('click', node, capture);
  28. };
  29. var dblclick = function (node, capture) {
  30. if ( capture === void 0 ) capture = false;
  31. return domEvent('dblclick', node, capture);
  32. };
  33. var mousedown = function (node, capture) {
  34. if ( capture === void 0 ) capture = false;
  35. return domEvent('mousedown', node, capture);
  36. };
  37. var mouseup = function (node, capture) {
  38. if ( capture === void 0 ) capture = false;
  39. return domEvent('mouseup', node, capture);
  40. };
  41. var mousemove = function (node, capture) {
  42. if ( capture === void 0 ) capture = false;
  43. return domEvent('mousemove', node, capture);
  44. };
  45. var mouseover = function (node, capture) {
  46. if ( capture === void 0 ) capture = false;
  47. return domEvent('mouseover', node, capture);
  48. };
  49. var mouseenter = function (node, capture) {
  50. if ( capture === void 0 ) capture = false;
  51. return domEvent('mouseenter', node, capture);
  52. };
  53. var mouseout = function (node, capture) {
  54. if ( capture === void 0 ) capture = false;
  55. return domEvent('mouseout', node, capture);
  56. };
  57. var mouseleave = function (node, capture) {
  58. if ( capture === void 0 ) capture = false;
  59. return domEvent('mouseleave', node, capture);
  60. };
  61. var change = function (node, capture) {
  62. if ( capture === void 0 ) capture = false;
  63. return domEvent('change', node, capture);
  64. };
  65. var select = function (node, capture) {
  66. if ( capture === void 0 ) capture = false;
  67. return domEvent('select', node, capture);
  68. };
  69. var submit = function (node, capture) {
  70. if ( capture === void 0 ) capture = false;
  71. return domEvent('submit', node, capture);
  72. };
  73. var keydown = function (node, capture) {
  74. if ( capture === void 0 ) capture = false;
  75. return domEvent('keydown', node, capture);
  76. };
  77. var keypress = function (node, capture) {
  78. if ( capture === void 0 ) capture = false;
  79. return domEvent('keypress', node, capture);
  80. };
  81. var keyup = function (node, capture) {
  82. if ( capture === void 0 ) capture = false;
  83. return domEvent('keyup', node, capture);
  84. };
  85. var input = function (node, capture) {
  86. if ( capture === void 0 ) capture = false;
  87. return domEvent('input', node, capture);
  88. };
  89. var contextmenu = function (node, capture) {
  90. if ( capture === void 0 ) capture = false;
  91. return domEvent('contextmenu', node, capture);
  92. };
  93. var resize = function (node, capture) {
  94. if ( capture === void 0 ) capture = false;
  95. return domEvent('resize', node, capture);
  96. };
  97. var scroll = function (node, capture) {
  98. if ( capture === void 0 ) capture = false;
  99. return domEvent('scroll', node, capture);
  100. };
  101. var error = function (node, capture) {
  102. if ( capture === void 0 ) capture = false;
  103. return domEvent('error', node, capture);
  104. };
  105. var hashchange = function (node, capture) {
  106. if ( capture === void 0 ) capture = false;
  107. return domEvent('hashchange', node, capture);
  108. };
  109. var popstate = function (node, capture) {
  110. if ( capture === void 0 ) capture = false;
  111. return domEvent('popstate', node, capture);
  112. };
  113. var load = function (node, capture) {
  114. if ( capture === void 0 ) capture = false;
  115. return domEvent('load', node, capture);
  116. };
  117. var unload = function (node, capture) {
  118. if ( capture === void 0 ) capture = false;
  119. return domEvent('unload', node, capture);
  120. };
  121. var pointerdown = function (node, capture) {
  122. if ( capture === void 0 ) capture = false;
  123. return domEvent('pointerdown', node, capture);
  124. };
  125. var pointerup = function (node, capture) {
  126. if ( capture === void 0 ) capture = false;
  127. return domEvent('pointerup', node, capture);
  128. };
  129. var pointermove = function (node, capture) {
  130. if ( capture === void 0 ) capture = false;
  131. return domEvent('pointermove', node, capture);
  132. };
  133. var pointerover = function (node, capture) {
  134. if ( capture === void 0 ) capture = false;
  135. return domEvent('pointerover', node, capture);
  136. };
  137. var pointerenter = function (node, capture) {
  138. if ( capture === void 0 ) capture = false;
  139. return domEvent('pointerenter', node, capture);
  140. };
  141. var pointerout = function (node, capture) {
  142. if ( capture === void 0 ) capture = false;
  143. return domEvent('pointerout', node, capture);
  144. };
  145. var pointerleave = function (node, capture) {
  146. if ( capture === void 0 ) capture = false;
  147. return domEvent('pointerleave', node, capture);
  148. };
  149. var touchstart = function (node, capture) {
  150. if ( capture === void 0 ) capture = false;
  151. return domEvent('touchstart', node, capture);
  152. };
  153. var touchend = function (node, capture) {
  154. if ( capture === void 0 ) capture = false;
  155. return domEvent('touchend', node, capture);
  156. };
  157. var touchmove = function (node, capture) {
  158. if ( capture === void 0 ) capture = false;
  159. return domEvent('touchmove', node, capture);
  160. };
  161. var touchcancel = function (node, capture) {
  162. if ( capture === void 0 ) capture = false;
  163. return domEvent('touchcancel', node, capture);
  164. };
  165. var DomEvent = function DomEvent (event, node, capture) {
  166. this.event = event;
  167. this.node = node;
  168. this.capture = capture;
  169. };
  170. DomEvent.prototype.run = function run (sink, scheduler$$1) {
  171. var this$1 = this;
  172. var send = function (e) { return tryEvent(currentTime(scheduler$$1), e, sink); };
  173. var dispose = function () { return this$1.node.removeEventListener(this$1.event, send, this$1.capture); };
  174. this.node.addEventListener(this.event, send, this.capture);
  175. return { dispose: dispose }
  176. };
  177. function tryEvent (t, x, sink) {
  178. try {
  179. sink.event(t, x);
  180. } catch (e) {
  181. sink.error(t, e);
  182. }
  183. }
  184. export { domEvent, blur, focus, focusin, focusout, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseenter, mouseout, mouseleave, change, select, submit, keydown, keypress, keyup, input, contextmenu, resize, scroll, error, hashchange, popstate, load, unload, pointerdown, pointerup, pointermove, pointerover, pointerenter, pointerout, pointerleave, touchstart, touchend, touchmove, touchcancel };
  185. //# sourceMappingURL=index.es.js.map