@enact/ui 3.4.9-experimental-3 → 3.4.9-experimental-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (464) hide show
  1. package/{build/A11yDecorator → A11yDecorator}/A11yDecorator.d.ts +0 -0
  2. package/A11yDecorator/A11yDecorator.js +79 -75
  3. package/A11yDecorator/tests/A11yDecorator-specs.js +90 -128
  4. package/AnnounceDecorator/Announce.js +136 -80
  5. package/{build/AnnounceDecorator → AnnounceDecorator}/AnnounceDecorator.d.ts +0 -0
  6. package/AnnounceDecorator/AnnounceDecorator.js +68 -53
  7. package/AnnounceDecorator/tests/Announce-specs.js +29 -35
  8. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +34 -36
  9. package/AnnounceDecorator/tests/useAnnounce-specs.js +56 -63
  10. package/AnnounceDecorator/useAnnounce.js +29 -18
  11. package/{build/BodyText → BodyText}/BodyText.d.ts +0 -0
  12. package/BodyText/BodyText.js +108 -96
  13. package/{build/BodyText → BodyText}/BodyText.module.css +0 -0
  14. package/BodyText/tests/BodyText-specs.js +67 -76
  15. package/{build/Button → Button}/Button.d.ts +0 -0
  16. package/Button/Button.js +236 -215
  17. package/{build/Button → Button}/Button.module.css +0 -0
  18. package/CHANGELOG.md +18 -0
  19. package/{build/Cancelable → Cancelable}/Cancelable.d.ts +0 -0
  20. package/Cancelable/Cancelable.js +213 -184
  21. package/Cancelable/cancelHandler.js +36 -29
  22. package/Cancelable/modalHandler.js +35 -23
  23. package/Cancelable/tests/Cancelable-specs.js +289 -381
  24. package/{build/Changeable → Changeable}/Changeable.d.ts +0 -0
  25. package/Changeable/Changeable.js +137 -161
  26. package/Changeable/tests/Changeable-specs.js +262 -327
  27. package/{build/ComponentOverride → ComponentOverride}/ComponentOverride.d.ts +0 -0
  28. package/ComponentOverride/ComponentOverride.js +21 -24
  29. package/FloatingLayer/FloatingLayer.js +310 -261
  30. package/FloatingLayer/FloatingLayerDecorator.js +150 -99
  31. package/FloatingLayer/Scrim.js +167 -99
  32. package/{build/FloatingLayer → FloatingLayer}/Scrim.module.css +0 -0
  33. package/FloatingLayer/index.js +39 -12
  34. package/FloatingLayer/tests/FloatingLayer-specs.js +24 -27
  35. package/FloatingLayer/tests/Scrim-specs.js +21 -24
  36. package/FloatingLayer/useFloatingLayer.js +46 -18
  37. package/{build/ForwardRef → ForwardRef}/ForwardRef.d.ts +0 -0
  38. package/ForwardRef/ForwardRef.js +35 -34
  39. package/{build/GridListImageItem → GridListImageItem}/GridListImageItem.d.ts +0 -0
  40. package/GridListImageItem/GridListImageItem.js +244 -212
  41. package/{build/GridListImageItem → GridListImageItem}/GridListImageItem.module.css +0 -0
  42. package/{build/Group → Group}/Group.d.ts +0 -0
  43. package/Group/Group.js +186 -168
  44. package/Group/GroupItem.js +83 -79
  45. package/Group/tests/Group-specs.js +128 -164
  46. package/{build/Heading → Heading}/Heading.d.ts +0 -0
  47. package/Heading/Heading.js +146 -128
  48. package/{build/Heading → Heading}/Heading.module.css +0 -0
  49. package/Heading/tests/Heading-specs.js +46 -54
  50. package/{build/Icon → Icon}/Icon.d.ts +0 -0
  51. package/Icon/Icon.js +200 -189
  52. package/{build/Icon → Icon}/Icon.module.css +0 -0
  53. package/Icon/tests/Icon-specs.js +92 -126
  54. package/{build/IconButton → IconButton}/IconButton.d.ts +0 -0
  55. package/IconButton/IconButton.js +213 -181
  56. package/{build/IconButton → IconButton}/IconButton.module.css +0 -0
  57. package/{build/Image → Image}/Image.d.ts +0 -0
  58. package/Image/Image.js +186 -151
  59. package/{build/Image → Image}/Image.module.css +0 -0
  60. package/Image/tests/Image-specs.js +49 -51
  61. package/{build/ImageItem → ImageItem}/ImageItem.d.ts +0 -0
  62. package/ImageItem/ImageItem.js +165 -149
  63. package/{build/ImageItem → ImageItem}/ImageItem.module.css +0 -0
  64. package/ImageItem/tests/ImageItem-specs.js +128 -161
  65. package/{build/Item → Item}/Item.d.ts +0 -0
  66. package/Item/Item.js +131 -121
  67. package/{build/Item → Item}/Item.module.css +0 -0
  68. package/Item/tests/Item-specs.js +71 -88
  69. package/{build/LabeledIcon → LabeledIcon}/LabeledIcon.d.ts +0 -0
  70. package/LabeledIcon/LabeledIcon.js +235 -216
  71. package/{build/LabeledIcon → LabeledIcon}/LabeledIcon.module.css +0 -0
  72. package/LabeledIcon/tests/LabeledIcon-specs.js +49 -58
  73. package/Layout/Cell.js +181 -146
  74. package/{build/Layout → Layout}/Layout.d.ts +0 -0
  75. package/Layout/Layout.js +193 -282
  76. package/{build/Layout → Layout}/Layout.module.css +0 -0
  77. package/Layout/tests/Layout-specs.js +102 -109
  78. package/{build/Marquee → Marquee}/Marquee.module.css +0 -0
  79. package/Marquee/MarqueeBase.js +275 -240
  80. package/Marquee/MarqueeController.js +327 -292
  81. package/Marquee/MarqueeDecorator.js +990 -898
  82. package/{build/Marquee → Marquee}/index.d.ts +0 -0
  83. package/Marquee/index.js +39 -14
  84. package/Marquee/tests/Marquee-specs.js +274 -382
  85. package/{build/Measurable → Measurable}/Measurable.d.ts +0 -0
  86. package/Measurable/Measurable.js +133 -100
  87. package/{build/Media → Media}/Media.d.ts +0 -0
  88. package/Media/Media.js +317 -254
  89. package/Placeholder/PlaceholderControllerDecorator.js +188 -133
  90. package/Placeholder/PlaceholderDecorator.js +147 -95
  91. package/{build/Placeholder → Placeholder}/index.d.ts +0 -0
  92. package/Placeholder/index.js +27 -9
  93. package/{build/ProgressBar → ProgressBar}/ProgressBar.d.ts +0 -0
  94. package/ProgressBar/ProgressBar.js +183 -173
  95. package/{build/ProgressBar → ProgressBar}/ProgressBar.module.css +0 -0
  96. package/ProgressBar/tests/ProgressBar-specs.js +80 -109
  97. package/RadioDecorator/RadioControllerDecorator.js +104 -54
  98. package/{build/RadioDecorator → RadioDecorator}/RadioDecorator.d.ts +0 -0
  99. package/RadioDecorator/RadioDecorator.js +176 -117
  100. package/RadioDecorator/tests/RadioDecorator-specs.js +155 -166
  101. package/{build/Repeater → Repeater}/Repeater.d.ts +0 -0
  102. package/Repeater/Repeater.js +157 -133
  103. package/Repeater/tests/Repeater-specs.js +136 -155
  104. package/{build/Resizable → Resizable}/Resizable.d.ts +0 -0
  105. package/Resizable/Resizable.js +145 -101
  106. package/Routable/Link.js +65 -61
  107. package/{build/Routable → Routable}/Routable.d.ts +0 -0
  108. package/Routable/Routable.js +148 -109
  109. package/Routable/Route.js +37 -27
  110. package/Routable/Router.js +236 -171
  111. package/Routable/tests/Router-specs.js +194 -196
  112. package/Routable/util.js +78 -68
  113. package/Scrollable/ScrollAnimator.js +138 -112
  114. package/Scrollable/ScrollThumb.js +52 -42
  115. package/{build/Scrollable → Scrollable}/ScrollThumb.module.css +0 -0
  116. package/{build/Scrollable → Scrollable}/Scrollable.d.ts +0 -0
  117. package/Scrollable/Scrollable.js +1591 -1443
  118. package/{build/Scrollable → Scrollable}/Scrollable.module.css +0 -0
  119. package/Scrollable/ScrollableNative.js +1599 -1445
  120. package/Scrollable/Scrollbar.js +312 -221
  121. package/{build/Scrollable → Scrollable}/Scrollbar.module.css +0 -0
  122. package/{build/Scroller → Scroller}/Scroller.d.ts +0 -0
  123. package/Scroller/Scroller.js +249 -242
  124. package/{build/Scroller → Scroller}/Scroller.module.css +0 -0
  125. package/Scroller/ScrollerBasic.js +311 -230
  126. package/{build/Scroller → Scroller}/UiScroller.module.css +0 -0
  127. package/Scroller/UiScrollerBase.js +253 -184
  128. package/{build/Skinnable → Skinnable}/Skinnable.d.ts +0 -0
  129. package/Skinnable/Skinnable.js +182 -172
  130. package/Skinnable/tests/Skinnable-specs.js +388 -416
  131. package/Skinnable/tests/useSkins-specs.js +290 -281
  132. package/Skinnable/tests/util-specs.js +107 -113
  133. package/Skinnable/useSkins.js +51 -28
  134. package/Skinnable/util.js +80 -75
  135. package/Slider/Knob.js +85 -71
  136. package/Slider/PositionDecorator.js +232 -162
  137. package/{build/Slider → Slider}/Slider.d.ts +0 -0
  138. package/Slider/Slider.js +331 -312
  139. package/{build/Slider → Slider}/Slider.module.css +0 -0
  140. package/Slider/utils.js +16 -11
  141. package/{build/SlotItem → SlotItem}/SlotItem.d.ts +0 -0
  142. package/SlotItem/SlotItem.js +199 -179
  143. package/{build/SlotItem → SlotItem}/SlotItem.module.css +0 -0
  144. package/{build/Slottable → Slottable}/Slottable.d.ts +0 -0
  145. package/Slottable/Slottable.js +62 -48
  146. package/Slottable/tests/Slottable-specs.js +232 -284
  147. package/Slottable/tests/useSlots-specs.js +277 -313
  148. package/Slottable/useSlots.js +113 -90
  149. package/{build/Spinner → Spinner}/Spinner.d.ts +0 -0
  150. package/Spinner/Spinner.js +213 -178
  151. package/{build/Spinner → Spinner}/Spinner.module.css +0 -0
  152. package/Spinner/tests/Spinner-specs.js +61 -77
  153. package/{build/ToggleIcon → ToggleIcon}/ToggleIcon.d.ts +0 -0
  154. package/ToggleIcon/ToggleIcon.js +134 -123
  155. package/{build/ToggleIcon → ToggleIcon}/ToggleIcon.module.css +0 -0
  156. package/ToggleIcon/tests/ToggleIcon-specs.js +52 -71
  157. package/{build/ToggleItem → ToggleItem}/ToggleItem.d.ts +0 -0
  158. package/ToggleItem/ToggleItem.js +263 -264
  159. package/{build/ToggleItem → ToggleItem}/ToggleItem.module.css +0 -0
  160. package/ToggleItem/tests/ToggleItem-specs.js +87 -87
  161. package/Toggleable/Toggle.js +70 -43
  162. package/{build/Toggleable → Toggleable}/Toggleable.d.ts +0 -0
  163. package/Toggleable/Toggleable.js +219 -244
  164. package/Toggleable/tests/Toggleable-specs.js +416 -549
  165. package/Toggleable/useToggle.js +50 -24
  166. package/Touchable/ClickAllow.js +67 -49
  167. package/Touchable/Drag.js +199 -170
  168. package/Touchable/Flick.js +152 -122
  169. package/Touchable/Hold.js +259 -214
  170. package/{build/Touchable → Touchable}/Touchable.d.ts +0 -0
  171. package/Touchable/Touchable.js +643 -651
  172. package/Touchable/config.js +63 -44
  173. package/Touchable/state.js +31 -14
  174. package/Touchable/tests/Touchable-specs.js +462 -526
  175. package/{build/Transition → Transition}/Transition.d.ts +0 -0
  176. package/Transition/Transition.js +606 -553
  177. package/{build/Transition → Transition}/Transition.module.css +0 -0
  178. package/Transition/tests/Transition-specs.js +123 -138
  179. package/ViewManager/Arranger.js +82 -40
  180. package/ViewManager/TransitionGroup.js +502 -419
  181. package/ViewManager/View.js +383 -298
  182. package/{build/ViewManager → ViewManager}/ViewManager.d.ts +0 -0
  183. package/ViewManager/ViewManager.js +352 -296
  184. package/ViewManager/tests/View-specs.js +176 -275
  185. package/ViewManager/tests/ViewManager-specs.js +524 -471
  186. package/ViewManager/tests/test-utils.js +44 -23
  187. package/{build/VirtualList → VirtualList}/UiVirtualList.module.css +0 -0
  188. package/VirtualList/UiVirtualListBase.js +1381 -1171
  189. package/{build/VirtualList → VirtualList}/VirtualList.d.ts +0 -0
  190. package/VirtualList/VirtualList.js +541 -537
  191. package/{build/VirtualList → VirtualList}/VirtualList.module.css +0 -0
  192. package/VirtualList/VirtualListBase.js +37 -10
  193. package/VirtualList/VirtualListBasic.js +1468 -1241
  194. package/VirtualList/tests/VirtualList-specs.js +314 -345
  195. package/{build/index.d.ts → index.d.ts} +0 -0
  196. package/index.js +1 -0
  197. package/{build/internal → internal}/IdProvider/IdProvider.d.ts +0 -0
  198. package/internal/IdProvider/IdProvider.js +76 -54
  199. package/internal/IdProvider/Provider.js +67 -41
  200. package/internal/IdProvider/tests/useId-specs.js +64 -78
  201. package/internal/IdProvider/useId.js +27 -15
  202. package/{build/internal → internal}/Pure/Pure.d.ts +0 -0
  203. package/internal/Pure/Pure.js +98 -65
  204. package/{build/internal → internal}/localized-fonts/localized-fonts.d.ts +0 -0
  205. package/internal/localized-fonts/localized-fonts.js +179 -159
  206. package/{build/internal → internal}/selection/selection.d.ts +0 -0
  207. package/internal/selection/selection.js +49 -40
  208. package/internal/selection/tests/selection-specs.js +158 -253
  209. package/{build/internal → internal}/validators/validators.d.ts +0 -0
  210. package/internal/validators/validators.js +103 -55
  211. package/package.json +2 -2
  212. package/resolution/ResolutionDecorator.js +150 -97
  213. package/{build/resolution → resolution}/index.d.ts +0 -0
  214. package/resolution/index.js +39 -7
  215. package/resolution/resolution.js +232 -183
  216. package/resolution/tests/ResolutionDecorator-specs.js +42 -48
  217. package/resolution/tests/resolution-specs.js +90 -91
  218. package/useControlledState/tests/useControlledState-specs.js +100 -76
  219. package/{build/useControlledState → useControlledState}/useControlledState.d.ts +0 -0
  220. package/useControlledState/useControlledState.js +56 -38
  221. package/useScroll/ScrollAnimator.js +138 -112
  222. package/useScroll/Scrollbar.js +199 -175
  223. package/{build/useScroll → useScroll}/Scrollbar.module.css +0 -0
  224. package/useScroll/ScrollbarTrack.js +46 -28
  225. package/{build/useScroll → useScroll}/ScrollbarTrack.module.css +0 -0
  226. package/{build/useScroll → useScroll}/useScroll.d.ts +0 -0
  227. package/useScroll/useScroll.js +1714 -1627
  228. package/{build/useScroll → useScroll}/useScroll.module.css +0 -0
  229. package/useScroll/utilDOM.js +62 -55
  230. package/useScroll/utilEvent.js +33 -28
  231. package/BodyText/BodyText.module.less +0 -11
  232. package/Button/Button.module.less +0 -57
  233. package/FloatingLayer/Scrim.module.less +0 -8
  234. package/GridListImageItem/GridListImageItem.module.less +0 -33
  235. package/Heading/Heading.module.less +0 -20
  236. package/Icon/Icon.module.less +0 -38
  237. package/IconButton/IconButton.module.less +0 -18
  238. package/Image/Image.module.less +0 -21
  239. package/ImageItem/ImageItem.module.less +0 -29
  240. package/Item/Item.module.less +0 -14
  241. package/LabeledIcon/LabeledIcon.module.less +0 -45
  242. package/Layout/Layout.module.less +0 -84
  243. package/Marquee/Marquee.module.less +0 -49
  244. package/ProgressBar/ProgressBar.module.less +0 -114
  245. package/Scrollable/ScrollThumb.module.less +0 -46
  246. package/Scrollable/Scrollable.module.less +0 -42
  247. package/Scrollable/Scrollbar.module.less +0 -35
  248. package/Scroller/Scroller.module.less +0 -10
  249. package/Scroller/UiScroller.module.less +0 -10
  250. package/Slider/Slider.module.less +0 -20
  251. package/SlotItem/SlotItem.module.less +0 -19
  252. package/Spinner/Spinner.module.less +0 -52
  253. package/ToggleIcon/ToggleIcon.module.less +0 -14
  254. package/ToggleItem/ToggleItem.module.less +0 -9
  255. package/Transition/Transition.module.less +0 -179
  256. package/VirtualList/UiVirtualList.module.less +0 -31
  257. package/VirtualList/VirtualList.module.less +0 -39
  258. package/build/A11yDecorator/A11yDecorator.js +0 -129
  259. package/build/A11yDecorator/package.json +0 -3
  260. package/build/A11yDecorator/tests/A11yDecorator-specs.js +0 -90
  261. package/build/AnnounceDecorator/Announce.js +0 -172
  262. package/build/AnnounceDecorator/AnnounceDecorator.js +0 -121
  263. package/build/AnnounceDecorator/package.json +0 -3
  264. package/build/AnnounceDecorator/tests/Announce-specs.js +0 -29
  265. package/build/AnnounceDecorator/tests/AnnounceDecorator-specs.js +0 -34
  266. package/build/AnnounceDecorator/tests/useAnnounce-specs.js +0 -56
  267. package/build/AnnounceDecorator/useAnnounce.js +0 -61
  268. package/build/BodyText/BodyText.js +0 -139
  269. package/build/BodyText/package.json +0 -3
  270. package/build/BodyText/tests/BodyText-specs.js +0 -67
  271. package/build/Button/Button.js +0 -283
  272. package/build/Button/package.json +0 -3
  273. package/build/CHANGELOG.md +0 -1089
  274. package/build/Cancelable/Cancelable.js +0 -271
  275. package/build/Cancelable/cancelHandler.js +0 -79
  276. package/build/Cancelable/modalHandler.js +0 -68
  277. package/build/Cancelable/package.json +0 -3
  278. package/build/Cancelable/tests/Cancelable-specs.js +0 -289
  279. package/build/Changeable/Changeable.js +0 -172
  280. package/build/Changeable/package.json +0 -3
  281. package/build/Changeable/tests/Changeable-specs.js +0 -262
  282. package/build/ComponentOverride/ComponentOverride.js +0 -68
  283. package/build/ComponentOverride/package.json +0 -3
  284. package/build/FloatingLayer/FloatingLayer.js +0 -339
  285. package/build/FloatingLayer/FloatingLayerDecorator.js +0 -174
  286. package/build/FloatingLayer/Scrim.js +0 -199
  287. package/build/FloatingLayer/index.js +0 -49
  288. package/build/FloatingLayer/tests/FloatingLayer-specs.js +0 -29
  289. package/build/FloatingLayer/tests/Scrim-specs.js +0 -26
  290. package/build/FloatingLayer/useFloatingLayer.js +0 -53
  291. package/build/ForwardRef/ForwardRef.js +0 -68
  292. package/build/ForwardRef/package.json +0 -3
  293. package/build/GridListImageItem/GridListImageItem.js +0 -257
  294. package/build/GridListImageItem/package.json +0 -3
  295. package/build/Group/Group.js +0 -217
  296. package/build/Group/GroupItem.js +0 -109
  297. package/build/Group/package.json +0 -3
  298. package/build/Group/tests/Group-specs.js +0 -128
  299. package/build/Heading/Heading.js +0 -158
  300. package/build/Heading/package.json +0 -3
  301. package/build/Heading/tests/Heading-specs.js +0 -46
  302. package/build/Icon/Icon.js +0 -234
  303. package/build/Icon/package.json +0 -3
  304. package/build/Icon/tests/Icon-specs.js +0 -92
  305. package/build/IconButton/IconButton.js +0 -252
  306. package/build/IconButton/package.json +0 -3
  307. package/build/Image/Image.js +0 -219
  308. package/build/Image/package.json +0 -3
  309. package/build/Image/tests/Image-specs.js +0 -55
  310. package/build/ImageItem/ImageItem.js +0 -180
  311. package/build/ImageItem/package.json +0 -3
  312. package/build/ImageItem/tests/ImageItem-specs.js +0 -133
  313. package/build/Item/Item.js +0 -166
  314. package/build/Item/package.json +0 -3
  315. package/build/Item/tests/Item-specs.js +0 -77
  316. package/build/LabeledIcon/LabeledIcon.js +0 -287
  317. package/build/LabeledIcon/package.json +0 -3
  318. package/build/LabeledIcon/tests/LabeledIcon-specs.js +0 -49
  319. package/build/Layout/Cell.js +0 -215
  320. package/build/Layout/Layout.js +0 -316
  321. package/build/Layout/package.json +0 -3
  322. package/build/Layout/tests/Layout-specs.js +0 -102
  323. package/build/Marquee/MarqueeBase.js +0 -307
  324. package/build/Marquee/MarqueeController.js +0 -346
  325. package/build/Marquee/MarqueeDecorator.js +0 -1029
  326. package/build/Marquee/index.js +0 -65
  327. package/build/Marquee/package.json +0 -3
  328. package/build/Marquee/tests/Marquee-specs.js +0 -275
  329. package/build/Measurable/Measurable.js +0 -163
  330. package/build/Measurable/package.json +0 -3
  331. package/build/Media/Media.js +0 -389
  332. package/build/Media/package.json +0 -3
  333. package/build/Placeholder/PlaceholderControllerDecorator.js +0 -210
  334. package/build/Placeholder/PlaceholderDecorator.js +0 -171
  335. package/build/Placeholder/index.js +0 -37
  336. package/build/Placeholder/package.json +0 -3
  337. package/build/ProgressBar/ProgressBar.js +0 -200
  338. package/build/ProgressBar/package.json +0 -3
  339. package/build/ProgressBar/tests/ProgressBar-specs.js +0 -80
  340. package/build/README.md +0 -45
  341. package/build/RadioDecorator/RadioControllerDecorator.js +0 -117
  342. package/build/RadioDecorator/RadioDecorator.js +0 -199
  343. package/build/RadioDecorator/package.json +0 -3
  344. package/build/RadioDecorator/tests/RadioDecorator-specs.js +0 -155
  345. package/build/Repeater/Repeater.js +0 -190
  346. package/build/Repeater/package.json +0 -3
  347. package/build/Repeater/tests/Repeater-specs.js +0 -141
  348. package/build/Resizable/Resizable.js +0 -179
  349. package/build/Resizable/package.json +0 -3
  350. package/build/Routable/Link.js +0 -78
  351. package/build/Routable/Routable.js +0 -170
  352. package/build/Routable/Route.js +0 -68
  353. package/build/Routable/Router.js +0 -248
  354. package/build/Routable/package.json +0 -3
  355. package/build/Routable/tests/Router-specs.js +0 -200
  356. package/build/Routable/util.js +0 -90
  357. package/build/Scrollable/ScrollAnimator.js +0 -146
  358. package/build/Scrollable/ScrollThumb.js +0 -63
  359. package/build/Scrollable/Scrollable.js +0 -1612
  360. package/build/Scrollable/ScrollableNative.js +0 -1619
  361. package/build/Scrollable/Scrollbar.js +0 -344
  362. package/build/Scrollable/package.json +0 -3
  363. package/build/Scroller/Scroller.js +0 -291
  364. package/build/Scroller/ScrollerBasic.js +0 -322
  365. package/build/Scroller/UiScrollerBase.js +0 -414
  366. package/build/Scroller/package.json +0 -3
  367. package/build/Skinnable/Skinnable.js +0 -224
  368. package/build/Skinnable/package.json +0 -3
  369. package/build/Skinnable/tests/Skinnable-specs.js +0 -388
  370. package/build/Skinnable/tests/useSkins-specs.js +0 -290
  371. package/build/Skinnable/tests/util-specs.js +0 -120
  372. package/build/Skinnable/useSkins.js +0 -134
  373. package/build/Skinnable/util.js +0 -106
  374. package/build/Slider/Knob.js +0 -100
  375. package/build/Slider/PositionDecorator.js +0 -234
  376. package/build/Slider/Slider.js +0 -380
  377. package/build/Slider/package.json +0 -3
  378. package/build/Slider/utils.js +0 -18
  379. package/build/SlotItem/SlotItem.js +0 -245
  380. package/build/SlotItem/package.json +0 -3
  381. package/build/Slottable/Slottable.js +0 -95
  382. package/build/Slottable/package.json +0 -3
  383. package/build/Slottable/tests/Slottable-specs.js +0 -238
  384. package/build/Slottable/tests/useSlots-specs.js +0 -282
  385. package/build/Slottable/useSlots.js +0 -183
  386. package/build/Spinner/Spinner.js +0 -247
  387. package/build/Spinner/package.json +0 -3
  388. package/build/Spinner/tests/Spinner-specs.js +0 -61
  389. package/build/ToggleIcon/ToggleIcon.js +0 -181
  390. package/build/ToggleIcon/package.json +0 -3
  391. package/build/ToggleIcon/tests/ToggleIcon-specs.js +0 -58
  392. package/build/ToggleItem/ToggleItem.js +0 -306
  393. package/build/ToggleItem/package.json +0 -3
  394. package/build/ToggleItem/tests/ToggleItem-specs.js +0 -100
  395. package/build/Toggleable/Toggle.js +0 -74
  396. package/build/Toggleable/Toggleable.js +0 -250
  397. package/build/Toggleable/package.json +0 -3
  398. package/build/Toggleable/tests/Toggleable-specs.js +0 -421
  399. package/build/Toggleable/useToggle.js +0 -91
  400. package/build/Touchable/ClickAllow.js +0 -78
  401. package/build/Touchable/Drag.js +0 -206
  402. package/build/Touchable/Flick.js +0 -156
  403. package/build/Touchable/Hold.js +0 -262
  404. package/build/Touchable/Touchable.js +0 -661
  405. package/build/Touchable/config.js +0 -147
  406. package/build/Touchable/package.json +0 -3
  407. package/build/Touchable/state.js +0 -36
  408. package/build/Touchable/tests/Touchable-specs.js +0 -470
  409. package/build/Transition/Transition.js +0 -634
  410. package/build/Transition/package.json +0 -3
  411. package/build/Transition/tests/Transition-specs.js +0 -123
  412. package/build/ViewManager/Arranger.js +0 -181
  413. package/build/ViewManager/TransitionGroup.js +0 -547
  414. package/build/ViewManager/View.js +0 -403
  415. package/build/ViewManager/ViewManager.js +0 -386
  416. package/build/ViewManager/package.json +0 -3
  417. package/build/ViewManager/tests/View-specs.js +0 -182
  418. package/build/ViewManager/tests/ViewManager-specs.js +0 -524
  419. package/build/ViewManager/tests/test-utils.js +0 -47
  420. package/build/VirtualList/UiVirtualListBase.js +0 -1566
  421. package/build/VirtualList/VirtualList.js +0 -582
  422. package/build/VirtualList/VirtualListBase.js +0 -37
  423. package/build/VirtualList/VirtualListBasic.js +0 -1503
  424. package/build/VirtualList/package.json +0 -3
  425. package/build/VirtualList/tests/VirtualList-specs.js +0 -314
  426. package/build/index.js +0 -2
  427. package/build/internal/IdProvider/IdProvider.js +0 -99
  428. package/build/internal/IdProvider/Provider.js +0 -67
  429. package/build/internal/IdProvider/package.json +0 -3
  430. package/build/internal/IdProvider/tests/useId-specs.js +0 -64
  431. package/build/internal/IdProvider/useId.js +0 -58
  432. package/build/internal/Pure/Pure.js +0 -133
  433. package/build/internal/Pure/package.json +0 -3
  434. package/build/internal/localized-fonts/localized-fonts.js +0 -272
  435. package/build/internal/localized-fonts/package.json +0 -3
  436. package/build/internal/selection/package.json +0 -3
  437. package/build/internal/selection/selection.js +0 -78
  438. package/build/internal/selection/tests/selection-specs.js +0 -158
  439. package/build/internal/validators/package.json +0 -4
  440. package/build/internal/validators/validators.js +0 -163
  441. package/build/package-lock.json +0 -234
  442. package/build/package.json +0 -39
  443. package/build/resolution/ResolutionDecorator.js +0 -183
  444. package/build/resolution/index.js +0 -47
  445. package/build/resolution/package.json +0 -3
  446. package/build/resolution/resolution.js +0 -529
  447. package/build/resolution/tests/ResolutionDecorator-specs.js +0 -42
  448. package/build/resolution/tests/resolution-specs.js +0 -90
  449. package/build/styles/core.less +0 -91
  450. package/build/styles/mixins.less +0 -444
  451. package/build/styles/variables.less +0 -7
  452. package/build/useControlledState/package.json +0 -3
  453. package/build/useControlledState/tests/useControlledState-specs.js +0 -100
  454. package/build/useControlledState/useControlledState.js +0 -68
  455. package/build/useScroll/ScrollAnimator.js +0 -146
  456. package/build/useScroll/Scrollbar.js +0 -238
  457. package/build/useScroll/ScrollbarTrack.js +0 -62
  458. package/build/useScroll/package.json +0 -3
  459. package/build/useScroll/useScroll.js +0 -1730
  460. package/build/useScroll/utilDOM.js +0 -65
  461. package/build/useScroll/utilEvent.js +0 -39
  462. package/useScroll/Scrollbar.module.less +0 -37
  463. package/useScroll/ScrollbarTrack.module.less +0 -48
  464. package/useScroll/useScroll.module.less +0 -44
@@ -1,52 +1,105 @@
1
- import classNames from 'classnames';
2
- import handle, {forward, forwardWithPrevent} from '@enact/core/handle';
3
- import {is} from '@enact/core/keymap';
4
- import {platform} from '@enact/core/platform';
5
- import Registry from '@enact/core/internal/Registry';
6
- import {Job} from '@enact/core/util';
7
- import PropTypes from 'prop-types';
8
- import clamp from 'ramda/src/clamp';
9
- import React, {Component} from 'react';
10
-
11
- import {ResizeContext} from '../Resizable';
12
- import ri from '../resolution';
13
- import Touchable from '../Touchable';
14
-
15
- import ScrollAnimator from './ScrollAnimator';
16
- import Scrollbar from './Scrollbar';
17
-
18
- import css from './Scrollable.module.less';
19
-
20
- const
21
- constants = {
22
- epsilon: 1,
23
- flickConfig: {maxDuration: null},
24
- isPageDown: is('pageDown'),
25
- isPageUp: is('pageUp'),
26
- nop: () => {},
27
- overscrollTypeNone: 0,
28
- overscrollTypeHold: 1,
29
- overscrollTypeOnce: 2,
30
- overscrollTypeDone: 9,
31
- overscrollVelocityFactor: 300,
32
- scrollStopWaiting: 200,
33
- scrollWheelPageMultiplierForMaxPixel: 0.2 // The ratio of the maximum distance scrolled by wheel to the size of the viewport.
34
- },
35
- {
36
- epsilon,
37
- flickConfig,
38
- nop,
39
- overscrollTypeDone,
40
- overscrollTypeHold,
41
- overscrollTypeNone,
42
- overscrollTypeOnce,
43
- overscrollVelocityFactor,
44
- scrollStopWaiting,
45
- scrollWheelPageMultiplierForMaxPixel
46
- } = constants;
47
-
48
- const TouchableDiv = Touchable('div');
1
+ "use strict";
49
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ScrollableNative = exports.ScrollableBaseNative = exports.constants = exports["default"] = void 0;
7
+
8
+ var _classnames = _interopRequireDefault(require("classnames"));
9
+
10
+ var _handle = _interopRequireWildcard(require("@enact/core/handle"));
11
+
12
+ var _keymap = require("@enact/core/keymap");
13
+
14
+ var _platform = require("@enact/core/platform");
15
+
16
+ var _Registry = _interopRequireDefault(require("@enact/core/internal/Registry"));
17
+
18
+ var _util = require("@enact/core/util");
19
+
20
+ var _propTypes = _interopRequireDefault(require("prop-types"));
21
+
22
+ var _clamp = _interopRequireDefault(require("ramda/src/clamp"));
23
+
24
+ var _react = _interopRequireWildcard(require("react"));
25
+
26
+ var _Resizable = require("../Resizable");
27
+
28
+ var _resolution = _interopRequireDefault(require("../resolution"));
29
+
30
+ var _Touchable = _interopRequireDefault(require("../Touchable"));
31
+
32
+ var _ScrollAnimator = _interopRequireDefault(require("./ScrollAnimator"));
33
+
34
+ var _Scrollbar = _interopRequireDefault(require("./Scrollbar"));
35
+
36
+ var _ScrollableModule = _interopRequireDefault(require("./Scrollable.module.css"));
37
+
38
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
39
+
40
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
41
+
42
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
43
+
44
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
45
+
46
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
47
+
48
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
49
+
50
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
51
+
52
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
53
+
54
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
55
+
56
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
57
+
58
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
59
+
60
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
61
+
62
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
63
+
64
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
65
+
66
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
67
+
68
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
69
+
70
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
71
+
72
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
73
+
74
+ var constants = {
75
+ epsilon: 1,
76
+ flickConfig: {
77
+ maxDuration: null
78
+ },
79
+ isPageDown: (0, _keymap.is)('pageDown'),
80
+ isPageUp: (0, _keymap.is)('pageUp'),
81
+ nop: function nop() {},
82
+ overscrollTypeNone: 0,
83
+ overscrollTypeHold: 1,
84
+ overscrollTypeOnce: 2,
85
+ overscrollTypeDone: 9,
86
+ overscrollVelocityFactor: 300,
87
+ scrollStopWaiting: 200,
88
+ scrollWheelPageMultiplierForMaxPixel: 0.2 // The ratio of the maximum distance scrolled by wheel to the size of the viewport.
89
+
90
+ },
91
+ epsilon = constants.epsilon,
92
+ flickConfig = constants.flickConfig,
93
+ nop = constants.nop,
94
+ overscrollTypeDone = constants.overscrollTypeDone,
95
+ overscrollTypeHold = constants.overscrollTypeHold,
96
+ overscrollTypeNone = constants.overscrollTypeNone,
97
+ overscrollTypeOnce = constants.overscrollTypeOnce,
98
+ overscrollVelocityFactor = constants.overscrollVelocityFactor,
99
+ scrollStopWaiting = constants.scrollStopWaiting,
100
+ scrollWheelPageMultiplierForMaxPixel = constants.scrollWheelPageMultiplierForMaxPixel;
101
+ exports.constants = constants;
102
+ var TouchableDiv = (0, _Touchable["default"])('div');
50
103
  /**
51
104
  * An unstyled native component that passes scrollable behavior information as its render prop's arguments.
52
105
  *
@@ -55,1339 +108,1098 @@ const TouchableDiv = Touchable('div');
55
108
  * @ui
56
109
  * @private
57
110
  */
58
- class ScrollableBaseNative extends Component {
59
- static displayName = 'ui:ScrollableBaseNative';
60
-
61
- static propTypes = /** @lends ui/ScrollableNative.ScrollableNative.prototype */ {
62
- /**
63
- * Render function.
64
- *
65
- * @type {Function}
66
- * @required
67
- * @private
68
- */
69
- containerRenderer: PropTypes.func.isRequired,
70
-
71
- /**
72
- * Called when adding additional event listeners in a themed component.
73
- *
74
- * @type {Function}
75
- * @private
76
- */
77
- addEventListeners: PropTypes.func,
78
-
79
- /**
80
- * Called to execute additional logic in a themed component to show overscroll effect.
81
- *
82
- * @type {Function}
83
- * @private
84
- */
85
- applyOverscrollEffect: PropTypes.func,
86
-
87
- /**
88
- * A callback function that receives a reference to the `scrollTo` feature.
89
- *
90
- * Once received, the `scrollTo` method can be called as an imperative interface.
91
- *
92
- * The `scrollTo` function accepts the following parameters:
93
- * - {position: {x, y}} - Pixel value for x and/or y position
94
- * - {align} - Where the scroll area should be aligned. Values are:
95
- * `'left'`, `'right'`, `'top'`, `'bottom'`,
96
- * `'topleft'`, `'topright'`, `'bottomleft'`, and `'bottomright'`.
97
- * - {index} - Index of specific item. (`0` or positive integer)
98
- * This option is available for only `VirtualList` kind.
99
- * - {node} - Node to scroll into view
100
- * - {animate} - When `true`, scroll occurs with animation. When `false`, no
101
- * animation occurs.
102
- * - {focus} - When `true`, attempts to focus item after scroll. Only valid when scrolling
103
- * by `index` or `node`.
104
- * > Note: Only specify one of: `position`, `align`, `index` or `node`
105
- *
106
- * Example:
107
- * ```
108
- * // If you set cbScrollTo prop like below;
109
- * cbScrollTo: (fn) => {this.scrollTo = fn;}
110
- * // You can simply call like below;
111
- * this.scrollTo({align: 'top'}); // scroll to the top
112
- * ```
113
- *
114
- * @type {Function}
115
- * @public
116
- */
117
- cbScrollTo: PropTypes.func,
118
-
119
- /**
120
- * Called to execute additional logic in a themed component to clear overscroll effect.
121
- *
122
- * @type {Function}
123
- * @private
124
- */
125
- clearOverscrollEffect: PropTypes.func,
126
-
127
- /**
128
- * Client size of the container; valid values are an object that has `clientWidth` and `clientHeight`.
129
- *
130
- * @type {Object}
131
- * @property {Number} clientHeight The client height of the list.
132
- * @property {Number} clientWidth The client width of the list.
133
- * @public
134
- */
135
- clientSize: PropTypes.shape({
136
- clientHeight: PropTypes.number.isRequired,
137
- clientWidth: PropTypes.number.isRequired
138
- }),
139
-
140
- /**
141
- * Direction of the list or the scroller.
142
- *
143
- * `'both'` could be only used for[Scroller]{@link ui/Scroller.Scroller}.
144
- *
145
- * Valid values are:
146
- * * `'both'`,
147
- * * `'horizontal'`, and
148
- * * `'vertical'`.
149
- *
150
- * @type {String}
151
- * @private
152
- */
153
- direction: PropTypes.oneOf(['both', 'horizontal', 'vertical']),
154
-
155
- /**
156
- * Called when resizing window
157
- *
158
- * @type {Function}
159
- * @private
160
- */
161
- handleResizeWindow: PropTypes.func,
162
-
163
- /**
164
- * Specifies how to show horizontal scrollbar.
165
- *
166
- * Valid values are:
167
- * * `'auto'`,
168
- * * `'visible'`, and
169
- * * `'hidden'`.
170
- *
171
- * @type {String}
172
- * @default 'auto'
173
- * @public
174
- */
175
- horizontalScrollbar: PropTypes.oneOf(['auto', 'visible', 'hidden']),
176
-
177
- /**
178
- * Prevents scroll by dragging or flicking on the list or the scroller.
179
- *
180
- * @type {Boolean}
181
- * @default false
182
- * @private
183
- */
184
- noScrollByDrag: PropTypes.bool,
185
-
186
- /**
187
- * Prevents scroll by wheeling on the list or the scroller.
188
- *
189
- * @type {Boolean}
190
- * @default false
191
- * @public
192
- */
193
- noScrollByWheel: PropTypes.bool,
194
-
195
- /**
196
- * Called when flicking with a mouse or a touch screen.
197
- *
198
- * @type {Function}
199
- * @private
200
- */
201
- onFlick: PropTypes.func,
202
-
203
- /**
204
- * Called when pressing a key.
205
- *
206
- * @type {Function}
207
- * @private
208
- */
209
- onKeyDown: PropTypes.func,
210
-
211
- /**
212
- * Called when triggering a mousedown event.
213
- *
214
- * @type {Function}
215
- * @private
216
- */
217
- onMouseDown: PropTypes.func,
218
-
219
- /**
220
- * Called when scrolling.
221
- *
222
- * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
223
- * It is not recommended to set this prop since it can cause performance degradation.
224
- * Use `onScrollStart` or `onScrollStop` instead.
225
- *
226
- * @type {Function}
227
- * @param {Object} event
228
- * @param {Number} event.scrollLeft Scroll left value.
229
- * @param {Number} event.scrollTop Scroll top value.
230
- * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
231
- * @public
232
- */
233
- onScroll: PropTypes.func,
234
-
235
- /**
236
- * Called when scroll starts.
237
- *
238
- * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
239
- * You can get firstVisibleIndex and lastVisibleIndex from VirtualList with `moreInfo`.
240
- *
241
- * Example:
242
- * ```
243
- * onScrollStart = ({scrollLeft, scrollTop, moreInfo}) => {
244
- * const {firstVisibleIndex, lastVisibleIndex} = moreInfo;
245
- * // do something with firstVisibleIndex and lastVisibleIndex
246
- * }
247
- *
248
- * render = () => (
249
- * <VirtualList
250
- * ...
251
- * onScrollStart={this.onScrollStart}
252
- * ...
253
- * />
254
- * )
255
- * ```
256
- *
257
- * @type {Function}
258
- * @param {Object} event
259
- * @param {Number} event.scrollLeft Scroll left value.
260
- * @param {Number} event.scrollTop Scroll top value.
261
- * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
262
- * @public
263
- */
264
- onScrollStart: PropTypes.func,
265
-
266
- /**
267
- * Called when scroll stops.
268
- *
269
- * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
270
- * You can get firstVisibleIndex and lastVisibleIndex from VirtualList with `moreInfo`.
271
- *
272
- * Example:
273
- * ```
274
- * onScrollStop = ({scrollLeft, scrollTop, moreInfo}) => {
275
- * const {firstVisibleIndex, lastVisibleIndex} = moreInfo;
276
- * // do something with firstVisibleIndex and lastVisibleIndex
277
- * }
278
- *
279
- * render = () => (
280
- * <VirtualList
281
- * ...
282
- * onScrollStop={this.onScrollStop}
283
- * ...
284
- * />
285
- * )
286
- * ```
287
- *
288
- * @type {Function}
289
- * @param {Object} event
290
- * @param {Number} event.scrollLeft Scroll left value.
291
- * @param {Number} event.scrollTop Scroll top value.
292
- * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
293
- * @public
294
- */
295
- onScrollStop: PropTypes.func,
296
-
297
- /**
298
- * Called when wheeling.
299
- *
300
- * @type {Function}
301
- * @private
302
- */
303
- onWheel: PropTypes.func,
304
-
305
- /**
306
- * Specifies overscroll effects shows on which type of inputs.
307
- *
308
- * @type {Object}
309
- * @default {drag: false, pageKey: false, wheel: false}
310
- * @private
311
- */
312
- overscrollEffectOn: PropTypes.shape({
313
- drag: PropTypes.bool,
314
- pageKey: PropTypes.bool,
315
- wheel: PropTypes.bool
316
- }),
317
-
318
- /**
319
- * Called when removing additional event listeners in a themed component.
320
- *
321
- * @type {Function}
322
- * @private
323
- */
324
- removeEventListeners: PropTypes.func,
325
-
326
- /**
327
- * Indicates the content's text direction is right-to-left.
328
- *
329
- * @type {Boolean}
330
- * @private
331
- */
332
- rtl: PropTypes.bool,
333
-
334
- /**
335
- * Called to execute additional logic in a themed component after scrolling.
336
- *
337
- * @type {Function}
338
- * @private
339
- */
340
- scrollStopOnScroll: PropTypes.func,
341
-
342
- /**
343
- * Called to execute additional logic in a themed component when scrollTo is called.
344
- *
345
- * @type {Function}
346
- * @private
347
- */
348
- scrollTo: PropTypes.func,
349
-
350
- /**
351
- * Called to execute additional logic in a themed component when scroll starts.
352
- *
353
- * @type {Function}
354
- * @private
355
- */
356
- start: PropTypes.func,
357
-
358
- /**
359
- * Specifies how to show vertical scrollbar.
360
- *
361
- * Valid values are:
362
- * * `'auto'`,
363
- * * `'visible'`, and
364
- * * `'hidden'`.
365
- *
366
- * @type {String}
367
- * @default 'auto'
368
- * @public
369
- */
370
- verticalScrollbar: PropTypes.oneOf(['auto', 'visible', 'hidden'])
371
- };
372
-
373
- static defaultProps = {
374
- cbScrollTo: nop,
375
- horizontalScrollbar: 'auto',
376
- noScrollByDrag: false,
377
- noScrollByWheel: false,
378
- onScroll: nop,
379
- onScrollStart: nop,
380
- onScrollStop: nop,
381
- overscrollEffectOn: {drag: false, pageKey: false, wheel: false},
382
- verticalScrollbar: 'auto'
383
- };
384
-
385
- static contextType = ResizeContext;
386
-
387
- constructor (props) {
388
- super(props);
389
-
390
- this.state = {
391
- remeasure: false,
392
- isHorizontalScrollbarVisible: props.horizontalScrollbar === 'visible',
393
- isVerticalScrollbarVisible: props.verticalScrollbar === 'visible'
394
- };
395
-
396
- this.containerRef = React.createRef();
397
- this.horizontalScrollbarRef = React.createRef();
398
- this.verticalScrollbarRef = React.createRef();
399
-
400
- this.horizontalScrollbarProps = {
401
- ref: this.horizontalScrollbarRef,
402
- vertical: false,
403
- clientSize: props.clientSize
404
- };
405
-
406
- this.verticalScrollbarProps = {
407
- ref: this.verticalScrollbarRef,
408
- vertical: true,
409
- clientSize: props.clientSize
410
- };
411
-
412
- this.overscrollEnabled = !!(props.applyOverscrollEffect);
413
-
414
- // Enable the early bail out of repeated scrolling to the same position
415
- this.animationInfo = null;
416
-
417
- this.resizeRegistry = Registry.create(this.handleResize.bind(this));
418
-
419
- props.cbScrollTo(this.scrollTo);
420
- }
421
-
422
- componentDidMount () {
423
- this.resizeRegistry.parent = this.context;
424
- this.addEventListeners();
425
- this.updateScrollbars();
426
- }
427
-
428
- componentDidUpdate (prevProps, prevState) {
429
- const
430
- {isHorizontalScrollbarVisible, isVerticalScrollbarVisible} = this.state,
431
- {hasDataSizeChanged} = this.childRefCurrent;
432
-
433
- // Need to sync calculated client size if it is different from the real size
434
- if (this.childRefCurrent.syncClientSize) {
435
- // If we actually synced, we need to reset scroll position.
436
- if (this.childRefCurrent.syncClientSize()) {
437
- this.setScrollLeft(0);
438
- this.setScrollTop(0);
439
- }
440
- }
441
-
442
- this.addEventListeners();
443
- if (
444
- hasDataSizeChanged === false &&
445
- (isHorizontalScrollbarVisible && !prevState.isHorizontalScrollbarVisible || isVerticalScrollbarVisible && !prevState.isVerticalScrollbarVisible)
446
- ) {
447
- this.deferScrollTo = false;
448
- this.isUpdatedScrollThumb = this.updateScrollThumbSize();
449
- } else {
450
- this.updateScrollbars();
451
- }
452
-
453
- if (this.scrollToInfo !== null) {
454
- if (!this.deferScrollTo) {
455
- this.scrollTo(this.scrollToInfo);
456
- }
457
- }
458
-
459
- // publish container resize changes
460
- const horizontal = isHorizontalScrollbarVisible !== prevState.isHorizontalScrollbarVisible;
461
- const vertical = isVerticalScrollbarVisible !== prevState.isVerticalScrollbarVisible;
462
- if (horizontal || vertical) {
463
- this.resizeRegistry.notify({});
464
- }
465
- }
466
-
467
- componentWillUnmount () {
468
- this.resizeRegistry.parent = null;
469
- // Before call cancelAnimationFrame, you must send scrollStop Event.
470
- if (this.scrolling) {
471
- this.forwardScrollEvent('onScrollStop', this.getReachedEdgeInfo());
472
- }
473
- this.scrollStopJob.stop();
474
-
475
- this.removeEventListeners();
476
- }
477
-
478
- handleResize (ev) {
479
- if (ev.action === 'invalidateBounds') {
480
- this.enqueueForceUpdate();
481
- }
482
- }
483
-
484
- handleResizeWindow = () => {
485
- // `handleSize` in `ui/resolution.ResolutionDecorator` should be executed first.
486
- setTimeout(() => {
487
- const {handleResizeWindow} = this.props;
488
-
489
- if (handleResizeWindow) {
490
- handleResizeWindow();
491
- }
492
- this.childRefCurrent.containerRef.current.style.scrollBehavior = null;
493
- this.childRefCurrent.scrollToPosition(0, 0);
494
- this.childRefCurrent.containerRef.current.style.scrollBehavior = 'smooth';
495
-
496
- this.enqueueForceUpdate();
497
- });
498
- };
499
-
500
- // TODO: consider replacing forceUpdate() by storing bounds in state rather than a non-
501
- // state member.
502
- enqueueForceUpdate () {
503
- this.childRefCurrent.calculateMetrics(this.childRefCurrent.props);
504
- this.forceUpdate();
505
- }
506
-
507
- // constants
508
- pixelPerLine = 39;
509
- scrollWheelMultiplierForDeltaPixel = 1.5; // The ratio of wheel 'delta' units to pixels scrolled.
510
-
511
- // status
512
- deferScrollTo = true;
513
- isScrollAnimationTargetAccumulated = false;
514
- isUpdatedScrollThumb = false;
515
-
516
- // overscroll
517
- lastInputType = null;
518
- overscrollEnabled = false;
519
- overscrollStatus = {
520
- horizontal: {
521
- before: {type: overscrollTypeNone, ratio: 0},
522
- after: {type: overscrollTypeNone, ratio: 0}
523
- },
524
- vertical: {
525
- before: {type: overscrollTypeNone, ratio: 0},
526
- after: {type: overscrollTypeNone, ratio: 0}
527
- }
528
- };
529
-
530
- // bounds info
531
- bounds = {
532
- clientWidth: 0,
533
- clientHeight: 0,
534
- scrollWidth: 0,
535
- scrollHeight: 0,
536
- maxTop: 0,
537
- maxLeft: 0
538
- };
539
-
540
- // wheel/drag/flick info
541
- wheelDirection = 0;
542
- isDragging = false;
543
- isTouching = false;
544
-
545
- // scroll info
546
- scrolling = false;
547
- scrollLeft = 0;
548
- scrollTop = 0;
549
- scrollToInfo = null;
550
-
551
- // component info
552
- childRefCurrent = null;
553
-
554
- // scroll animator
555
- animator = new ScrollAnimator();
556
-
557
- // event handler for browser native scroll
558
-
559
- getRtlX = (x) => (this.props.rtl ? -x : x);
560
-
561
- onMouseDown = handle(
562
- forwardWithPrevent('onMouseDown'),
563
- this.stop
564
- ).bindAs(this, 'onMouseDown');
565
-
566
- onTouchStart = () => {
567
- this.isTouching = true;
568
- };
569
-
570
- onDragStart = (ev) => {
571
- if (!this.isTouching) {
572
- this.stop();
573
- this.isDragging = true;
574
- }
575
-
576
- // these values are used also for touch inputs
577
- this.dragStartX = this.scrollLeft + this.getRtlX(ev.x);
578
- this.dragStartY = this.scrollTop + ev.y;
579
- };
580
-
581
- onDrag = (ev) => {
582
- const
583
- {direction, overscrollEffectOn} = this.props,
584
- targetX = (direction === 'vertical') ? 0 : this.dragStartX - this.getRtlX(ev.x), // 'horizontal' or 'both'
585
- targetY = (direction === 'horizontal') ? 0 : this.dragStartY - ev.y; // 'vertical' or 'both'
586
-
587
- this.lastInputType = 'drag';
588
-
589
- if (!this.isTouching) {
590
- this.start({targetX, targetY, animate: false, overscrollEffect: overscrollEffectOn.drag});
591
- } else if (this.overscrollEnabled && overscrollEffectOn.drag) {
592
- this.checkAndApplyOverscrollEffectOnDrag(targetX, targetY, overscrollTypeHold);
593
- }
594
- };
595
-
596
- onDragEnd = () => {
597
- this.isDragging = false;
598
-
599
- this.lastInputType = 'drag';
600
-
601
- if (this.flickTarget) {
602
- const
603
- {overscrollEffectOn} = this.props,
604
- {targetX, targetY} = this.flickTarget;
605
-
606
- if (!this.isTouching) {
607
- this.isScrollAnimationTargetAccumulated = false;
608
- this.start({targetX, targetY, overscrollEffect: overscrollEffectOn.drag});
609
- } else if (this.overscrollEnabled && overscrollEffectOn.drag) {
610
- this.checkAndApplyOverscrollEffectOnDrag(targetX, targetY, overscrollTypeOnce);
611
- }
612
- } else if (!this.isTouching) {
613
- this.stop();
614
- }
615
-
616
- if (this.overscrollEnabled) { // not check this.props.overscrollEffectOn.drag for safety
617
- this.clearAllOverscrollEffects();
618
- }
619
- this.isTouching = false;
620
- this.flickTarget = null;
621
- };
622
-
623
- onFlick = (ev) => {
624
- const {direction} = this.props;
625
-
626
- if (!this.isTouching) {
627
- this.flickTarget = this.animator.simulate(
628
- this.scrollLeft,
629
- this.scrollTop,
630
- (direction !== 'vertical') ? this.getRtlX(-ev.velocityX) : 0,
631
- (direction !== 'horizontal') ? -ev.velocityY : 0
632
- );
633
- } else if (this.overscrollEnabled && this.props.overscrollEffectOn.drag) {
634
- this.flickTarget = {
635
- targetX: this.scrollLeft + this.getRtlX(-ev.velocityX) * overscrollVelocityFactor, // 'horizontal' or 'both'
636
- targetY: this.scrollTop + -ev.velocityY * overscrollVelocityFactor // 'vertical' or 'both'
637
- };
638
- }
639
-
640
- if (this.props.onFlick) {
641
- forward('onFlick', ev, this.props);
642
- }
643
- };
644
-
645
- calculateDistanceByWheel (deltaMode, delta, maxPixel) {
646
- if (deltaMode === 0) {
647
- delta = clamp(-maxPixel, maxPixel, ri.scale(delta * this.scrollWheelMultiplierForDeltaPixel));
648
- } else if (deltaMode === 1) { // line; firefox
649
- delta = clamp(-maxPixel, maxPixel, ri.scale(delta * this.pixelPerLine * this.scrollWheelMultiplierForDeltaPixel));
650
- } else if (deltaMode === 2) { // page
651
- delta = delta < 0 ? -maxPixel : maxPixel;
652
- }
653
-
654
- return delta;
655
- }
656
-
657
- /*
658
- * wheel event handler;
659
- * - for horizontal scroll, supports wheel action on any children nodes since web engine cannot support this
660
- * - for vertical scroll, supports wheel action on scrollbars only
661
- */
662
- onWheel = (ev) => {
663
- if (this.isDragging) {
664
- ev.preventDefault();
665
- ev.stopPropagation();
666
- } else {
667
- const
668
- {overscrollEffectOn} = this.props,
669
- overscrollEffectRequired = this.overscrollEnabled && overscrollEffectOn.wheel,
670
- bounds = this.getScrollBounds(),
671
- canScrollHorizontally = this.canScrollHorizontally(bounds),
672
- canScrollVertically = this.canScrollVertically(bounds),
673
- eventDeltaMode = ev.deltaMode,
674
- eventDelta = (-ev.wheelDeltaY || ev.deltaY);
675
- let
676
- delta = 0,
677
- needToHideThumb = false;
678
-
679
- this.lastInputType = 'wheel';
680
-
681
- if (this.props.noScrollByWheel) {
682
- if (canScrollVertically) {
683
- ev.preventDefault();
684
- }
685
-
686
- return;
687
- }
688
-
689
- if (this.props.onWheel) {
690
- forward('onWheel', ev, this.props);
691
- return;
692
- }
693
-
694
- this.showThumb(bounds);
695
-
696
- // FIXME This routine is a temporary support for horizontal wheel scroll.
697
- // FIXME If web engine supports horizontal wheel, this routine should be refined or removed.
698
- if (canScrollVertically) { // This routine handles wheel events on scrollbars for vertical scroll.
699
- if (eventDelta < 0 && this.scrollTop > 0 || eventDelta > 0 && this.scrollTop < bounds.maxTop) {
700
- const {horizontalScrollbarRef, verticalScrollbarRef} = this;
701
-
702
- // Not to check if ev.target is a descendant of a wrapped component which may have a lot of nodes in it.
703
- if ((horizontalScrollbarRef.current && horizontalScrollbarRef.current.getContainerRef().current.contains(ev.target)) ||
704
- (verticalScrollbarRef.current && verticalScrollbarRef.current.getContainerRef().current.contains(ev.target))) {
705
- delta = this.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientHeight * scrollWheelPageMultiplierForMaxPixel);
706
- needToHideThumb = !delta;
707
-
708
- ev.preventDefault();
709
- } else if (overscrollEffectRequired) {
710
- this.checkAndApplyOverscrollEffect('vertical', eventDelta > 0 ? 'after' : 'before', overscrollTypeOnce);
711
- }
712
-
713
- ev.stopPropagation();
714
- } else {
715
- if (overscrollEffectRequired && (eventDelta < 0 && this.scrollTop <= 0 || eventDelta > 0 && this.scrollTop >= bounds.maxTop)) {
716
- this.applyOverscrollEffect('vertical', eventDelta > 0 ? 'after' : 'before', overscrollTypeOnce, 1);
717
- }
718
- needToHideThumb = true;
719
- }
720
- } else if (canScrollHorizontally) { // this routine handles wheel events on any children for horizontal scroll.
721
- if (eventDelta < 0 && this.scrollLeft > 0 || eventDelta > 0 && this.scrollLeft < bounds.maxLeft) {
722
- delta = this.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientWidth * scrollWheelPageMultiplierForMaxPixel);
723
- needToHideThumb = !delta;
724
-
725
- ev.preventDefault();
726
- ev.stopPropagation();
727
- } else {
728
- if (overscrollEffectRequired && (eventDelta < 0 && this.scrollLeft <= 0 || eventDelta > 0 && this.scrollLeft >= bounds.maxLeft)) {
729
- this.applyOverscrollEffect('horizontal', eventDelta > 0 ? 'after' : 'before', overscrollTypeOnce, 1);
730
- }
731
- needToHideThumb = true;
732
- }
733
- }
734
-
735
- if (delta !== 0) {
736
- const direction = Math.sign(delta);
737
- // Not to accumulate scroll position if wheel direction is different from hold direction
738
- if (direction !== this.wheelDirection) {
739
- this.isScrollAnimationTargetAccumulated = false;
740
- this.wheelDirection = direction;
741
- }
742
- this.scrollToAccumulatedTarget(delta, canScrollVertically, overscrollEffectOn.wheel);
743
- }
744
-
745
- if (needToHideThumb) {
746
- this.startHidingThumb();
747
- }
748
- }
749
- };
750
-
751
- onScroll = (ev) => {
752
- let {scrollLeft, scrollTop} = ev.target;
753
-
754
- const
755
- bounds = this.getScrollBounds(),
756
- canScrollHorizontally = this.canScrollHorizontally(bounds);
757
-
758
- if (!this.scrolling) {
759
- this.scrollStartOnScroll();
760
- }
761
-
762
- if (this.props.rtl && canScrollHorizontally) {
763
- scrollLeft = (platform.ios || platform.safari) ? -scrollLeft : bounds.maxLeft - scrollLeft;
764
- }
765
-
766
- if (scrollLeft !== this.scrollLeft) {
767
- this.setScrollLeft(scrollLeft);
768
- }
769
- if (scrollTop !== this.scrollTop) {
770
- this.setScrollTop(scrollTop);
771
- }
772
-
773
- if (this.childRefCurrent.didScroll) {
774
- this.childRefCurrent.didScroll(this.scrollLeft, this.scrollTop);
775
- }
776
- this.forwardScrollEvent('onScroll');
777
- this.scrollStopJob.start();
778
- };
779
-
780
- onKeyDown = (ev) => {
781
- forward('onKeyDown', ev, this.props);
782
- };
783
-
784
- scrollToAccumulatedTarget = (delta, vertical, overscrollEffect) => {
785
- if (!this.isScrollAnimationTargetAccumulated) {
786
- this.accumulatedTargetX = this.scrollLeft;
787
- this.accumulatedTargetY = this.scrollTop;
788
- this.isScrollAnimationTargetAccumulated = true;
789
- }
790
-
791
- if (vertical) {
792
- this.accumulatedTargetY += delta;
793
- } else {
794
- this.accumulatedTargetX += delta;
795
- }
796
-
797
- this.start({targetX: this.accumulatedTargetX, targetY: this.accumulatedTargetY, overscrollEffect});
798
- };
799
-
800
- // overscroll effect
801
-
802
- getEdgeFromPosition = (position, maxPosition) => {
803
- if (position <= 0) {
804
- return 'before';
805
- /* If a scroll size or a client size is not integer,
806
- browser's max scroll position could be smaller than maxPos by 1 pixel.*/
807
- } else if (position >= maxPosition - 1) {
808
- return 'after';
809
- } else {
810
- return null;
811
- }
812
- };
813
-
814
- setOverscrollStatus = (orientation, edge, type, ratio) => {
815
- const status = this.overscrollStatus[orientation][edge];
816
- status.type = type;
817
- status.ratio = ratio;
818
- };
819
-
820
- getOverscrollStatus = (orientation, edge) => (this.overscrollStatus[orientation][edge]);
821
-
822
- calculateOverscrollRatio = (orientation, position) => {
823
- const
824
- bounds = this.getScrollBounds(),
825
- isVertical = (orientation === 'vertical'),
826
- baseSize = isVertical ? bounds.clientHeight : bounds.clientWidth,
827
- maxPos = bounds[isVertical ? 'maxTop' : 'maxLeft'];
828
- let overDistance = 0;
829
-
830
- if (position < 0) {
831
- overDistance = -position;
832
- } else if (position > maxPos) {
833
- overDistance = position - maxPos;
834
- } else {
835
- return 0;
836
- }
837
-
838
- return Math.min(1, 2 * overDistance / baseSize);
839
- };
840
-
841
- applyOverscrollEffect = (orientation, edge, type, ratio) => {
842
- this.props.applyOverscrollEffect(orientation, edge, type, ratio);
843
- this.setOverscrollStatus(orientation, edge, type === overscrollTypeOnce ? overscrollTypeDone : type, ratio);
844
- };
845
-
846
- checkAndApplyOverscrollEffect = (orientation, edge, type, ratio = 1) => {
847
- const
848
- isVertical = (orientation === 'vertical'),
849
- curPos = isVertical ? this.scrollTop : this.scrollLeft,
850
- maxPos = this.getScrollBounds()[isVertical ? 'maxTop' : 'maxLeft'];
851
-
852
- /* If a scroll size or a client size is not integer,
853
- browser's max scroll position could be smaller than maxPos by 1 pixel.*/
854
- if ((edge === 'before' && curPos <= 0) || (edge === 'after' && curPos >= maxPos - 1)) { // Already on the edge
855
- this.applyOverscrollEffect(orientation, edge, type, ratio);
856
- } else {
857
- this.setOverscrollStatus(orientation, edge, type, ratio);
858
- }
859
- };
860
-
861
- clearOverscrollEffect = (orientation, edge) => {
862
- if (this.getOverscrollStatus(orientation, edge).type !== overscrollTypeNone) {
863
- if (this.props.clearOverscrollEffect) {
864
- this.props.clearOverscrollEffect(orientation, edge);
865
- } else {
866
- this.applyOverscrollEffect(orientation, edge, overscrollTypeNone, 0);
867
- }
868
- }
869
- };
870
-
871
- clearAllOverscrollEffects = () => {
872
- ['horizontal', 'vertical'].forEach((orientation) => {
873
- ['before', 'after'].forEach((edge) => {
874
- this.clearOverscrollEffect(orientation, edge);
875
- });
876
- });
877
- };
878
-
879
- applyOverscrollEffectOnDrag = (orientation, edge, targetPosition, type) => {
880
- if (edge) {
881
- const
882
- oppositeEdge = edge === 'before' ? 'after' : 'before',
883
- ratio = this.calculateOverscrollRatio(orientation, targetPosition);
884
-
885
- this.applyOverscrollEffect(orientation, edge, type, ratio);
886
- this.clearOverscrollEffect(orientation, oppositeEdge);
887
- } else {
888
- this.clearOverscrollEffect(orientation, 'before');
889
- this.clearOverscrollEffect(orientation, 'after');
890
- }
891
- };
892
-
893
- checkAndApplyOverscrollEffectOnDrag = (targetX, targetY, type) => {
894
- const bounds = this.getScrollBounds();
895
-
896
- if (this.canScrollHorizontally(bounds)) {
897
- this.applyOverscrollEffectOnDrag('horizontal', this.getEdgeFromPosition(targetX, bounds.maxLeft), targetX, type);
898
- }
899
-
900
- if (this.canScrollVertically(bounds)) {
901
- this.applyOverscrollEffectOnDrag('vertical', this.getEdgeFromPosition(targetY, bounds.maxTop), targetY, type);
902
- }
903
- };
904
-
905
- checkAndApplyOverscrollEffectOnScroll = (orientation) => {
906
- ['before', 'after'].forEach((edge) => {
907
- const {ratio, type} = this.getOverscrollStatus(orientation, edge);
908
-
909
- if (type === overscrollTypeOnce) {
910
- this.checkAndApplyOverscrollEffect(orientation, edge, type, ratio);
911
- }
912
- });
913
- };
914
-
915
- checkAndApplyOverscrollEffectOnStart = (orientation, edge, targetPosition) => {
916
- if (this.isDragging) {
917
- this.applyOverscrollEffectOnDrag(orientation, edge, targetPosition, overscrollTypeHold);
918
- } else if (edge) {
919
- this.checkAndApplyOverscrollEffect(orientation, edge, overscrollTypeOnce);
920
- }
921
- };
922
-
923
- // call scroll callbacks
924
-
925
- forwardScrollEvent (type, reachedEdgeInfo) {
926
- forward(type, {scrollLeft: this.scrollLeft, scrollTop: this.scrollTop, moreInfo: this.getMoreInfo(), reachedEdgeInfo}, this.props);
927
- }
928
-
929
- // call scroll callbacks and update scrollbars for native scroll
930
-
931
- scrollStartOnScroll = () => {
932
- this.scrolling = true;
933
- this.showThumb(this.getScrollBounds());
934
- this.forwardScrollEvent('onScrollStart');
935
- };
936
-
937
- scrollStopOnScroll = () => {
938
- if (this.props.scrollStopOnScroll) {
939
- this.props.scrollStopOnScroll();
940
- }
941
- if (this.overscrollEnabled && !this.isDragging) { // not check this.props.overscrollEffectOn for safety
942
- this.clearAllOverscrollEffects();
943
- }
944
- this.lastInputType = null;
945
- this.isScrollAnimationTargetAccumulated = false;
946
- this.scrolling = false;
947
- this.forwardScrollEvent('onScrollStop', this.getReachedEdgeInfo());
948
- this.startHidingThumb();
949
- };
950
-
951
- scrollStopJob = new Job(this.scrollStopOnScroll, scrollStopWaiting);
952
-
953
- // update scroll position
954
-
955
- setScrollLeft (value) {
956
- const bounds = this.getScrollBounds();
957
-
958
- this.scrollLeft = clamp(0, bounds.maxLeft, value);
959
-
960
- if (this.overscrollEnabled && this.props.overscrollEffectOn[this.lastInputType]) {
961
- this.checkAndApplyOverscrollEffectOnScroll('horizontal');
962
- }
963
-
964
- if (this.state.isHorizontalScrollbarVisible) {
965
- this.updateThumb(this.horizontalScrollbarRef, bounds);
966
- }
967
- }
968
-
969
- setScrollTop (value) {
970
- const bounds = this.getScrollBounds();
971
-
972
- this.scrollTop = clamp(0, bounds.maxTop, value);
973
-
974
- if (this.overscrollEnabled && this.props.overscrollEffectOn[this.lastInputType]) {
975
- this.checkAndApplyOverscrollEffectOnScroll('vertical');
976
- }
977
-
978
- if (this.state.isVerticalScrollbarVisible) {
979
- this.updateThumb(this.verticalScrollbarRef, bounds);
980
- }
981
- }
982
-
983
- getReachedEdgeInfo = () => {
984
- const
985
- bounds = this.getScrollBounds(),
986
- reachedEdgeInfo = {bottom: false, left: false, right: false, top: false};
987
-
988
- if (this.canScrollHorizontally(bounds)) {
989
- const
990
- rtl = this.props.rtl,
991
- edge = this.getEdgeFromPosition(this.scrollLeft, bounds.maxLeft);
992
-
993
- if (edge) { // if edge is null, no need to check which edge is reached.
994
- if ((edge === 'before' && !rtl) || (edge === 'after' && rtl)) {
995
- reachedEdgeInfo.left = true;
996
- } else {
997
- reachedEdgeInfo.right = true;
998
- }
999
- }
1000
- }
1001
-
1002
- if (this.canScrollVertically(bounds)) {
1003
- const edge = this.getEdgeFromPosition(this.scrollTop, bounds.maxTop);
1004
-
1005
- if (edge === 'before') {
1006
- reachedEdgeInfo.top = true;
1007
- } else if (edge === 'after') {
1008
- reachedEdgeInfo.bottom = true;
1009
- }
1010
- }
1011
-
1012
- return reachedEdgeInfo;
1013
- };
1014
-
1015
- // scroll start
1016
-
1017
- start ({targetX, targetY, animate = true, overscrollEffect = false}) {
1018
- const
1019
- {scrollLeft, scrollTop} = this,
1020
- childRefCurrent = this.childRefCurrent,
1021
- childContainerRef = childRefCurrent.containerRef,
1022
- bounds = this.getScrollBounds(),
1023
- {maxLeft, maxTop} = bounds;
1024
-
1025
- const updatedAnimationInfo = {
1026
- targetX,
1027
- targetY
1028
- };
1029
-
1030
- // bail early when scrolling to the same position
1031
- if (this.scrolling && this.animationInfo && this.animationInfo.targetX === targetX && this.animationInfo.targetY === targetY) {
1032
- return;
1033
- }
1034
-
1035
- this.animationInfo = updatedAnimationInfo;
1036
-
1037
- if (Math.abs(maxLeft - targetX) < epsilon) {
1038
- targetX = maxLeft;
1039
- }
1040
- if (Math.abs(maxTop - targetY) < epsilon) {
1041
- targetY = maxTop;
1042
- }
1043
-
1044
- if (this.overscrollEnabled && overscrollEffect) {
1045
- if (scrollLeft !== targetX && this.canScrollHorizontally(bounds)) {
1046
- this.checkAndApplyOverscrollEffectOnStart('horizontal', this.getEdgeFromPosition(targetX, maxLeft), targetX);
1047
- }
1048
- if (scrollTop !== targetY && this.canScrollVertically(bounds)) {
1049
- this.checkAndApplyOverscrollEffectOnStart('vertical', this.getEdgeFromPosition(targetY, maxTop), targetY);
1050
- }
1051
- }
1052
-
1053
- if (animate) {
1054
- childRefCurrent.scrollToPosition(targetX, targetY);
1055
- } else {
1056
- childContainerRef.current.style.scrollBehavior = null;
1057
- childRefCurrent.scrollToPosition(targetX, targetY);
1058
- childContainerRef.current.style.scrollBehavior = 'smooth';
1059
- }
1060
- this.scrollStopJob.start();
1061
-
1062
- if (this.props.start) {
1063
- this.props.start(animate);
1064
- }
1065
- }
1066
-
1067
- stop () {
1068
- const
1069
- childRefCurrent = this.childRefCurrent,
1070
- childContainerRef = childRefCurrent.containerRef;
1071
-
1072
- childContainerRef.current.style.scrollBehavior = null;
1073
- childRefCurrent.scrollToPosition(this.scrollLeft + 0.1, this.scrollTop + 0.1);
1074
- childContainerRef.current.style.scrollBehavior = 'smooth';
1075
- }
1076
-
1077
- // scrollTo API
1078
-
1079
- getPositionForScrollTo = (opt) => {
1080
- const
1081
- bounds = this.getScrollBounds(),
1082
- canScrollHorizontally = this.canScrollHorizontally(bounds),
1083
- canScrollVertically = this.canScrollVertically(bounds);
1084
- let
1085
- itemPos,
1086
- left = null,
1087
- top = null;
1088
-
1089
- if (opt instanceof Object) {
1090
- if (opt.position instanceof Object) {
1091
- if (canScrollHorizontally) {
1092
- // We need '!=' to check if opt.position.x is null or undefined
1093
- left = opt.position.x != null ? opt.position.x : this.scrollLeft;
1094
- } else {
1095
- left = 0;
1096
- }
1097
- if (canScrollVertically) {
1098
- // We need '!=' to check if opt.position.y is null or undefined
1099
- top = opt.position.y != null ? opt.position.y : this.scrollTop;
1100
- } else {
1101
- top = 0;
1102
- }
1103
- } else if (typeof opt.align === 'string') {
1104
- if (canScrollHorizontally) {
1105
- if (opt.align.includes('left')) {
1106
- left = 0;
1107
- } else if (opt.align.includes('right')) {
1108
- left = bounds.maxLeft;
1109
- }
1110
- }
1111
- if (canScrollVertically) {
1112
- if (opt.align.includes('top')) {
1113
- top = 0;
1114
- } else if (opt.align.includes('bottom')) {
1115
- top = bounds.maxTop;
1116
- }
1117
- }
1118
- } else {
1119
- if (typeof opt.index === 'number' && typeof this.childRefCurrent.getItemPosition === 'function') {
1120
- itemPos = this.childRefCurrent.getItemPosition(opt.index, opt.stickTo);
1121
- } else if (opt.node instanceof Object) {
1122
- if (opt.node.nodeType === 1 && typeof this.childRefCurrent.getNodePosition === 'function') {
1123
- itemPos = this.childRefCurrent.getNodePosition(opt.node);
1124
- }
1125
- }
1126
- if (itemPos) {
1127
- if (canScrollHorizontally) {
1128
- left = itemPos.left;
1129
- }
1130
- if (canScrollVertically) {
1131
- top = itemPos.top;
1132
- }
1133
- }
1134
- }
1135
- }
1136
-
1137
- return {left, top};
1138
- };
1139
-
1140
- scrollTo = (opt) => {
1141
- if (!this.deferScrollTo) {
1142
- const {left, top} = this.getPositionForScrollTo(opt);
1143
-
1144
- if (this.props.scrollTo) {
1145
- this.props.scrollTo(opt);
1146
- }
1147
- this.scrollToInfo = null;
1148
- this.start({
1149
- targetX: (left !== null) ? left : this.scrollLeft,
1150
- targetY: (top !== null) ? top : this.scrollTop,
1151
- animate: opt.animate
1152
- });
1153
- } else {
1154
- this.scrollToInfo = opt;
1155
- }
1156
- };
1157
-
1158
- canScrollHorizontally = (bounds) => {
1159
- const {direction} = this.props;
1160
- return (direction === 'horizontal' || direction === 'both') && (bounds.scrollWidth > bounds.clientWidth) && !isNaN(bounds.scrollWidth);
1161
- };
1162
-
1163
- canScrollVertically = (bounds) => {
1164
- const {direction} = this.props;
1165
- return (direction === 'vertical' || direction === 'both') && (bounds.scrollHeight > bounds.clientHeight) && !isNaN(bounds.scrollHeight);
1166
- };
1167
-
1168
- // scroll bar
1169
-
1170
- showThumb (bounds) {
1171
- if (this.state.isHorizontalScrollbarVisible && this.canScrollHorizontally(bounds) && this.horizontalScrollbarRef.current) {
1172
- this.horizontalScrollbarRef.current.showThumb();
1173
- }
1174
- if (this.state.isVerticalScrollbarVisible && this.canScrollVertically(bounds) && this.verticalScrollbarRef.current) {
1175
- this.verticalScrollbarRef.current.showThumb();
1176
- }
1177
- }
1178
-
1179
- updateThumb (scrollbarRef, bounds) {
1180
- scrollbarRef.current.update({
1181
- ...bounds,
1182
- scrollLeft: this.scrollLeft,
1183
- scrollTop: this.scrollTop
1184
- });
1185
- }
1186
-
1187
- startHidingThumb = () => {
1188
- if (this.state.isHorizontalScrollbarVisible && this.horizontalScrollbarRef.current) {
1189
- this.horizontalScrollbarRef.current.startHidingThumb();
1190
- }
1191
- if (this.state.isVerticalScrollbarVisible && this.verticalScrollbarRef.current) {
1192
- this.verticalScrollbarRef.current.startHidingThumb();
1193
- }
1194
- };
1195
-
1196
- updateScrollbars = () => {
1197
- const
1198
- {horizontalScrollbar, verticalScrollbar} = this.props,
1199
- {isHorizontalScrollbarVisible, isVerticalScrollbarVisible} = this.state,
1200
- bounds = this.getScrollBounds(),
1201
- canScrollHorizontally = this.canScrollHorizontally(bounds),
1202
- canScrollVertically = this.canScrollVertically(bounds),
1203
- curHorizontalScrollbarVisible = (horizontalScrollbar === 'auto') ? canScrollHorizontally : horizontalScrollbar === 'visible',
1204
- curVerticalScrollbarVisible = (verticalScrollbar === 'auto') ? canScrollVertically : verticalScrollbar === 'visible';
1205
-
1206
- // determine if we should hide or show any scrollbars
1207
- const
1208
- isVisibilityChanged = (
1209
- isHorizontalScrollbarVisible !== curHorizontalScrollbarVisible ||
1210
- isVerticalScrollbarVisible !== curVerticalScrollbarVisible
1211
- );
1212
-
1213
- if (isVisibilityChanged) {
1214
- // one or both scrollbars have changed visibility
1215
- this.setState({
1216
- isHorizontalScrollbarVisible: curHorizontalScrollbarVisible,
1217
- isVerticalScrollbarVisible: curVerticalScrollbarVisible
1218
- });
1219
- } else {
1220
- this.deferScrollTo = false;
1221
- this.isUpdatedScrollThumb = this.updateScrollThumbSize();
1222
- }
1223
- };
1224
-
1225
- updateScrollThumbSize = () => {
1226
- const
1227
- {horizontalScrollbar, verticalScrollbar} = this.props,
1228
- bounds = this.getScrollBounds(),
1229
- canScrollHorizontally = this.canScrollHorizontally(bounds),
1230
- canScrollVertically = this.canScrollVertically(bounds),
1231
- curHorizontalScrollbarVisible = (horizontalScrollbar === 'auto') ? canScrollHorizontally : horizontalScrollbar === 'visible',
1232
- curVerticalScrollbarVisible = (verticalScrollbar === 'auto') ? canScrollVertically : verticalScrollbar === 'visible';
1233
-
1234
- if (curHorizontalScrollbarVisible || curVerticalScrollbarVisible) {
1235
- // no visibility change but need to notify whichever scrollbars are visible of the
1236
- // updated bounds and scroll position
1237
- const
1238
- updatedBounds = {
1239
- ...bounds,
1240
- scrollLeft: this.scrollLeft,
1241
- scrollTop: this.scrollTop
1242
- };
1243
-
1244
- if (curHorizontalScrollbarVisible && this.horizontalScrollbarRef.current) {
1245
- this.horizontalScrollbarRef.current.update(updatedBounds);
1246
- }
1247
- if (curVerticalScrollbarVisible && this.verticalScrollbarRef.current) {
1248
- this.verticalScrollbarRef.current.update(updatedBounds);
1249
- }
1250
- return true;
1251
- }
1252
- return false;
1253
- };
1254
-
1255
- // ref
1256
-
1257
- getScrollBounds () {
1258
- if (this.childRefCurrent && typeof this.childRefCurrent.getScrollBounds === 'function') {
1259
- return this.childRefCurrent.getScrollBounds();
1260
- }
1261
- }
1262
-
1263
- getMoreInfo () {
1264
- if (this.childRefCurrent && typeof this.childRefCurrent.getMoreInfo === 'function') {
1265
- return this.childRefCurrent.getMoreInfo();
1266
- }
1267
- }
1268
-
1269
- // FIXME setting event handlers directly to work on the V8 snapshot.
1270
- addEventListeners () {
1271
- const {childRefCurrent, containerRef} = this;
1272
-
1273
- if (containerRef.current && containerRef.current.addEventListener) {
1274
- containerRef.current.addEventListener('wheel', this.onWheel);
1275
- containerRef.current.addEventListener('keydown', this.onKeyDown);
1276
- containerRef.current.addEventListener('mousedown', this.onMouseDown);
1277
- }
1278
-
1279
- if (childRefCurrent.containerRef.current) {
1280
- if (childRefCurrent.containerRef.current.addEventListener) {
1281
- childRefCurrent.containerRef.current.addEventListener('scroll', this.onScroll, {capture: true, passive: true});
1282
- }
1283
- this.childRefCurrent.containerRef.current.style.scrollBehavior = 'smooth';
1284
- }
1285
-
1286
- if (this.props.addEventListeners) {
1287
- this.props.addEventListeners(childRefCurrent.containerRef);
1288
- }
1289
-
1290
- if (window) {
1291
- window.addEventListener('resize', this.handleResizeWindow);
1292
- }
1293
- }
1294
-
1295
- // FIXME setting event handlers directly to work on the V8 snapshot.
1296
- removeEventListeners () {
1297
- const {childRefCurrent, containerRef} = this;
1298
-
1299
- if (containerRef.current && containerRef.current.removeEventListener) {
1300
- containerRef.current.removeEventListener('wheel', this.onWheel);
1301
- containerRef.current.removeEventListener('keydown', this.onKeyDown);
1302
- containerRef.current.removeEventListener('mousedown', this.onMouseDown);
1303
- }
1304
-
1305
- if (childRefCurrent.containerRef.current && childRefCurrent.containerRef.current.removeEventListener) {
1306
- childRefCurrent.containerRef.current.removeEventListener('scroll', this.onScroll, {capture: true, passive: true});
1307
- }
1308
-
1309
- if (this.props.removeEventListeners) {
1310
- this.props.removeEventListeners(childRefCurrent.containerRef);
1311
- }
1312
-
1313
- if (window) {
1314
- window.removeEventListener('resize', this.handleResizeWindow);
1315
- }
1316
- }
1317
-
1318
- // render
1319
-
1320
- initChildRef = (ref) => {
1321
- if (ref) {
1322
- this.childRefCurrent = ref.current || ref;
1323
- }
1324
- };
1325
-
1326
- render () {
1327
- const
1328
- {className, containerRenderer, noScrollByDrag, rtl, style, ...rest} = this.props,
1329
- {isHorizontalScrollbarVisible, isVerticalScrollbarVisible} = this.state,
1330
- scrollableClasses = classNames(css.scrollable, className),
1331
- contentClasses = classNames(css.content, css.contentNative),
1332
- childWrapper = noScrollByDrag ? 'div' : TouchableDiv,
1333
- childWrapperProps = {
1334
- className: contentClasses,
1335
- ...(!noScrollByDrag && {
1336
- flickConfig,
1337
- onDrag: this.onDrag,
1338
- onDragEnd: this.onDragEnd,
1339
- onDragStart: this.onDragStart,
1340
- onFlick: this.onFlick,
1341
- onTouchStart: this.onTouchStart
1342
- })
1343
- };
1344
-
1345
- delete rest.addEventListeners;
1346
- delete rest.applyOverscrollEffect;
1347
- delete rest.cbScrollTo;
1348
- delete rest.clearOverscrollEffect;
1349
- delete rest.handleResizeWindow;
1350
- delete rest.horizontalScrollbar;
1351
- delete rest.noScrollByWheel;
1352
- delete rest.onFlick;
1353
- delete rest.onKeyDown;
1354
- delete rest.onMouseDown;
1355
- delete rest.onScroll;
1356
- delete rest.onScrollStart;
1357
- delete rest.onScrollStop;
1358
- delete rest.onWheel;
1359
- delete rest.overscrollEffectOn;
1360
- delete rest.removeEventListeners;
1361
- delete rest.scrollStopOnScroll;
1362
- delete rest.scrollTo;
1363
- delete rest.start;
1364
- delete rest.verticalScrollbar;
1365
-
1366
- this.deferScrollTo = true;
1367
-
1368
- return (
1369
- <ResizeContext.Provider value={this.resizeRegistry.register}>
1370
- {containerRenderer({
1371
- childComponentProps: rest,
1372
- childWrapper,
1373
- childWrapperProps,
1374
- className: scrollableClasses,
1375
- componentCss: css,
1376
- containerRef: this.containerRef,
1377
- horizontalScrollbarProps: this.horizontalScrollbarProps,
1378
- initChildRef: this.initChildRef,
1379
- isHorizontalScrollbarVisible,
1380
- isVerticalScrollbarVisible,
1381
- rtl,
1382
- scrollTo: this.scrollTo,
1383
- style,
1384
- verticalScrollbarProps: this.verticalScrollbarProps
1385
- })}
1386
- </ResizeContext.Provider>
1387
- );
1388
- }
1389
- }
1390
111
 
112
+ var ScrollableBaseNative = /*#__PURE__*/function (_Component) {
113
+ _inherits(ScrollableBaseNative, _Component);
114
+
115
+ var _super = _createSuper(ScrollableBaseNative);
116
+
117
+ function ScrollableBaseNative(props) {
118
+ var _this;
119
+
120
+ _classCallCheck(this, ScrollableBaseNative);
121
+
122
+ _this = _super.call(this, props);
123
+
124
+ _this.handleResizeWindow = function () {
125
+ // `handleSize` in `ui/resolution.ResolutionDecorator` should be executed first.
126
+ setTimeout(function () {
127
+ var handleResizeWindow = _this.props.handleResizeWindow;
128
+
129
+ if (handleResizeWindow) {
130
+ handleResizeWindow();
131
+ }
132
+
133
+ _this.childRefCurrent.containerRef.current.style.scrollBehavior = null;
134
+
135
+ _this.childRefCurrent.scrollToPosition(0, 0);
136
+
137
+ _this.childRefCurrent.containerRef.current.style.scrollBehavior = 'smooth';
138
+
139
+ _this.enqueueForceUpdate();
140
+ });
141
+ };
142
+
143
+ _this.pixelPerLine = 39;
144
+ _this.scrollWheelMultiplierForDeltaPixel = 1.5;
145
+ _this.deferScrollTo = true;
146
+ _this.isScrollAnimationTargetAccumulated = false;
147
+ _this.isUpdatedScrollThumb = false;
148
+ _this.lastInputType = null;
149
+ _this.overscrollEnabled = false;
150
+ _this.overscrollStatus = {
151
+ horizontal: {
152
+ before: {
153
+ type: overscrollTypeNone,
154
+ ratio: 0
155
+ },
156
+ after: {
157
+ type: overscrollTypeNone,
158
+ ratio: 0
159
+ }
160
+ },
161
+ vertical: {
162
+ before: {
163
+ type: overscrollTypeNone,
164
+ ratio: 0
165
+ },
166
+ after: {
167
+ type: overscrollTypeNone,
168
+ ratio: 0
169
+ }
170
+ }
171
+ };
172
+ _this.bounds = {
173
+ clientWidth: 0,
174
+ clientHeight: 0,
175
+ scrollWidth: 0,
176
+ scrollHeight: 0,
177
+ maxTop: 0,
178
+ maxLeft: 0
179
+ };
180
+ _this.wheelDirection = 0;
181
+ _this.isDragging = false;
182
+ _this.isTouching = false;
183
+ _this.scrolling = false;
184
+ _this.scrollLeft = 0;
185
+ _this.scrollTop = 0;
186
+ _this.scrollToInfo = null;
187
+ _this.childRefCurrent = null;
188
+ _this.animator = new _ScrollAnimator["default"]();
189
+
190
+ _this.getRtlX = function (x) {
191
+ return _this.props.rtl ? -x : x;
192
+ };
193
+
194
+ _this.onMouseDown = (0, _handle["default"])((0, _handle.forwardWithPrevent)('onMouseDown'), _this.stop).bindAs(_assertThisInitialized(_this), 'onMouseDown');
195
+
196
+ _this.onTouchStart = function () {
197
+ _this.isTouching = true;
198
+ };
199
+
200
+ _this.onDragStart = function (ev) {
201
+ if (!_this.isTouching) {
202
+ _this.stop();
203
+
204
+ _this.isDragging = true;
205
+ } // these values are used also for touch inputs
206
+
207
+
208
+ _this.dragStartX = _this.scrollLeft + _this.getRtlX(ev.x);
209
+ _this.dragStartY = _this.scrollTop + ev.y;
210
+ };
211
+
212
+ _this.onDrag = function (ev) {
213
+ var _this$props = _this.props,
214
+ direction = _this$props.direction,
215
+ overscrollEffectOn = _this$props.overscrollEffectOn,
216
+ targetX = direction === 'vertical' ? 0 : _this.dragStartX - _this.getRtlX(ev.x),
217
+ targetY = direction === 'horizontal' ? 0 : _this.dragStartY - ev.y; // 'vertical' or 'both'
218
+
219
+ _this.lastInputType = 'drag';
220
+
221
+ if (!_this.isTouching) {
222
+ _this.start({
223
+ targetX: targetX,
224
+ targetY: targetY,
225
+ animate: false,
226
+ overscrollEffect: overscrollEffectOn.drag
227
+ });
228
+ } else if (_this.overscrollEnabled && overscrollEffectOn.drag) {
229
+ _this.checkAndApplyOverscrollEffectOnDrag(targetX, targetY, overscrollTypeHold);
230
+ }
231
+ };
232
+
233
+ _this.onDragEnd = function () {
234
+ _this.isDragging = false;
235
+ _this.lastInputType = 'drag';
236
+
237
+ if (_this.flickTarget) {
238
+ var overscrollEffectOn = _this.props.overscrollEffectOn,
239
+ _this$flickTarget = _this.flickTarget,
240
+ targetX = _this$flickTarget.targetX,
241
+ targetY = _this$flickTarget.targetY;
242
+
243
+ if (!_this.isTouching) {
244
+ _this.isScrollAnimationTargetAccumulated = false;
245
+
246
+ _this.start({
247
+ targetX: targetX,
248
+ targetY: targetY,
249
+ overscrollEffect: overscrollEffectOn.drag
250
+ });
251
+ } else if (_this.overscrollEnabled && overscrollEffectOn.drag) {
252
+ _this.checkAndApplyOverscrollEffectOnDrag(targetX, targetY, overscrollTypeOnce);
253
+ }
254
+ } else if (!_this.isTouching) {
255
+ _this.stop();
256
+ }
257
+
258
+ if (_this.overscrollEnabled) {
259
+ // not check this.props.overscrollEffectOn.drag for safety
260
+ _this.clearAllOverscrollEffects();
261
+ }
262
+
263
+ _this.isTouching = false;
264
+ _this.flickTarget = null;
265
+ };
266
+
267
+ _this.onFlick = function (ev) {
268
+ var direction = _this.props.direction;
269
+
270
+ if (!_this.isTouching) {
271
+ _this.flickTarget = _this.animator.simulate(_this.scrollLeft, _this.scrollTop, direction !== 'vertical' ? _this.getRtlX(-ev.velocityX) : 0, direction !== 'horizontal' ? -ev.velocityY : 0);
272
+ } else if (_this.overscrollEnabled && _this.props.overscrollEffectOn.drag) {
273
+ _this.flickTarget = {
274
+ targetX: _this.scrollLeft + _this.getRtlX(-ev.velocityX) * overscrollVelocityFactor,
275
+ // 'horizontal' or 'both'
276
+ targetY: _this.scrollTop + -ev.velocityY * overscrollVelocityFactor // 'vertical' or 'both'
277
+
278
+ };
279
+ }
280
+
281
+ if (_this.props.onFlick) {
282
+ (0, _handle.forward)('onFlick', ev, _this.props);
283
+ }
284
+ };
285
+
286
+ _this.onWheel = function (ev) {
287
+ if (_this.isDragging) {
288
+ ev.preventDefault();
289
+ ev.stopPropagation();
290
+ } else {
291
+ var overscrollEffectOn = _this.props.overscrollEffectOn,
292
+ overscrollEffectRequired = _this.overscrollEnabled && overscrollEffectOn.wheel,
293
+ bounds = _this.getScrollBounds(),
294
+ canScrollHorizontally = _this.canScrollHorizontally(bounds),
295
+ canScrollVertically = _this.canScrollVertically(bounds),
296
+ eventDeltaMode = ev.deltaMode,
297
+ eventDelta = -ev.wheelDeltaY || ev.deltaY;
298
+
299
+ var delta = 0,
300
+ needToHideThumb = false;
301
+ _this.lastInputType = 'wheel';
302
+
303
+ if (_this.props.noScrollByWheel) {
304
+ if (canScrollVertically) {
305
+ ev.preventDefault();
306
+ }
307
+
308
+ return;
309
+ }
310
+
311
+ if (_this.props.onWheel) {
312
+ (0, _handle.forward)('onWheel', ev, _this.props);
313
+ return;
314
+ }
315
+
316
+ _this.showThumb(bounds); // FIXME This routine is a temporary support for horizontal wheel scroll.
317
+ // FIXME If web engine supports horizontal wheel, this routine should be refined or removed.
318
+
319
+
320
+ if (canScrollVertically) {
321
+ // This routine handles wheel events on scrollbars for vertical scroll.
322
+ if (eventDelta < 0 && _this.scrollTop > 0 || eventDelta > 0 && _this.scrollTop < bounds.maxTop) {
323
+ var _assertThisInitialize = _assertThisInitialized(_this),
324
+ horizontalScrollbarRef = _assertThisInitialize.horizontalScrollbarRef,
325
+ verticalScrollbarRef = _assertThisInitialize.verticalScrollbarRef; // Not to check if ev.target is a descendant of a wrapped component which may have a lot of nodes in it.
326
+
327
+
328
+ if (horizontalScrollbarRef.current && horizontalScrollbarRef.current.getContainerRef().current.contains(ev.target) || verticalScrollbarRef.current && verticalScrollbarRef.current.getContainerRef().current.contains(ev.target)) {
329
+ delta = _this.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientHeight * scrollWheelPageMultiplierForMaxPixel);
330
+ needToHideThumb = !delta;
331
+ ev.preventDefault();
332
+ } else if (overscrollEffectRequired) {
333
+ _this.checkAndApplyOverscrollEffect('vertical', eventDelta > 0 ? 'after' : 'before', overscrollTypeOnce);
334
+ }
335
+
336
+ ev.stopPropagation();
337
+ } else {
338
+ if (overscrollEffectRequired && (eventDelta < 0 && _this.scrollTop <= 0 || eventDelta > 0 && _this.scrollTop >= bounds.maxTop)) {
339
+ _this.applyOverscrollEffect('vertical', eventDelta > 0 ? 'after' : 'before', overscrollTypeOnce, 1);
340
+ }
341
+
342
+ needToHideThumb = true;
343
+ }
344
+ } else if (canScrollHorizontally) {
345
+ // this routine handles wheel events on any children for horizontal scroll.
346
+ if (eventDelta < 0 && _this.scrollLeft > 0 || eventDelta > 0 && _this.scrollLeft < bounds.maxLeft) {
347
+ delta = _this.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientWidth * scrollWheelPageMultiplierForMaxPixel);
348
+ needToHideThumb = !delta;
349
+ ev.preventDefault();
350
+ ev.stopPropagation();
351
+ } else {
352
+ if (overscrollEffectRequired && (eventDelta < 0 && _this.scrollLeft <= 0 || eventDelta > 0 && _this.scrollLeft >= bounds.maxLeft)) {
353
+ _this.applyOverscrollEffect('horizontal', eventDelta > 0 ? 'after' : 'before', overscrollTypeOnce, 1);
354
+ }
355
+
356
+ needToHideThumb = true;
357
+ }
358
+ }
359
+
360
+ if (delta !== 0) {
361
+ var direction = Math.sign(delta); // Not to accumulate scroll position if wheel direction is different from hold direction
362
+
363
+ if (direction !== _this.wheelDirection) {
364
+ _this.isScrollAnimationTargetAccumulated = false;
365
+ _this.wheelDirection = direction;
366
+ }
367
+
368
+ _this.scrollToAccumulatedTarget(delta, canScrollVertically, overscrollEffectOn.wheel);
369
+ }
370
+
371
+ if (needToHideThumb) {
372
+ _this.startHidingThumb();
373
+ }
374
+ }
375
+ };
376
+
377
+ _this.onScroll = function (ev) {
378
+ var _ev$target = ev.target,
379
+ scrollLeft = _ev$target.scrollLeft,
380
+ scrollTop = _ev$target.scrollTop;
381
+
382
+ var bounds = _this.getScrollBounds(),
383
+ canScrollHorizontally = _this.canScrollHorizontally(bounds);
384
+
385
+ if (!_this.scrolling) {
386
+ _this.scrollStartOnScroll();
387
+ }
388
+
389
+ if (_this.props.rtl && canScrollHorizontally) {
390
+ scrollLeft = _platform.platform.ios || _platform.platform.safari ? -scrollLeft : bounds.maxLeft - scrollLeft;
391
+ }
392
+
393
+ if (scrollLeft !== _this.scrollLeft) {
394
+ _this.setScrollLeft(scrollLeft);
395
+ }
396
+
397
+ if (scrollTop !== _this.scrollTop) {
398
+ _this.setScrollTop(scrollTop);
399
+ }
400
+
401
+ if (_this.childRefCurrent.didScroll) {
402
+ _this.childRefCurrent.didScroll(_this.scrollLeft, _this.scrollTop);
403
+ }
404
+
405
+ _this.forwardScrollEvent('onScroll');
406
+
407
+ _this.scrollStopJob.start();
408
+ };
409
+
410
+ _this.onKeyDown = function (ev) {
411
+ (0, _handle.forward)('onKeyDown', ev, _this.props);
412
+ };
413
+
414
+ _this.scrollToAccumulatedTarget = function (delta, vertical, overscrollEffect) {
415
+ if (!_this.isScrollAnimationTargetAccumulated) {
416
+ _this.accumulatedTargetX = _this.scrollLeft;
417
+ _this.accumulatedTargetY = _this.scrollTop;
418
+ _this.isScrollAnimationTargetAccumulated = true;
419
+ }
420
+
421
+ if (vertical) {
422
+ _this.accumulatedTargetY += delta;
423
+ } else {
424
+ _this.accumulatedTargetX += delta;
425
+ }
426
+
427
+ _this.start({
428
+ targetX: _this.accumulatedTargetX,
429
+ targetY: _this.accumulatedTargetY,
430
+ overscrollEffect: overscrollEffect
431
+ });
432
+ };
433
+
434
+ _this.getEdgeFromPosition = function (position, maxPosition) {
435
+ if (position <= 0) {
436
+ return 'before';
437
+ /* If a scroll size or a client size is not integer,
438
+ browser's max scroll position could be smaller than maxPos by 1 pixel.*/
439
+ } else if (position >= maxPosition - 1) {
440
+ return 'after';
441
+ } else {
442
+ return null;
443
+ }
444
+ };
445
+
446
+ _this.setOverscrollStatus = function (orientation, edge, type, ratio) {
447
+ var status = _this.overscrollStatus[orientation][edge];
448
+ status.type = type;
449
+ status.ratio = ratio;
450
+ };
451
+
452
+ _this.getOverscrollStatus = function (orientation, edge) {
453
+ return _this.overscrollStatus[orientation][edge];
454
+ };
455
+
456
+ _this.calculateOverscrollRatio = function (orientation, position) {
457
+ var bounds = _this.getScrollBounds(),
458
+ isVertical = orientation === 'vertical',
459
+ baseSize = isVertical ? bounds.clientHeight : bounds.clientWidth,
460
+ maxPos = bounds[isVertical ? 'maxTop' : 'maxLeft'];
461
+
462
+ var overDistance = 0;
463
+
464
+ if (position < 0) {
465
+ overDistance = -position;
466
+ } else if (position > maxPos) {
467
+ overDistance = position - maxPos;
468
+ } else {
469
+ return 0;
470
+ }
471
+
472
+ return Math.min(1, 2 * overDistance / baseSize);
473
+ };
474
+
475
+ _this.applyOverscrollEffect = function (orientation, edge, type, ratio) {
476
+ _this.props.applyOverscrollEffect(orientation, edge, type, ratio);
477
+
478
+ _this.setOverscrollStatus(orientation, edge, type === overscrollTypeOnce ? overscrollTypeDone : type, ratio);
479
+ };
480
+
481
+ _this.checkAndApplyOverscrollEffect = function (orientation, edge, type) {
482
+ var ratio = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
483
+
484
+ var isVertical = orientation === 'vertical',
485
+ curPos = isVertical ? _this.scrollTop : _this.scrollLeft,
486
+ maxPos = _this.getScrollBounds()[isVertical ? 'maxTop' : 'maxLeft'];
487
+ /* If a scroll size or a client size is not integer,
488
+ browser's max scroll position could be smaller than maxPos by 1 pixel.*/
489
+
490
+
491
+ if (edge === 'before' && curPos <= 0 || edge === 'after' && curPos >= maxPos - 1) {
492
+ // Already on the edge
493
+ _this.applyOverscrollEffect(orientation, edge, type, ratio);
494
+ } else {
495
+ _this.setOverscrollStatus(orientation, edge, type, ratio);
496
+ }
497
+ };
498
+
499
+ _this.clearOverscrollEffect = function (orientation, edge) {
500
+ if (_this.getOverscrollStatus(orientation, edge).type !== overscrollTypeNone) {
501
+ if (_this.props.clearOverscrollEffect) {
502
+ _this.props.clearOverscrollEffect(orientation, edge);
503
+ } else {
504
+ _this.applyOverscrollEffect(orientation, edge, overscrollTypeNone, 0);
505
+ }
506
+ }
507
+ };
508
+
509
+ _this.clearAllOverscrollEffects = function () {
510
+ ['horizontal', 'vertical'].forEach(function (orientation) {
511
+ ['before', 'after'].forEach(function (edge) {
512
+ _this.clearOverscrollEffect(orientation, edge);
513
+ });
514
+ });
515
+ };
516
+
517
+ _this.applyOverscrollEffectOnDrag = function (orientation, edge, targetPosition, type) {
518
+ if (edge) {
519
+ var oppositeEdge = edge === 'before' ? 'after' : 'before',
520
+ ratio = _this.calculateOverscrollRatio(orientation, targetPosition);
521
+
522
+ _this.applyOverscrollEffect(orientation, edge, type, ratio);
523
+
524
+ _this.clearOverscrollEffect(orientation, oppositeEdge);
525
+ } else {
526
+ _this.clearOverscrollEffect(orientation, 'before');
527
+
528
+ _this.clearOverscrollEffect(orientation, 'after');
529
+ }
530
+ };
531
+
532
+ _this.checkAndApplyOverscrollEffectOnDrag = function (targetX, targetY, type) {
533
+ var bounds = _this.getScrollBounds();
534
+
535
+ if (_this.canScrollHorizontally(bounds)) {
536
+ _this.applyOverscrollEffectOnDrag('horizontal', _this.getEdgeFromPosition(targetX, bounds.maxLeft), targetX, type);
537
+ }
538
+
539
+ if (_this.canScrollVertically(bounds)) {
540
+ _this.applyOverscrollEffectOnDrag('vertical', _this.getEdgeFromPosition(targetY, bounds.maxTop), targetY, type);
541
+ }
542
+ };
543
+
544
+ _this.checkAndApplyOverscrollEffectOnScroll = function (orientation) {
545
+ ['before', 'after'].forEach(function (edge) {
546
+ var _this$getOverscrollSt = _this.getOverscrollStatus(orientation, edge),
547
+ ratio = _this$getOverscrollSt.ratio,
548
+ type = _this$getOverscrollSt.type;
549
+
550
+ if (type === overscrollTypeOnce) {
551
+ _this.checkAndApplyOverscrollEffect(orientation, edge, type, ratio);
552
+ }
553
+ });
554
+ };
555
+
556
+ _this.checkAndApplyOverscrollEffectOnStart = function (orientation, edge, targetPosition) {
557
+ if (_this.isDragging) {
558
+ _this.applyOverscrollEffectOnDrag(orientation, edge, targetPosition, overscrollTypeHold);
559
+ } else if (edge) {
560
+ _this.checkAndApplyOverscrollEffect(orientation, edge, overscrollTypeOnce);
561
+ }
562
+ };
563
+
564
+ _this.scrollStartOnScroll = function () {
565
+ _this.scrolling = true;
566
+
567
+ _this.showThumb(_this.getScrollBounds());
568
+
569
+ _this.forwardScrollEvent('onScrollStart');
570
+ };
571
+
572
+ _this.scrollStopOnScroll = function () {
573
+ if (_this.props.scrollStopOnScroll) {
574
+ _this.props.scrollStopOnScroll();
575
+ }
576
+
577
+ if (_this.overscrollEnabled && !_this.isDragging) {
578
+ // not check this.props.overscrollEffectOn for safety
579
+ _this.clearAllOverscrollEffects();
580
+ }
581
+
582
+ _this.lastInputType = null;
583
+ _this.isScrollAnimationTargetAccumulated = false;
584
+ _this.scrolling = false;
585
+
586
+ _this.forwardScrollEvent('onScrollStop', _this.getReachedEdgeInfo());
587
+
588
+ _this.startHidingThumb();
589
+ };
590
+
591
+ _this.scrollStopJob = new _util.Job(_this.scrollStopOnScroll, scrollStopWaiting);
592
+
593
+ _this.getReachedEdgeInfo = function () {
594
+ var bounds = _this.getScrollBounds(),
595
+ reachedEdgeInfo = {
596
+ bottom: false,
597
+ left: false,
598
+ right: false,
599
+ top: false
600
+ };
601
+
602
+ if (_this.canScrollHorizontally(bounds)) {
603
+ var rtl = _this.props.rtl,
604
+ edge = _this.getEdgeFromPosition(_this.scrollLeft, bounds.maxLeft);
605
+
606
+ if (edge) {
607
+ // if edge is null, no need to check which edge is reached.
608
+ if (edge === 'before' && !rtl || edge === 'after' && rtl) {
609
+ reachedEdgeInfo.left = true;
610
+ } else {
611
+ reachedEdgeInfo.right = true;
612
+ }
613
+ }
614
+ }
615
+
616
+ if (_this.canScrollVertically(bounds)) {
617
+ var _edge = _this.getEdgeFromPosition(_this.scrollTop, bounds.maxTop);
618
+
619
+ if (_edge === 'before') {
620
+ reachedEdgeInfo.top = true;
621
+ } else if (_edge === 'after') {
622
+ reachedEdgeInfo.bottom = true;
623
+ }
624
+ }
625
+
626
+ return reachedEdgeInfo;
627
+ };
628
+
629
+ _this.getPositionForScrollTo = function (opt) {
630
+ var bounds = _this.getScrollBounds(),
631
+ canScrollHorizontally = _this.canScrollHorizontally(bounds),
632
+ canScrollVertically = _this.canScrollVertically(bounds);
633
+
634
+ var itemPos,
635
+ left = null,
636
+ top = null;
637
+
638
+ if (opt instanceof Object) {
639
+ if (opt.position instanceof Object) {
640
+ if (canScrollHorizontally) {
641
+ // We need '!=' to check if opt.position.x is null or undefined
642
+ left = opt.position.x != null ? opt.position.x : _this.scrollLeft;
643
+ } else {
644
+ left = 0;
645
+ }
646
+
647
+ if (canScrollVertically) {
648
+ // We need '!=' to check if opt.position.y is null or undefined
649
+ top = opt.position.y != null ? opt.position.y : _this.scrollTop;
650
+ } else {
651
+ top = 0;
652
+ }
653
+ } else if (typeof opt.align === 'string') {
654
+ if (canScrollHorizontally) {
655
+ if (opt.align.includes('left')) {
656
+ left = 0;
657
+ } else if (opt.align.includes('right')) {
658
+ left = bounds.maxLeft;
659
+ }
660
+ }
661
+
662
+ if (canScrollVertically) {
663
+ if (opt.align.includes('top')) {
664
+ top = 0;
665
+ } else if (opt.align.includes('bottom')) {
666
+ top = bounds.maxTop;
667
+ }
668
+ }
669
+ } else {
670
+ if (typeof opt.index === 'number' && typeof _this.childRefCurrent.getItemPosition === 'function') {
671
+ itemPos = _this.childRefCurrent.getItemPosition(opt.index, opt.stickTo);
672
+ } else if (opt.node instanceof Object) {
673
+ if (opt.node.nodeType === 1 && typeof _this.childRefCurrent.getNodePosition === 'function') {
674
+ itemPos = _this.childRefCurrent.getNodePosition(opt.node);
675
+ }
676
+ }
677
+
678
+ if (itemPos) {
679
+ if (canScrollHorizontally) {
680
+ left = itemPos.left;
681
+ }
682
+
683
+ if (canScrollVertically) {
684
+ top = itemPos.top;
685
+ }
686
+ }
687
+ }
688
+ }
689
+
690
+ return {
691
+ left: left,
692
+ top: top
693
+ };
694
+ };
695
+
696
+ _this.scrollTo = function (opt) {
697
+ if (!_this.deferScrollTo) {
698
+ var _this$getPositionForS = _this.getPositionForScrollTo(opt),
699
+ left = _this$getPositionForS.left,
700
+ top = _this$getPositionForS.top;
701
+
702
+ if (_this.props.scrollTo) {
703
+ _this.props.scrollTo(opt);
704
+ }
705
+
706
+ _this.scrollToInfo = null;
707
+
708
+ _this.start({
709
+ targetX: left !== null ? left : _this.scrollLeft,
710
+ targetY: top !== null ? top : _this.scrollTop,
711
+ animate: opt.animate
712
+ });
713
+ } else {
714
+ _this.scrollToInfo = opt;
715
+ }
716
+ };
717
+
718
+ _this.canScrollHorizontally = function (bounds) {
719
+ var direction = _this.props.direction;
720
+ return (direction === 'horizontal' || direction === 'both') && bounds.scrollWidth > bounds.clientWidth && !isNaN(bounds.scrollWidth);
721
+ };
722
+
723
+ _this.canScrollVertically = function (bounds) {
724
+ var direction = _this.props.direction;
725
+ return (direction === 'vertical' || direction === 'both') && bounds.scrollHeight > bounds.clientHeight && !isNaN(bounds.scrollHeight);
726
+ };
727
+
728
+ _this.startHidingThumb = function () {
729
+ if (_this.state.isHorizontalScrollbarVisible && _this.horizontalScrollbarRef.current) {
730
+ _this.horizontalScrollbarRef.current.startHidingThumb();
731
+ }
732
+
733
+ if (_this.state.isVerticalScrollbarVisible && _this.verticalScrollbarRef.current) {
734
+ _this.verticalScrollbarRef.current.startHidingThumb();
735
+ }
736
+ };
737
+
738
+ _this.updateScrollbars = function () {
739
+ var _this$props2 = _this.props,
740
+ horizontalScrollbar = _this$props2.horizontalScrollbar,
741
+ verticalScrollbar = _this$props2.verticalScrollbar,
742
+ _this$state = _this.state,
743
+ isHorizontalScrollbarVisible = _this$state.isHorizontalScrollbarVisible,
744
+ isVerticalScrollbarVisible = _this$state.isVerticalScrollbarVisible,
745
+ bounds = _this.getScrollBounds(),
746
+ canScrollHorizontally = _this.canScrollHorizontally(bounds),
747
+ canScrollVertically = _this.canScrollVertically(bounds),
748
+ curHorizontalScrollbarVisible = horizontalScrollbar === 'auto' ? canScrollHorizontally : horizontalScrollbar === 'visible',
749
+ curVerticalScrollbarVisible = verticalScrollbar === 'auto' ? canScrollVertically : verticalScrollbar === 'visible'; // determine if we should hide or show any scrollbars
750
+
751
+
752
+ var isVisibilityChanged = isHorizontalScrollbarVisible !== curHorizontalScrollbarVisible || isVerticalScrollbarVisible !== curVerticalScrollbarVisible;
753
+
754
+ if (isVisibilityChanged) {
755
+ // one or both scrollbars have changed visibility
756
+ _this.setState({
757
+ isHorizontalScrollbarVisible: curHorizontalScrollbarVisible,
758
+ isVerticalScrollbarVisible: curVerticalScrollbarVisible
759
+ });
760
+ } else {
761
+ _this.deferScrollTo = false;
762
+ _this.isUpdatedScrollThumb = _this.updateScrollThumbSize();
763
+ }
764
+ };
765
+
766
+ _this.updateScrollThumbSize = function () {
767
+ var _this$props3 = _this.props,
768
+ horizontalScrollbar = _this$props3.horizontalScrollbar,
769
+ verticalScrollbar = _this$props3.verticalScrollbar,
770
+ bounds = _this.getScrollBounds(),
771
+ canScrollHorizontally = _this.canScrollHorizontally(bounds),
772
+ canScrollVertically = _this.canScrollVertically(bounds),
773
+ curHorizontalScrollbarVisible = horizontalScrollbar === 'auto' ? canScrollHorizontally : horizontalScrollbar === 'visible',
774
+ curVerticalScrollbarVisible = verticalScrollbar === 'auto' ? canScrollVertically : verticalScrollbar === 'visible';
775
+
776
+ if (curHorizontalScrollbarVisible || curVerticalScrollbarVisible) {
777
+ // no visibility change but need to notify whichever scrollbars are visible of the
778
+ // updated bounds and scroll position
779
+ var updatedBounds = _objectSpread(_objectSpread({}, bounds), {}, {
780
+ scrollLeft: _this.scrollLeft,
781
+ scrollTop: _this.scrollTop
782
+ });
783
+
784
+ if (curHorizontalScrollbarVisible && _this.horizontalScrollbarRef.current) {
785
+ _this.horizontalScrollbarRef.current.update(updatedBounds);
786
+ }
787
+
788
+ if (curVerticalScrollbarVisible && _this.verticalScrollbarRef.current) {
789
+ _this.verticalScrollbarRef.current.update(updatedBounds);
790
+ }
791
+
792
+ return true;
793
+ }
794
+
795
+ return false;
796
+ };
797
+
798
+ _this.initChildRef = function (ref) {
799
+ if (ref) {
800
+ _this.childRefCurrent = ref.current || ref;
801
+ }
802
+ };
803
+
804
+ _this.state = {
805
+ remeasure: false,
806
+ isHorizontalScrollbarVisible: props.horizontalScrollbar === 'visible',
807
+ isVerticalScrollbarVisible: props.verticalScrollbar === 'visible'
808
+ };
809
+ _this.containerRef = /*#__PURE__*/_react["default"].createRef();
810
+ _this.horizontalScrollbarRef = /*#__PURE__*/_react["default"].createRef();
811
+ _this.verticalScrollbarRef = /*#__PURE__*/_react["default"].createRef();
812
+ _this.horizontalScrollbarProps = {
813
+ ref: _this.horizontalScrollbarRef,
814
+ vertical: false,
815
+ clientSize: props.clientSize
816
+ };
817
+ _this.verticalScrollbarProps = {
818
+ ref: _this.verticalScrollbarRef,
819
+ vertical: true,
820
+ clientSize: props.clientSize
821
+ };
822
+ _this.overscrollEnabled = !!props.applyOverscrollEffect; // Enable the early bail out of repeated scrolling to the same position
823
+
824
+ _this.animationInfo = null;
825
+ _this.resizeRegistry = _Registry["default"].create(_this.handleResize.bind(_assertThisInitialized(_this)));
826
+ props.cbScrollTo(_this.scrollTo);
827
+ return _this;
828
+ }
829
+
830
+ _createClass(ScrollableBaseNative, [{
831
+ key: "componentDidMount",
832
+ value: function componentDidMount() {
833
+ this.resizeRegistry.parent = this.context;
834
+ this.addEventListeners();
835
+ this.updateScrollbars();
836
+ }
837
+ }, {
838
+ key: "componentDidUpdate",
839
+ value: function componentDidUpdate(prevProps, prevState) {
840
+ var _this$state2 = this.state,
841
+ isHorizontalScrollbarVisible = _this$state2.isHorizontalScrollbarVisible,
842
+ isVerticalScrollbarVisible = _this$state2.isVerticalScrollbarVisible,
843
+ hasDataSizeChanged = this.childRefCurrent.hasDataSizeChanged; // Need to sync calculated client size if it is different from the real size
844
+
845
+ if (this.childRefCurrent.syncClientSize) {
846
+ // If we actually synced, we need to reset scroll position.
847
+ if (this.childRefCurrent.syncClientSize()) {
848
+ this.setScrollLeft(0);
849
+ this.setScrollTop(0);
850
+ }
851
+ }
852
+
853
+ this.addEventListeners();
854
+
855
+ if (hasDataSizeChanged === false && (isHorizontalScrollbarVisible && !prevState.isHorizontalScrollbarVisible || isVerticalScrollbarVisible && !prevState.isVerticalScrollbarVisible)) {
856
+ this.deferScrollTo = false;
857
+ this.isUpdatedScrollThumb = this.updateScrollThumbSize();
858
+ } else {
859
+ this.updateScrollbars();
860
+ }
861
+
862
+ if (this.scrollToInfo !== null) {
863
+ if (!this.deferScrollTo) {
864
+ this.scrollTo(this.scrollToInfo);
865
+ }
866
+ } // publish container resize changes
867
+
868
+
869
+ var horizontal = isHorizontalScrollbarVisible !== prevState.isHorizontalScrollbarVisible;
870
+ var vertical = isVerticalScrollbarVisible !== prevState.isVerticalScrollbarVisible;
871
+
872
+ if (horizontal || vertical) {
873
+ this.resizeRegistry.notify({});
874
+ }
875
+ }
876
+ }, {
877
+ key: "componentWillUnmount",
878
+ value: function componentWillUnmount() {
879
+ this.resizeRegistry.parent = null; // Before call cancelAnimationFrame, you must send scrollStop Event.
880
+
881
+ if (this.scrolling) {
882
+ this.forwardScrollEvent('onScrollStop', this.getReachedEdgeInfo());
883
+ }
884
+
885
+ this.scrollStopJob.stop();
886
+ this.removeEventListeners();
887
+ }
888
+ }, {
889
+ key: "handleResize",
890
+ value: function handleResize(ev) {
891
+ if (ev.action === 'invalidateBounds') {
892
+ this.enqueueForceUpdate();
893
+ }
894
+ }
895
+ }, {
896
+ key: "enqueueForceUpdate",
897
+ // TODO: consider replacing forceUpdate() by storing bounds in state rather than a non-
898
+ // state member.
899
+ value: function enqueueForceUpdate() {
900
+ this.childRefCurrent.calculateMetrics(this.childRefCurrent.props);
901
+ this.forceUpdate();
902
+ } // constants
903
+
904
+ }, {
905
+ key: "calculateDistanceByWheel",
906
+ value: function calculateDistanceByWheel(deltaMode, delta, maxPixel) {
907
+ if (deltaMode === 0) {
908
+ delta = (0, _clamp["default"])(-maxPixel, maxPixel, _resolution["default"].scale(delta * this.scrollWheelMultiplierForDeltaPixel));
909
+ } else if (deltaMode === 1) {
910
+ // line; firefox
911
+ delta = (0, _clamp["default"])(-maxPixel, maxPixel, _resolution["default"].scale(delta * this.pixelPerLine * this.scrollWheelMultiplierForDeltaPixel));
912
+ } else if (deltaMode === 2) {
913
+ // page
914
+ delta = delta < 0 ? -maxPixel : maxPixel;
915
+ }
916
+
917
+ return delta;
918
+ }
919
+ /*
920
+ * wheel event handler;
921
+ * - for horizontal scroll, supports wheel action on any children nodes since web engine cannot support this
922
+ * - for vertical scroll, supports wheel action on scrollbars only
923
+ */
924
+
925
+ }, {
926
+ key: "forwardScrollEvent",
927
+ // call scroll callbacks
928
+ value: function forwardScrollEvent(type, reachedEdgeInfo) {
929
+ (0, _handle.forward)(type, {
930
+ scrollLeft: this.scrollLeft,
931
+ scrollTop: this.scrollTop,
932
+ moreInfo: this.getMoreInfo(),
933
+ reachedEdgeInfo: reachedEdgeInfo
934
+ }, this.props);
935
+ } // call scroll callbacks and update scrollbars for native scroll
936
+
937
+ }, {
938
+ key: "setScrollLeft",
939
+ // update scroll position
940
+ value: function setScrollLeft(value) {
941
+ var bounds = this.getScrollBounds();
942
+ this.scrollLeft = (0, _clamp["default"])(0, bounds.maxLeft, value);
943
+
944
+ if (this.overscrollEnabled && this.props.overscrollEffectOn[this.lastInputType]) {
945
+ this.checkAndApplyOverscrollEffectOnScroll('horizontal');
946
+ }
947
+
948
+ if (this.state.isHorizontalScrollbarVisible) {
949
+ this.updateThumb(this.horizontalScrollbarRef, bounds);
950
+ }
951
+ }
952
+ }, {
953
+ key: "setScrollTop",
954
+ value: function setScrollTop(value) {
955
+ var bounds = this.getScrollBounds();
956
+ this.scrollTop = (0, _clamp["default"])(0, bounds.maxTop, value);
957
+
958
+ if (this.overscrollEnabled && this.props.overscrollEffectOn[this.lastInputType]) {
959
+ this.checkAndApplyOverscrollEffectOnScroll('vertical');
960
+ }
961
+
962
+ if (this.state.isVerticalScrollbarVisible) {
963
+ this.updateThumb(this.verticalScrollbarRef, bounds);
964
+ }
965
+ }
966
+ }, {
967
+ key: "start",
968
+ // scroll start
969
+ value: function start(_ref) {
970
+ var targetX = _ref.targetX,
971
+ targetY = _ref.targetY,
972
+ _ref$animate = _ref.animate,
973
+ animate = _ref$animate === void 0 ? true : _ref$animate,
974
+ _ref$overscrollEffect = _ref.overscrollEffect,
975
+ overscrollEffect = _ref$overscrollEffect === void 0 ? false : _ref$overscrollEffect;
976
+ var scrollLeft = this.scrollLeft,
977
+ scrollTop = this.scrollTop,
978
+ childRefCurrent = this.childRefCurrent,
979
+ childContainerRef = childRefCurrent.containerRef,
980
+ bounds = this.getScrollBounds(),
981
+ maxLeft = bounds.maxLeft,
982
+ maxTop = bounds.maxTop;
983
+ var updatedAnimationInfo = {
984
+ targetX: targetX,
985
+ targetY: targetY
986
+ }; // bail early when scrolling to the same position
987
+
988
+ if (this.scrolling && this.animationInfo && this.animationInfo.targetX === targetX && this.animationInfo.targetY === targetY) {
989
+ return;
990
+ }
991
+
992
+ this.animationInfo = updatedAnimationInfo;
993
+
994
+ if (Math.abs(maxLeft - targetX) < epsilon) {
995
+ targetX = maxLeft;
996
+ }
997
+
998
+ if (Math.abs(maxTop - targetY) < epsilon) {
999
+ targetY = maxTop;
1000
+ }
1001
+
1002
+ if (this.overscrollEnabled && overscrollEffect) {
1003
+ if (scrollLeft !== targetX && this.canScrollHorizontally(bounds)) {
1004
+ this.checkAndApplyOverscrollEffectOnStart('horizontal', this.getEdgeFromPosition(targetX, maxLeft), targetX);
1005
+ }
1006
+
1007
+ if (scrollTop !== targetY && this.canScrollVertically(bounds)) {
1008
+ this.checkAndApplyOverscrollEffectOnStart('vertical', this.getEdgeFromPosition(targetY, maxTop), targetY);
1009
+ }
1010
+ }
1011
+
1012
+ if (animate) {
1013
+ childRefCurrent.scrollToPosition(targetX, targetY);
1014
+ } else {
1015
+ childContainerRef.current.style.scrollBehavior = null;
1016
+ childRefCurrent.scrollToPosition(targetX, targetY);
1017
+ childContainerRef.current.style.scrollBehavior = 'smooth';
1018
+ }
1019
+
1020
+ this.scrollStopJob.start();
1021
+
1022
+ if (this.props.start) {
1023
+ this.props.start(animate);
1024
+ }
1025
+ }
1026
+ }, {
1027
+ key: "stop",
1028
+ value: function stop() {
1029
+ var childRefCurrent = this.childRefCurrent,
1030
+ childContainerRef = childRefCurrent.containerRef;
1031
+ childContainerRef.current.style.scrollBehavior = null;
1032
+ childRefCurrent.scrollToPosition(this.scrollLeft + 0.1, this.scrollTop + 0.1);
1033
+ childContainerRef.current.style.scrollBehavior = 'smooth';
1034
+ } // scrollTo API
1035
+
1036
+ }, {
1037
+ key: "showThumb",
1038
+ // scroll bar
1039
+ value: function showThumb(bounds) {
1040
+ if (this.state.isHorizontalScrollbarVisible && this.canScrollHorizontally(bounds) && this.horizontalScrollbarRef.current) {
1041
+ this.horizontalScrollbarRef.current.showThumb();
1042
+ }
1043
+
1044
+ if (this.state.isVerticalScrollbarVisible && this.canScrollVertically(bounds) && this.verticalScrollbarRef.current) {
1045
+ this.verticalScrollbarRef.current.showThumb();
1046
+ }
1047
+ }
1048
+ }, {
1049
+ key: "updateThumb",
1050
+ value: function updateThumb(scrollbarRef, bounds) {
1051
+ scrollbarRef.current.update(_objectSpread(_objectSpread({}, bounds), {}, {
1052
+ scrollLeft: this.scrollLeft,
1053
+ scrollTop: this.scrollTop
1054
+ }));
1055
+ }
1056
+ }, {
1057
+ key: "getScrollBounds",
1058
+ // ref
1059
+ value: function getScrollBounds() {
1060
+ if (this.childRefCurrent && typeof this.childRefCurrent.getScrollBounds === 'function') {
1061
+ return this.childRefCurrent.getScrollBounds();
1062
+ }
1063
+ }
1064
+ }, {
1065
+ key: "getMoreInfo",
1066
+ value: function getMoreInfo() {
1067
+ if (this.childRefCurrent && typeof this.childRefCurrent.getMoreInfo === 'function') {
1068
+ return this.childRefCurrent.getMoreInfo();
1069
+ }
1070
+ } // FIXME setting event handlers directly to work on the V8 snapshot.
1071
+
1072
+ }, {
1073
+ key: "addEventListeners",
1074
+ value: function addEventListeners() {
1075
+ var childRefCurrent = this.childRefCurrent,
1076
+ containerRef = this.containerRef;
1077
+
1078
+ if (containerRef.current && containerRef.current.addEventListener) {
1079
+ containerRef.current.addEventListener('wheel', this.onWheel);
1080
+ containerRef.current.addEventListener('keydown', this.onKeyDown);
1081
+ containerRef.current.addEventListener('mousedown', this.onMouseDown);
1082
+ }
1083
+
1084
+ if (childRefCurrent.containerRef.current) {
1085
+ if (childRefCurrent.containerRef.current.addEventListener) {
1086
+ childRefCurrent.containerRef.current.addEventListener('scroll', this.onScroll, {
1087
+ capture: true,
1088
+ passive: true
1089
+ });
1090
+ }
1091
+
1092
+ this.childRefCurrent.containerRef.current.style.scrollBehavior = 'smooth';
1093
+ }
1094
+
1095
+ if (this.props.addEventListeners) {
1096
+ this.props.addEventListeners(childRefCurrent.containerRef);
1097
+ }
1098
+
1099
+ if (window) {
1100
+ window.addEventListener('resize', this.handleResizeWindow);
1101
+ }
1102
+ } // FIXME setting event handlers directly to work on the V8 snapshot.
1103
+
1104
+ }, {
1105
+ key: "removeEventListeners",
1106
+ value: function removeEventListeners() {
1107
+ var childRefCurrent = this.childRefCurrent,
1108
+ containerRef = this.containerRef;
1109
+
1110
+ if (containerRef.current && containerRef.current.removeEventListener) {
1111
+ containerRef.current.removeEventListener('wheel', this.onWheel);
1112
+ containerRef.current.removeEventListener('keydown', this.onKeyDown);
1113
+ containerRef.current.removeEventListener('mousedown', this.onMouseDown);
1114
+ }
1115
+
1116
+ if (childRefCurrent.containerRef.current && childRefCurrent.containerRef.current.removeEventListener) {
1117
+ childRefCurrent.containerRef.current.removeEventListener('scroll', this.onScroll, {
1118
+ capture: true,
1119
+ passive: true
1120
+ });
1121
+ }
1122
+
1123
+ if (this.props.removeEventListeners) {
1124
+ this.props.removeEventListeners(childRefCurrent.containerRef);
1125
+ }
1126
+
1127
+ if (window) {
1128
+ window.removeEventListener('resize', this.handleResizeWindow);
1129
+ }
1130
+ } // render
1131
+
1132
+ }, {
1133
+ key: "render",
1134
+ value: function render() {
1135
+ var _this$props4 = this.props,
1136
+ className = _this$props4.className,
1137
+ containerRenderer = _this$props4.containerRenderer,
1138
+ noScrollByDrag = _this$props4.noScrollByDrag,
1139
+ rtl = _this$props4.rtl,
1140
+ style = _this$props4.style,
1141
+ rest = _objectWithoutProperties(_this$props4, ["className", "containerRenderer", "noScrollByDrag", "rtl", "style"]),
1142
+ _this$state3 = this.state,
1143
+ isHorizontalScrollbarVisible = _this$state3.isHorizontalScrollbarVisible,
1144
+ isVerticalScrollbarVisible = _this$state3.isVerticalScrollbarVisible,
1145
+ scrollableClasses = (0, _classnames["default"])(_ScrollableModule["default"].scrollable, className),
1146
+ contentClasses = (0, _classnames["default"])(_ScrollableModule["default"].content, _ScrollableModule["default"].contentNative),
1147
+ childWrapper = noScrollByDrag ? 'div' : TouchableDiv,
1148
+ childWrapperProps = _objectSpread({
1149
+ className: contentClasses
1150
+ }, !noScrollByDrag && {
1151
+ flickConfig: flickConfig,
1152
+ onDrag: this.onDrag,
1153
+ onDragEnd: this.onDragEnd,
1154
+ onDragStart: this.onDragStart,
1155
+ onFlick: this.onFlick,
1156
+ onTouchStart: this.onTouchStart
1157
+ });
1158
+
1159
+ delete rest.addEventListeners;
1160
+ delete rest.applyOverscrollEffect;
1161
+ delete rest.cbScrollTo;
1162
+ delete rest.clearOverscrollEffect;
1163
+ delete rest.handleResizeWindow;
1164
+ delete rest.horizontalScrollbar;
1165
+ delete rest.noScrollByWheel;
1166
+ delete rest.onFlick;
1167
+ delete rest.onKeyDown;
1168
+ delete rest.onMouseDown;
1169
+ delete rest.onScroll;
1170
+ delete rest.onScrollStart;
1171
+ delete rest.onScrollStop;
1172
+ delete rest.onWheel;
1173
+ delete rest.overscrollEffectOn;
1174
+ delete rest.removeEventListeners;
1175
+ delete rest.scrollStopOnScroll;
1176
+ delete rest.scrollTo;
1177
+ delete rest.start;
1178
+ delete rest.verticalScrollbar;
1179
+ this.deferScrollTo = true;
1180
+ return /*#__PURE__*/_react["default"].createElement(_Resizable.ResizeContext.Provider, {
1181
+ value: this.resizeRegistry.register
1182
+ }, containerRenderer({
1183
+ childComponentProps: rest,
1184
+ childWrapper: childWrapper,
1185
+ childWrapperProps: childWrapperProps,
1186
+ className: scrollableClasses,
1187
+ componentCss: _ScrollableModule["default"],
1188
+ containerRef: this.containerRef,
1189
+ horizontalScrollbarProps: this.horizontalScrollbarProps,
1190
+ initChildRef: this.initChildRef,
1191
+ isHorizontalScrollbarVisible: isHorizontalScrollbarVisible,
1192
+ isVerticalScrollbarVisible: isVerticalScrollbarVisible,
1193
+ rtl: rtl,
1194
+ scrollTo: this.scrollTo,
1195
+ style: style,
1196
+ verticalScrollbarProps: this.verticalScrollbarProps
1197
+ }));
1198
+ }
1199
+ }]);
1200
+
1201
+ return ScrollableBaseNative;
1202
+ }(_react.Component);
1391
1203
  /**
1392
1204
  * An unstyled native component that provides horizontal and vertical scrollbars and makes a render prop element scrollable.
1393
1205
  *
@@ -1397,69 +1209,411 @@ class ScrollableBaseNative extends Component {
1397
1209
  * @ui
1398
1210
  * @private
1399
1211
  */
1400
- class ScrollableNative extends Component {
1401
- static displayName = 'ui:ScrollableNative';
1402
-
1403
- static propTypes = /** @lends ui/ScrollableNative.ScrollableNative.prototype */ {
1404
- /**
1405
- * Render function.
1406
- *
1407
- * @type {Function}
1408
- * @private
1409
- */
1410
- childRenderer: PropTypes.func
1411
- };
1412
-
1413
- render () {
1414
- const {childRenderer, ...rest} = this.props;
1415
-
1416
- return (
1417
- <ScrollableBaseNative
1418
- {...rest}
1419
- containerRenderer={({ // eslint-disable-line react/jsx-no-bind
1420
- childComponentProps,
1421
- childWrapper: ChildWrapper,
1422
- childWrapperProps,
1423
- className,
1424
- componentCss,
1425
- containerRef,
1426
- horizontalScrollbarProps,
1427
- initChildRef,
1428
- isHorizontalScrollbarVisible,
1429
- isVerticalScrollbarVisible,
1430
- rtl,
1431
- scrollTo,
1432
- style,
1433
- verticalScrollbarProps
1434
- }) => (
1435
- <div
1436
- className={className}
1437
- ref={containerRef}
1438
- style={style}
1439
- >
1440
- <div className={componentCss.container}>
1441
- <ChildWrapper {...childWrapperProps}>
1442
- {childRenderer({
1443
- ...childComponentProps,
1444
- cbScrollTo: scrollTo,
1445
- className: componentCss.scrollableFill,
1446
- initChildRef,
1447
- rtl
1448
- })}
1449
- </ChildWrapper>
1450
- {isVerticalScrollbarVisible ? <Scrollbar {...verticalScrollbarProps} disabled={!isVerticalScrollbarVisible} /> : null}
1451
- </div>
1452
- {isHorizontalScrollbarVisible ? <Scrollbar {...horizontalScrollbarProps} corner={isVerticalScrollbarVisible} disabled={!isHorizontalScrollbarVisible} /> : null}
1453
- </div>
1454
- )}
1455
- />
1456
- );
1457
- }
1458
- }
1459
-
1460
- export default ScrollableNative;
1461
- export {
1462
- constants,
1463
- ScrollableBaseNative,
1464
- ScrollableNative
1212
+
1213
+
1214
+ exports.ScrollableBaseNative = ScrollableBaseNative;
1215
+ ScrollableBaseNative.displayName = 'ui:ScrollableBaseNative';
1216
+ ScrollableBaseNative.propTypes =
1217
+ /** @lends ui/ScrollableNative.ScrollableNative.prototype */
1218
+ {
1219
+ /**
1220
+ * Render function.
1221
+ *
1222
+ * @type {Function}
1223
+ * @required
1224
+ * @private
1225
+ */
1226
+ containerRenderer: _propTypes["default"].func.isRequired,
1227
+
1228
+ /**
1229
+ * Called when adding additional event listeners in a themed component.
1230
+ *
1231
+ * @type {Function}
1232
+ * @private
1233
+ */
1234
+ addEventListeners: _propTypes["default"].func,
1235
+
1236
+ /**
1237
+ * Called to execute additional logic in a themed component to show overscroll effect.
1238
+ *
1239
+ * @type {Function}
1240
+ * @private
1241
+ */
1242
+ applyOverscrollEffect: _propTypes["default"].func,
1243
+
1244
+ /**
1245
+ * A callback function that receives a reference to the `scrollTo` feature.
1246
+ *
1247
+ * Once received, the `scrollTo` method can be called as an imperative interface.
1248
+ *
1249
+ * The `scrollTo` function accepts the following parameters:
1250
+ * - {position: {x, y}} - Pixel value for x and/or y position
1251
+ * - {align} - Where the scroll area should be aligned. Values are:
1252
+ * `'left'`, `'right'`, `'top'`, `'bottom'`,
1253
+ * `'topleft'`, `'topright'`, `'bottomleft'`, and `'bottomright'`.
1254
+ * - {index} - Index of specific item. (`0` or positive integer)
1255
+ * This option is available for only `VirtualList` kind.
1256
+ * - {node} - Node to scroll into view
1257
+ * - {animate} - When `true`, scroll occurs with animation. When `false`, no
1258
+ * animation occurs.
1259
+ * - {focus} - When `true`, attempts to focus item after scroll. Only valid when scrolling
1260
+ * by `index` or `node`.
1261
+ * > Note: Only specify one of: `position`, `align`, `index` or `node`
1262
+ *
1263
+ * Example:
1264
+ * ```
1265
+ * // If you set cbScrollTo prop like below;
1266
+ * cbScrollTo: (fn) => {this.scrollTo = fn;}
1267
+ * // You can simply call like below;
1268
+ * this.scrollTo({align: 'top'}); // scroll to the top
1269
+ * ```
1270
+ *
1271
+ * @type {Function}
1272
+ * @public
1273
+ */
1274
+ cbScrollTo: _propTypes["default"].func,
1275
+
1276
+ /**
1277
+ * Called to execute additional logic in a themed component to clear overscroll effect.
1278
+ *
1279
+ * @type {Function}
1280
+ * @private
1281
+ */
1282
+ clearOverscrollEffect: _propTypes["default"].func,
1283
+
1284
+ /**
1285
+ * Client size of the container; valid values are an object that has `clientWidth` and `clientHeight`.
1286
+ *
1287
+ * @type {Object}
1288
+ * @property {Number} clientHeight The client height of the list.
1289
+ * @property {Number} clientWidth The client width of the list.
1290
+ * @public
1291
+ */
1292
+ clientSize: _propTypes["default"].shape({
1293
+ clientHeight: _propTypes["default"].number.isRequired,
1294
+ clientWidth: _propTypes["default"].number.isRequired
1295
+ }),
1296
+
1297
+ /**
1298
+ * Direction of the list or the scroller.
1299
+ *
1300
+ * `'both'` could be only used for[Scroller]{@link ui/Scroller.Scroller}.
1301
+ *
1302
+ * Valid values are:
1303
+ * * `'both'`,
1304
+ * * `'horizontal'`, and
1305
+ * * `'vertical'`.
1306
+ *
1307
+ * @type {String}
1308
+ * @private
1309
+ */
1310
+ direction: _propTypes["default"].oneOf(['both', 'horizontal', 'vertical']),
1311
+
1312
+ /**
1313
+ * Called when resizing window
1314
+ *
1315
+ * @type {Function}
1316
+ * @private
1317
+ */
1318
+ handleResizeWindow: _propTypes["default"].func,
1319
+
1320
+ /**
1321
+ * Specifies how to show horizontal scrollbar.
1322
+ *
1323
+ * Valid values are:
1324
+ * * `'auto'`,
1325
+ * * `'visible'`, and
1326
+ * * `'hidden'`.
1327
+ *
1328
+ * @type {String}
1329
+ * @default 'auto'
1330
+ * @public
1331
+ */
1332
+ horizontalScrollbar: _propTypes["default"].oneOf(['auto', 'visible', 'hidden']),
1333
+
1334
+ /**
1335
+ * Prevents scroll by dragging or flicking on the list or the scroller.
1336
+ *
1337
+ * @type {Boolean}
1338
+ * @default false
1339
+ * @private
1340
+ */
1341
+ noScrollByDrag: _propTypes["default"].bool,
1342
+
1343
+ /**
1344
+ * Prevents scroll by wheeling on the list or the scroller.
1345
+ *
1346
+ * @type {Boolean}
1347
+ * @default false
1348
+ * @public
1349
+ */
1350
+ noScrollByWheel: _propTypes["default"].bool,
1351
+
1352
+ /**
1353
+ * Called when flicking with a mouse or a touch screen.
1354
+ *
1355
+ * @type {Function}
1356
+ * @private
1357
+ */
1358
+ onFlick: _propTypes["default"].func,
1359
+
1360
+ /**
1361
+ * Called when pressing a key.
1362
+ *
1363
+ * @type {Function}
1364
+ * @private
1365
+ */
1366
+ onKeyDown: _propTypes["default"].func,
1367
+
1368
+ /**
1369
+ * Called when triggering a mousedown event.
1370
+ *
1371
+ * @type {Function}
1372
+ * @private
1373
+ */
1374
+ onMouseDown: _propTypes["default"].func,
1375
+
1376
+ /**
1377
+ * Called when scrolling.
1378
+ *
1379
+ * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
1380
+ * It is not recommended to set this prop since it can cause performance degradation.
1381
+ * Use `onScrollStart` or `onScrollStop` instead.
1382
+ *
1383
+ * @type {Function}
1384
+ * @param {Object} event
1385
+ * @param {Number} event.scrollLeft Scroll left value.
1386
+ * @param {Number} event.scrollTop Scroll top value.
1387
+ * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
1388
+ * @public
1389
+ */
1390
+ onScroll: _propTypes["default"].func,
1391
+
1392
+ /**
1393
+ * Called when scroll starts.
1394
+ *
1395
+ * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
1396
+ * You can get firstVisibleIndex and lastVisibleIndex from VirtualList with `moreInfo`.
1397
+ *
1398
+ * Example:
1399
+ * ```
1400
+ * onScrollStart = ({scrollLeft, scrollTop, moreInfo}) => {
1401
+ * const {firstVisibleIndex, lastVisibleIndex} = moreInfo;
1402
+ * // do something with firstVisibleIndex and lastVisibleIndex
1403
+ * }
1404
+ *
1405
+ * render = () => (
1406
+ * <VirtualList
1407
+ * ...
1408
+ * onScrollStart={this.onScrollStart}
1409
+ * ...
1410
+ * />
1411
+ * )
1412
+ * ```
1413
+ *
1414
+ * @type {Function}
1415
+ * @param {Object} event
1416
+ * @param {Number} event.scrollLeft Scroll left value.
1417
+ * @param {Number} event.scrollTop Scroll top value.
1418
+ * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
1419
+ * @public
1420
+ */
1421
+ onScrollStart: _propTypes["default"].func,
1422
+
1423
+ /**
1424
+ * Called when scroll stops.
1425
+ *
1426
+ * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
1427
+ * You can get firstVisibleIndex and lastVisibleIndex from VirtualList with `moreInfo`.
1428
+ *
1429
+ * Example:
1430
+ * ```
1431
+ * onScrollStop = ({scrollLeft, scrollTop, moreInfo}) => {
1432
+ * const {firstVisibleIndex, lastVisibleIndex} = moreInfo;
1433
+ * // do something with firstVisibleIndex and lastVisibleIndex
1434
+ * }
1435
+ *
1436
+ * render = () => (
1437
+ * <VirtualList
1438
+ * ...
1439
+ * onScrollStop={this.onScrollStop}
1440
+ * ...
1441
+ * />
1442
+ * )
1443
+ * ```
1444
+ *
1445
+ * @type {Function}
1446
+ * @param {Object} event
1447
+ * @param {Number} event.scrollLeft Scroll left value.
1448
+ * @param {Number} event.scrollTop Scroll top value.
1449
+ * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
1450
+ * @public
1451
+ */
1452
+ onScrollStop: _propTypes["default"].func,
1453
+
1454
+ /**
1455
+ * Called when wheeling.
1456
+ *
1457
+ * @type {Function}
1458
+ * @private
1459
+ */
1460
+ onWheel: _propTypes["default"].func,
1461
+
1462
+ /**
1463
+ * Specifies overscroll effects shows on which type of inputs.
1464
+ *
1465
+ * @type {Object}
1466
+ * @default {drag: false, pageKey: false, wheel: false}
1467
+ * @private
1468
+ */
1469
+ overscrollEffectOn: _propTypes["default"].shape({
1470
+ drag: _propTypes["default"].bool,
1471
+ pageKey: _propTypes["default"].bool,
1472
+ wheel: _propTypes["default"].bool
1473
+ }),
1474
+
1475
+ /**
1476
+ * Called when removing additional event listeners in a themed component.
1477
+ *
1478
+ * @type {Function}
1479
+ * @private
1480
+ */
1481
+ removeEventListeners: _propTypes["default"].func,
1482
+
1483
+ /**
1484
+ * Indicates the content's text direction is right-to-left.
1485
+ *
1486
+ * @type {Boolean}
1487
+ * @private
1488
+ */
1489
+ rtl: _propTypes["default"].bool,
1490
+
1491
+ /**
1492
+ * Called to execute additional logic in a themed component after scrolling.
1493
+ *
1494
+ * @type {Function}
1495
+ * @private
1496
+ */
1497
+ scrollStopOnScroll: _propTypes["default"].func,
1498
+
1499
+ /**
1500
+ * Called to execute additional logic in a themed component when scrollTo is called.
1501
+ *
1502
+ * @type {Function}
1503
+ * @private
1504
+ */
1505
+ scrollTo: _propTypes["default"].func,
1506
+
1507
+ /**
1508
+ * Called to execute additional logic in a themed component when scroll starts.
1509
+ *
1510
+ * @type {Function}
1511
+ * @private
1512
+ */
1513
+ start: _propTypes["default"].func,
1514
+
1515
+ /**
1516
+ * Specifies how to show vertical scrollbar.
1517
+ *
1518
+ * Valid values are:
1519
+ * * `'auto'`,
1520
+ * * `'visible'`, and
1521
+ * * `'hidden'`.
1522
+ *
1523
+ * @type {String}
1524
+ * @default 'auto'
1525
+ * @public
1526
+ */
1527
+ verticalScrollbar: _propTypes["default"].oneOf(['auto', 'visible', 'hidden'])
1528
+ };
1529
+ ScrollableBaseNative.defaultProps = {
1530
+ cbScrollTo: nop,
1531
+ horizontalScrollbar: 'auto',
1532
+ noScrollByDrag: false,
1533
+ noScrollByWheel: false,
1534
+ onScroll: nop,
1535
+ onScrollStart: nop,
1536
+ onScrollStop: nop,
1537
+ overscrollEffectOn: {
1538
+ drag: false,
1539
+ pageKey: false,
1540
+ wheel: false
1541
+ },
1542
+ verticalScrollbar: 'auto'
1543
+ };
1544
+ ScrollableBaseNative.contextType = _Resizable.ResizeContext;
1545
+
1546
+ var ScrollableNative = /*#__PURE__*/function (_Component2) {
1547
+ _inherits(ScrollableNative, _Component2);
1548
+
1549
+ var _super2 = _createSuper(ScrollableNative);
1550
+
1551
+ function ScrollableNative() {
1552
+ _classCallCheck(this, ScrollableNative);
1553
+
1554
+ return _super2.apply(this, arguments);
1555
+ }
1556
+
1557
+ _createClass(ScrollableNative, [{
1558
+ key: "render",
1559
+ value: function render() {
1560
+ var _this$props5 = this.props,
1561
+ childRenderer = _this$props5.childRenderer,
1562
+ rest = _objectWithoutProperties(_this$props5, ["childRenderer"]);
1563
+
1564
+ return /*#__PURE__*/_react["default"].createElement(ScrollableBaseNative, Object.assign({}, rest, {
1565
+ containerRenderer: function containerRenderer(_ref2) {
1566
+ var childComponentProps = _ref2.childComponentProps,
1567
+ ChildWrapper = _ref2.childWrapper,
1568
+ childWrapperProps = _ref2.childWrapperProps,
1569
+ className = _ref2.className,
1570
+ componentCss = _ref2.componentCss,
1571
+ containerRef = _ref2.containerRef,
1572
+ horizontalScrollbarProps = _ref2.horizontalScrollbarProps,
1573
+ initChildRef = _ref2.initChildRef,
1574
+ isHorizontalScrollbarVisible = _ref2.isHorizontalScrollbarVisible,
1575
+ isVerticalScrollbarVisible = _ref2.isVerticalScrollbarVisible,
1576
+ rtl = _ref2.rtl,
1577
+ scrollTo = _ref2.scrollTo,
1578
+ style = _ref2.style,
1579
+ verticalScrollbarProps = _ref2.verticalScrollbarProps;
1580
+ return /*#__PURE__*/_react["default"].createElement("div", {
1581
+ className: className,
1582
+ ref: containerRef,
1583
+ style: style
1584
+ }, /*#__PURE__*/_react["default"].createElement("div", {
1585
+ className: componentCss.container
1586
+ }, /*#__PURE__*/_react["default"].createElement(ChildWrapper, childWrapperProps, childRenderer(_objectSpread(_objectSpread({}, childComponentProps), {}, {
1587
+ cbScrollTo: scrollTo,
1588
+ className: componentCss.scrollableFill,
1589
+ initChildRef: initChildRef,
1590
+ rtl: rtl
1591
+ }))), isVerticalScrollbarVisible ? /*#__PURE__*/_react["default"].createElement(_Scrollbar["default"], Object.assign({}, verticalScrollbarProps, {
1592
+ disabled: !isVerticalScrollbarVisible
1593
+ })) : null), isHorizontalScrollbarVisible ? /*#__PURE__*/_react["default"].createElement(_Scrollbar["default"], Object.assign({}, horizontalScrollbarProps, {
1594
+ corner: isVerticalScrollbarVisible,
1595
+ disabled: !isHorizontalScrollbarVisible
1596
+ })) : null);
1597
+ }
1598
+ }));
1599
+ }
1600
+ }]);
1601
+
1602
+ return ScrollableNative;
1603
+ }(_react.Component);
1604
+
1605
+ exports.ScrollableNative = ScrollableNative;
1606
+ ScrollableNative.displayName = 'ui:ScrollableNative';
1607
+ ScrollableNative.propTypes =
1608
+ /** @lends ui/ScrollableNative.ScrollableNative.prototype */
1609
+ {
1610
+ /**
1611
+ * Render function.
1612
+ *
1613
+ * @type {Function}
1614
+ * @private
1615
+ */
1616
+ childRenderer: _propTypes["default"].func
1465
1617
  };
1618
+ var _default = ScrollableNative;
1619
+ exports["default"] = _default;