@titaui/pc 1.11.1 → 1.11.2

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 (298) hide show
  1. package/lib/components/date-picker/BodyItem.js +3 -3
  2. package/lib/components/date-picker/CalendarHeader.js +3 -3
  3. package/lib/components/delete-confirm-pop/ConfirmPop.js +3 -3
  4. package/lib/components/drawer-manager/index.js +25 -27
  5. package/lib/components/dynamic/online-broadcast/data.js +7 -1
  6. package/lib/components/eReport/eReportLists/reportList.js +3 -3
  7. package/lib/components/emotions-selector/selector-pop.js +3 -3
  8. package/lib/components/ereport-list/index.js +3 -3
  9. package/lib/components/mblog/components/MblogAction.js +3 -3
  10. package/lib/components/okr-detail/components/okr-tree/tree-node/kr-node/kr-score-editor/edit-pop.js +3 -3
  11. package/lib/components/okr-review/components/ReviewItem/index.js +3 -3
  12. package/lib/components/okr-review/components/confirm-pop/ConfirmPop.js +3 -3
  13. package/lib/components/okrcase-library/okrcases-components/caseLibrary-main.js +14 -8
  14. package/lib/components/range-selector-pop/RangeSelectorPop.js +3 -3
  15. package/lib/components/rich-editor/models/schema.js +6 -6
  16. package/lib/components/rich-editor/plugins/block/block-quote/index.js +8 -8
  17. package/lib/components/rich-editor/plugins/block/heading/index.js +8 -8
  18. package/lib/components/rich-editor/plugins/block/lists/index.js +14 -14
  19. package/lib/components/rich-editor/plugins/block/paragraph/index.js +5 -5
  20. package/lib/components/rich-editor/plugins/core/index.js +4 -4
  21. package/lib/components/rich-editor/plugins/extension/alignment/index.js +5 -5
  22. package/lib/components/rich-editor/plugins/extension/placeholder/index.js +4 -4
  23. package/lib/components/rich-editor/plugins/inline/color/index.js +11 -11
  24. package/lib/components/rich-editor/plugins/inline/delete-line/index.js +8 -8
  25. package/lib/components/rich-editor/plugins/inline/em/index.js +5 -5
  26. package/lib/components/rich-editor/plugins/inline/link/index.js +8 -8
  27. package/lib/components/rich-editor/plugins/inline/strong/index.js +8 -8
  28. package/lib/components/rich-editor/plugins/inline/under-line/index.js +8 -8
  29. package/lib/components/rich-editor/react/uiProvider.js +3 -3
  30. package/lib/components/rich-editor/ui/Popup/index.js +3 -3
  31. package/lib/components/select/Option.js +3 -3
  32. package/lib/components/tita-chart/errorBoundary/index.js +3 -3
  33. package/lib/components-v1/animate/AnimateChild.js +3 -3
  34. package/lib/components-v1/avatar/index.js +3 -3
  35. package/lib/components-v1/dropDownSelector/StatelessDropdown.js +3 -3
  36. package/lib/components-v1/progress/CircleProgress.js +3 -3
  37. package/lib/components-v1/select/Option.js +3 -3
  38. package/lib/components-v1/userSelector/UserSelectorPop.js +3 -3
  39. package/lib/components-v1/userSelector/components/MultiMode/index.js +3 -3
  40. package/lib/components-v1/userSelector/components/UserItem.js +3 -3
  41. package/lib/index.js +0 -8
  42. package/package.json +1 -1
  43. package/es/components/cascader/time.js +0 -31
  44. package/es/components/common-share/request-apis.js +0 -56
  45. package/es/components/confidence/heart.js +0 -66
  46. package/es/components/create-okr-modal/fields/index.js +0 -17
  47. package/es/components/create-okr-modal/utils/getCreateOkrSurpassPercent.js +0 -154
  48. package/es/components/date-picker/BodyItem.js +0 -121
  49. package/es/components/date-picker/CalendarBody.js +0 -157
  50. package/es/components/date-picker/CalendarHeader.js +0 -187
  51. package/es/components/date-picker/index.js +0 -157
  52. package/es/components/date-range-picker/index.js +0 -210
  53. package/es/components/dialog/index.js +0 -119
  54. package/es/components/dialog-confirm/index.js +0 -154
  55. package/es/components/drop-selector/icon-item.js +0 -40
  56. package/es/components/drop-selector/index.js +0 -179
  57. package/es/components/dynamic/dynamic-like-ranking/mock.js +0 -84
  58. package/es/components/dynamic/dynamic-liking/mock.js +0 -83
  59. package/es/components/dynamic/dynamic-topping/request-api.js +0 -36
  60. package/es/components/e-priority/index.js +0 -88
  61. package/es/components/e-status-dropdown/index.js +0 -94
  62. package/es/components/grid-layout/commen-components/index.js +0 -73
  63. package/es/components/grid-layout/image/could.js +0 -8
  64. package/es/components/grid-layout/image/lv.js +0 -8
  65. package/es/components/grid-layout/image/tita-mask.js +0 -8
  66. package/es/components/help-card/request-api.js +0 -35
  67. package/es/components/icon-button-list/index.js +0 -65
  68. package/es/components/menus/context.js +0 -18
  69. package/es/components/menus/precls.js +0 -8
  70. package/es/components/okr-detail/auth.js +0 -197
  71. package/es/components/okr-detail/components/ao-nice/index.js +0 -245
  72. package/es/components/okr-detail/components/block-line/index.js +0 -20
  73. package/es/components/okr-detail/components/header/index.js +0 -211
  74. package/es/components/okr-detail/components/icon-text/index.js +0 -116
  75. package/es/components/okr-detail/components/okr-tree/index.js +0 -48
  76. package/es/components/okr-detail/components/okr-tree/precls.js +0 -8
  77. package/es/components/okr-detail/components/okr-tree/tree-node/default-node.js +0 -22
  78. package/es/components/okr-detail/components/okr-tree/tree-node/e-node/e-priority-dropdown.js +0 -88
  79. package/es/components/okr-detail/components/okr-tree/tree-node/e-node/e-project.js +0 -200
  80. package/es/components/okr-detail/components/okr-tree/tree-node/e-node/e-status-dropdown.js +0 -98
  81. package/es/components/okr-detail/components/okr-tree/tree-node/e-node/e-task-level2.js +0 -412
  82. package/es/components/okr-detail/components/okr-tree/tree-node/get-process-color.js +0 -62
  83. package/es/components/okr-detail/components/okr-tree/tree-node/index.js +0 -90
  84. package/es/components/okr-detail/components/okr-tree/tree-node/kr-node/get-process-color.js +0 -46
  85. package/es/components/okr-detail/components/okr-tree/tree-node/kr-node/index.js +0 -421
  86. package/es/components/okr-detail/components/okr-tree/tree-node/kr-node/kr-score-editor/index.js +0 -54
  87. package/es/components/okr-detail/components/okr-tree/tree-node/kr-node/kr-score-editor/style.js +0 -62
  88. package/es/components/okr-detail/components/okr-tree/tree-node/kr-node/range-picker-pop.js +0 -94
  89. package/es/components/okr-detail/components/okr-tree/tree-node/kr-parent-node/index.js +0 -273
  90. package/es/components/okr-detail/components/okr-tree/tree-node/o-child-node/index.js +0 -207
  91. package/es/components/okr-detail/components/okr-tree/tree-node/o-parent-node/index.js +0 -236
  92. package/es/components/okr-detail/components/padding-layout.js +0 -22
  93. package/es/components/okr-detail/components/tab-panel-content/index.js +0 -27
  94. package/es/components/okr-detail/context.js +0 -30
  95. package/es/components/okr-detail/e-list/index.js +0 -243
  96. package/es/components/okr-detail/e-list/precls.js +0 -8
  97. package/es/components/okr-detail/e-list/search-form/fields/e-order.js +0 -172
  98. package/es/components/okr-detail/e-list/search-form/fields/e-status.js +0 -99
  99. package/es/components/okr-detail/e-list/search-form/fields/e-user.js +0 -49
  100. package/es/components/okr-detail/e-list/search-form/index.js +0 -143
  101. package/es/components/okr-detail/error-page/index.js +0 -33
  102. package/es/components/okr-detail/index.js +0 -428
  103. package/es/components/okr-detail/loading/index.js +0 -28
  104. package/es/components/okr-detail/okr-list/add-parent-okr.js +0 -37
  105. package/es/components/okr-detail/okr-list/create-kr-item/heart.js +0 -38
  106. package/es/components/okr-detail/okr-list/drag-order-kr.js +0 -62
  107. package/es/components/okr-detail/okr-list/empty/index.js +0 -48
  108. package/es/components/okr-detail/okr-list/index.js +0 -524
  109. package/es/components/okr-detail/okr-list/warp-parent-okr.js +0 -21
  110. package/es/components/okr-detail/store.js +0 -1
  111. package/es/components/okr-flow/child-node/fields/creator.js +0 -175
  112. package/es/components/okr-flow/child-node/fields/okrClassify.js +0 -31
  113. package/es/components/okr-flow/child-node/fields/okrType.js +0 -21
  114. package/es/components/okr-flow/child-node/helper.js +0 -35
  115. package/es/components/okr-flow/child-node/index.js +0 -110
  116. package/es/components/okr-flow/child-node/kr-node.js +0 -75
  117. package/es/components/okr-flow/child-node/work-node.js +0 -242
  118. package/es/components/okr-flow/context.js +0 -14
  119. package/es/components/okr-flow/empty/index.js +0 -29
  120. package/es/components/okr-flow/export-modules/okr-search-panel/index.js +0 -394
  121. package/es/components/okr-flow/index.js +0 -24
  122. package/es/components/okr-flow/mini-map/index.js +0 -112
  123. package/es/components/okr-flow/mini-map/map.js +0 -145
  124. package/es/components/okr-flow/mini-map/mini-node.js +0 -57
  125. package/es/components/okr-flow/mini-map/utils.js +0 -79
  126. package/es/components/okr-flow/okr-map/index.js +0 -192
  127. package/es/components/okr-flow/open-data/index.js +0 -115
  128. package/es/components/okr-flow/precls.js +0 -8
  129. package/es/components/okr-flow/request-apis.js +0 -118
  130. package/es/components/okr-flow/root-node/index.js +0 -229
  131. package/es/components/okr-flow/utils/config.js +0 -18
  132. package/es/components/okr-flow/utils/helper.js +0 -36
  133. package/es/components/okr-flow/utils/index.js +0 -66
  134. package/es/components/okr-flow/utils/tree-handler.js +0 -323
  135. package/es/components/okr-progress-modal/helper.js +0 -156
  136. package/es/components/okr-progress-modal/request-apis.js +0 -34
  137. package/es/components/okr-share/request-apis.js +0 -56
  138. package/es/components/okrcase-library/server/network.js +0 -407
  139. package/es/components/pagination/locale/en_US.js +0 -22
  140. package/es/components/pagination/locale/zh_CN.js +0 -22
  141. package/es/components/point-demo/drop-down-box/index.js +0 -159
  142. package/es/components/point-demo/index.js +0 -533
  143. package/es/components/point-demo/input/index.js +0 -176
  144. package/es/components/point-demo/point-demo.js +0 -75
  145. package/es/components/point-demo/popup/index.js +0 -113
  146. package/es/components/point-demo/popup/placement.js +0 -44
  147. package/es/components/range-picker-pop/index.js +0 -273
  148. package/es/components/scrollbar/simplebar/helpers.js +0 -59
  149. package/es/components/scrollbar/simplebar/index.js +0 -91
  150. package/es/components/scrollbar/simplebar/scrollbar-width.js +0 -47
  151. package/es/components/scrollbar/simplebar/simplebar.js +0 -852
  152. package/es/components/scrollbar/simplebar-react.js +0 -163
  153. package/es/components/search-dropdown/index.js +0 -40
  154. package/es/components/search-input/index.js +0 -126
  155. package/es/components/select/Option.js +0 -94
  156. package/es/components/select/index.js +0 -330
  157. package/es/components/selector-input/debounce.js +0 -36
  158. package/es/components/selector-input/index.js +0 -109
  159. package/es/components/slider-input/index.js +0 -119
  160. package/es/components/switch/index.js +0 -39
  161. package/es/components/table/index.js +0 -275
  162. package/es/components/tabs/index.js +0 -63
  163. package/es/components/task-relation-modal/tree-node/index.js +0 -58
  164. package/es/components/tita-chart/charts/img/could.js +0 -8
  165. package/es/components/tooltip/error-tip.js +0 -24
  166. package/es/components/tooltip/index.js +0 -21
  167. package/es/components/tree/index.js +0 -79
  168. package/es/components/tree/precls.js +0 -8
  169. package/es/components/upvote/request-apis.js +0 -45
  170. package/es/components/user-selector/action-btns/btn-cancel.js +0 -21
  171. package/es/components/user-selector/action-btns/btn-ok.js +0 -21
  172. package/es/components/user-selector/action-btns/index.js +0 -27
  173. package/es/components/user-selector/context.js +0 -18
  174. package/es/components/user-selector/empty/group.js +0 -55
  175. package/es/components/user-selector/empty/index.js +0 -28
  176. package/es/components/user-selector/export-modules/depart-search-selector/result-part.js +0 -41
  177. package/es/components/user-selector/export-modules/group-selector/index.js +0 -170
  178. package/es/components/user-selector/export-modules/group-selector/searched-panel.js +0 -68
  179. package/es/components/user-selector/export-modules/multiple-user-selector--bak/index.js +0 -246
  180. package/es/components/user-selector/index.js +0 -25
  181. package/es/components/user-selector/layout/index.js +0 -25
  182. package/es/components/user-selector/loading/index.js +0 -18
  183. package/es/components/user-selector/request-apis.js +0 -180
  184. package/es/components/user-selector/searched-panel/index.js +0 -139
  185. package/es/components/user-selector/searched-panel/result-part.js +0 -43
  186. package/es/components/user-selector/select-tree/selected-tree/index.js +0 -91
  187. package/es/components/user-selector/select-tree/tree-nodes/tree-depart-node/index.js +0 -48
  188. package/es/components/user-selector/select-tree/tree-nodes/tree-duties-node/index.js +0 -27
  189. package/es/components/user-selector/select-tree/tree-nodes/tree-group-node/index.js +0 -57
  190. package/es/components/user-selector/select-tree/tree-nodes/tree-person-node/index.js +0 -93
  191. package/es/components/user-selector/utils.js +0 -139
  192. package/es/components/viewer/ImageListRender.js +0 -143
  193. package/es/components/viewer/index.js +0 -168
  194. package/es/components/word-cloud/index.js +0 -109
  195. package/es/components/word-cloud/request-apis.js +0 -26
  196. package/es/components-v1/animate/AnimateChild.js +0 -76
  197. package/es/components-v1/animate/animate.js +0 -148
  198. package/es/components-v1/animate/index.js +0 -13
  199. package/es/components-v1/dom/index.js +0 -30
  200. package/es/components-v1/placement/index.js +0 -13
  201. package/es/components-v1/placement/placement.js +0 -111
  202. package/es/components-v1/placement/placementInner.js +0 -139
  203. package/es/components-v1/pop/Pop.js +0 -246
  204. package/es/components-v1/pop/PopInner.js +0 -163
  205. package/es/components-v1/pop/index.js +0 -13
  206. package/es/components-v1/progress/CircleProgress.js +0 -152
  207. package/es/components-v1/progress/LineProgress.js +0 -83
  208. package/es/components-v1/progress/index.js +0 -80
  209. package/es/components-v1/select/Option.js +0 -94
  210. package/es/components-v1/select/index.js +0 -330
  211. package/es/components-v1/utils/animate/animate.js +0 -103
  212. package/es/components-v1/utils/animate/event.js +0 -79
  213. package/es/components-v1/utils/dom/index.js +0 -30
  214. package/es/components-v1/utils/placement/autoAdjustPlacement.js +0 -93
  215. package/es/components-v1/utils/placement/getContainerVisibleArea.js +0 -22
  216. package/es/components-v1/utils/placement/getExpectPlacement.js +0 -49
  217. package/es/components-v1/utils/placement/getPlacementInContainer.js +0 -26
  218. package/es/components-v1/utils/placement/placement.js +0 -76
  219. package/es/index.js +0 -777
  220. package/es/pages/appointment-demo/drop-down-box/index.js +0 -159
  221. package/es/pages/appointment-demo/index.js +0 -649
  222. package/es/pages/appointment-demo/input/index.js +0 -176
  223. package/es/pages/appointment-demo/popup/index.js +0 -113
  224. package/es/pages/appointment-demo/popup/placement.js +0 -44
  225. package/es/pages/group-management/components/checkbox/index.js +0 -28
  226. package/es/pages/group-management/components/input-form/index.js +0 -174
  227. package/es/pages/group-management/components/radio/index.js +0 -21
  228. package/es/pages/group-management/components/table/index.js +0 -174
  229. package/es/pages/group-management/groupInterface.js +0 -293
  230. package/es/pages/group-management/index.js +0 -13
  231. package/es/pages/group-management/page-view/empty.js +0 -111
  232. package/es/pages/group-management/page-view/group-empty.js +0 -66
  233. package/es/pages/group-management/page-view/importGroupStaff/index.js +0 -208
  234. package/es/pages/group-management/page-view/index.js +0 -412
  235. package/es/pages/group-management/page-view/loading/index.js +0 -32
  236. package/es/pages/group-management/table/index.js +0 -104
  237. package/es/pages/group-management/tree/add-group-dialog/index.js +0 -153
  238. package/es/pages/group-management/tree/delete-group-dialog/index.js +0 -82
  239. package/es/pages/group-management/tree/edit-group-dialog/index.js +0 -155
  240. package/es/pages/group-management/tree/group-form/index.js +0 -207
  241. package/es/pages/group-management/tree/index.js +0 -168
  242. package/es/pages/group-management/tree/operation-panel.js +0 -41
  243. package/es/pages/group-management/tree/trigger-render.js +0 -99
  244. package/es/pages/like-ranking/mock.js +0 -366
  245. package/es/pages/okr-map/export-modules/index.js +0 -1
  246. package/es/pages/okr-map/export-modules/okr-map/header/index.js +0 -182
  247. package/es/pages/okr-map/export-modules/okr-map/header/show-kr-confirm.js +0 -47
  248. package/es/pages/okr-map/export-modules/okr-map/okr-map.js +0 -497
  249. package/es/pages/okr-map/export-modules/share-okr-page/header/index.js +0 -69
  250. package/es/pages/okr-map/export-modules/share-okr-page/share-okr-map.js +0 -168
  251. package/es/pages/okr-map/hooks/useStorage.js +0 -96
  252. package/es/pages/okr-map/index.js +0 -18
  253. package/es/pages/okr-map/level2-search/depart.js +0 -53
  254. package/es/pages/okr-map/level2-search/group.js +0 -69
  255. package/es/pages/okr-map/level2-search/index.js +0 -51
  256. package/es/pages/okr-map/level2-search/level2-input.js +0 -46
  257. package/es/pages/okr-map/level2-search/user.js +0 -54
  258. package/es/pages/okr-map/no-okr/index.js +0 -24
  259. package/es/pages/okr-map/number-select/index.js +0 -81
  260. package/es/pages/okr-map/open-data/index.js +0 -115
  261. package/es/pages/okr-map/precls.js +0 -8
  262. package/es/pages/okr-map/request-apis.js +0 -76
  263. package/es/pages/okr-map/share-dialog/index.js +0 -122
  264. package/es/pages/okr-map/unsupport-ie/index.js +0 -83
  265. package/es/pages/okr-map/utils.js +0 -51
  266. package/es/utils/auth.js +0 -294
  267. package/es/utils/bs-global.js +0 -114
  268. package/es/utils/local-storage.js +0 -42
  269. package/es/utils/mblog.js +0 -33
  270. package/es/utils/mock-bsglobal.js +0 -1837
  271. package/es/utils/open-data.js +0 -341
  272. package/es/utils/request-v1.js +0 -115
  273. package/es/utils/request.js +0 -183
  274. package/es/utils/tools.js +0 -286
  275. package/lib/components/picker/components/panels/date-panel/date-body.js +0 -116
  276. package/lib/components/picker/components/panels/date-panel/date-head.js +0 -66
  277. package/lib/components/picker/components/panels/date-panel/index.css +0 -14
  278. package/lib/components/picker/components/panels/date-panel/index.js +0 -49
  279. package/lib/components/picker/components/panels/month-panel/index.css +0 -27
  280. package/lib/components/picker/components/panels/month-panel/index.js +0 -63
  281. package/lib/components/picker/components/panels/month-panel/month-body.js +0 -87
  282. package/lib/components/picker/components/panels/month-panel/month-head.js +0 -47
  283. package/lib/components/picker/components/panels/panel-body/index.js +0 -53
  284. package/lib/components/picker/components/panels/panel-head/index.js +0 -48
  285. package/lib/components/picker/components/panels/year-panel/index.css +0 -23
  286. package/lib/components/picker/components/panels/year-panel/index.js +0 -65
  287. package/lib/components/picker/components/panels/year-panel/year-body.js +0 -92
  288. package/lib/components/picker/components/panels/year-panel/year-head.js +0 -35
  289. package/lib/components/picker/components/picker-trigger/index.css +0 -26
  290. package/lib/components/picker/components/picker-trigger/index.js +0 -85
  291. package/lib/components/picker/context.js +0 -15
  292. package/lib/components/picker/index.css +0 -121
  293. package/lib/components/picker/index.js +0 -13
  294. package/lib/components/picker/picker-panels.js +0 -182
  295. package/lib/components/picker/picker.js +0 -133
  296. package/lib/components/picker/type.js +0 -5
  297. package/lib/components/picker/utils.js +0 -28
  298. package/yarn-error.log +0 -21252
@@ -1,852 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _lodash = _interopRequireDefault(require("lodash.throttle"));
9
-
10
- var _lodash2 = _interopRequireDefault(require("lodash.debounce"));
11
-
12
- var _lodash3 = _interopRequireDefault(require("lodash.memoize"));
13
-
14
- var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
15
-
16
- var _canUseDom = _interopRequireDefault(require("can-use-dom"));
17
-
18
- var _scrollbarWidth = _interopRequireDefault(require("./scrollbar-width"));
19
-
20
- var _helpers = require("./helpers");
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
-
28
- 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; }
29
-
30
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
31
-
32
- 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); } }
33
-
34
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
35
-
36
- var SimpleBar = /*#__PURE__*/function () {
37
- function SimpleBar(element, options) {
38
- var _this = this;
39
-
40
- _classCallCheck(this, SimpleBar);
41
-
42
- this.onScroll = function () {
43
- var elWindow = (0, _helpers.getElementWindow)(_this.el);
44
-
45
- if (!_this.scrollXTicking) {
46
- elWindow.requestAnimationFrame(_this.scrollX);
47
- _this.scrollXTicking = true;
48
- }
49
-
50
- if (!_this.scrollYTicking) {
51
- elWindow.requestAnimationFrame(_this.scrollY);
52
- _this.scrollYTicking = true;
53
- }
54
- };
55
-
56
- this.scrollX = function () {
57
- if (_this.axis.x.isOverflowing) {
58
- _this.showScrollbar("x");
59
-
60
- _this.positionScrollbar("x");
61
- }
62
-
63
- _this.scrollXTicking = false;
64
- };
65
-
66
- this.scrollY = function () {
67
- if (_this.axis.y.isOverflowing) {
68
- _this.showScrollbar("y");
69
-
70
- _this.positionScrollbar("y");
71
- }
72
-
73
- _this.scrollYTicking = false;
74
- };
75
-
76
- this.onMouseEnter = function () {
77
- _this.showScrollbar("x");
78
-
79
- _this.showScrollbar("y");
80
- };
81
-
82
- this.onMouseMove = function (e) {
83
- _this.mouseX = e.clientX;
84
- _this.mouseY = e.clientY;
85
-
86
- if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
87
- _this.onMouseMoveForAxis("x");
88
- }
89
-
90
- if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
91
- _this.onMouseMoveForAxis("y");
92
- }
93
- };
94
-
95
- this.onMouseLeave = function () {
96
- _this.onMouseMove.cancel();
97
-
98
- if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
99
- _this.onMouseLeaveForAxis("x");
100
- }
101
-
102
- if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
103
- _this.onMouseLeaveForAxis("y");
104
- }
105
-
106
- _this.mouseX = -1;
107
- _this.mouseY = -1;
108
- };
109
-
110
- this.onWindowResize = function () {
111
- // Recalculate scrollbarWidth in case it's a zoom
112
- _this.scrollbarWidth = _this.getScrollbarWidth();
113
-
114
- _this.hideNativeScrollbar();
115
- };
116
-
117
- this.hideScrollbars = function () {
118
- _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
119
- _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
120
-
121
- if (!_this.isWithinBounds(_this.axis.y.track.rect)) {
122
- _this.axis.y.scrollbar.el.classList.remove(_this.classNames.visible);
123
-
124
- _this.axis.y.isVisible = false;
125
- }
126
-
127
- if (!_this.isWithinBounds(_this.axis.x.track.rect)) {
128
- _this.axis.x.scrollbar.el.classList.remove(_this.classNames.visible);
129
-
130
- _this.axis.x.isVisible = false;
131
- }
132
- };
133
-
134
- this.onPointerEvent = function (e) {
135
- var isWithinTrackXBounds;
136
- var isWithinTrackYBounds;
137
- _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
138
- _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
139
-
140
- if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
141
- isWithinTrackXBounds = _this.isWithinBounds(_this.axis.x.track.rect);
142
- }
143
-
144
- if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
145
- isWithinTrackYBounds = _this.isWithinBounds(_this.axis.y.track.rect);
146
- } // If any pointer event is called on the scrollbar
147
-
148
-
149
- if (isWithinTrackXBounds || isWithinTrackYBounds) {
150
- // Preventing the event's default action stops text being
151
- // selectable during the drag.
152
- e.preventDefault(); // Prevent event leaking
153
-
154
- e.stopPropagation();
155
-
156
- if (e.type === "mousedown") {
157
- if (isWithinTrackXBounds) {
158
- _this.axis.x.scrollbar.rect = _this.axis.x.scrollbar.el.getBoundingClientRect();
159
-
160
- if (_this.isWithinBounds(_this.axis.x.scrollbar.rect)) {
161
- _this.onDragStart(e, "x");
162
- } else {
163
- _this.onTrackClick(e, "x");
164
- }
165
- }
166
-
167
- if (isWithinTrackYBounds) {
168
- _this.axis.y.scrollbar.rect = _this.axis.y.scrollbar.el.getBoundingClientRect();
169
-
170
- if (_this.isWithinBounds(_this.axis.y.scrollbar.rect)) {
171
- _this.onDragStart(e, "y");
172
- } else {
173
- _this.onTrackClick(e, "y");
174
- }
175
- }
176
- }
177
- }
178
- };
179
-
180
- this.drag = function (e) {
181
- var eventOffset;
182
- var track = _this.axis[_this.draggedAxis].track;
183
- var trackSize = track.rect[_this.axis[_this.draggedAxis].sizeAttr];
184
- var scrollbar = _this.axis[_this.draggedAxis].scrollbar;
185
- var contentSize = _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollSizeAttr];
186
- var hostSize = parseInt(_this.elStyles[_this.axis[_this.draggedAxis].sizeAttr], 10);
187
- e.preventDefault();
188
- e.stopPropagation();
189
-
190
- if (_this.draggedAxis === "y") {
191
- eventOffset = e.pageY;
192
- } else {
193
- eventOffset = e.pageX;
194
- } // Calculate how far the user's mouse is from the top/left of the scrollbar (minus the dragOffset).
195
-
196
-
197
- var dragPos = eventOffset - track.rect[_this.axis[_this.draggedAxis].offsetAttr] - _this.axis[_this.draggedAxis].dragOffset; // Convert the mouse position into a percentage of the scrollbar height/width.
198
-
199
- var dragPerc = dragPos / (trackSize - scrollbar.size); // Scroll the content by the same percentage.
200
-
201
- var scrollPos = dragPerc * (contentSize - hostSize); // Fix browsers inconsistency on RTL
202
-
203
- if (_this.draggedAxis === "x") {
204
- scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? scrollPos - (trackSize + scrollbar.size) : scrollPos;
205
- scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollPos : scrollPos;
206
- }
207
-
208
- _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollOffsetAttr] = scrollPos;
209
- };
210
-
211
- this.onEndDrag = function (e) {
212
- var elDocument = (0, _helpers.getElementDocument)(_this.el);
213
- var elWindow = (0, _helpers.getElementWindow)(_this.el);
214
- e.preventDefault();
215
- e.stopPropagation();
216
-
217
- _this.el.classList.remove(_this.classNames.dragging);
218
-
219
- elDocument.removeEventListener("mousemove", _this.drag, true);
220
- elDocument.removeEventListener("mouseup", _this.onEndDrag, true);
221
- _this.removePreventClickId = elWindow.setTimeout(function () {
222
- // Remove these asynchronously so we still suppress click events
223
- // generated simultaneously with mouseup.
224
- elDocument.removeEventListener("click", _this.preventClick, true);
225
- elDocument.removeEventListener("dblclick", _this.preventClick, true);
226
- _this.removePreventClickId = null;
227
- });
228
- };
229
-
230
- this.preventClick = function (e) {
231
- e.preventDefault();
232
- e.stopPropagation();
233
- };
234
-
235
- this.el = element;
236
- this.minScrollbarWidth = 20;
237
- this.options = _objectSpread(_objectSpread({}, SimpleBar.defaultOptions), options);
238
- this.classNames = _objectSpread(_objectSpread({}, SimpleBar.defaultOptions.classNames), this.options.classNames);
239
- this.axis = {
240
- x: {
241
- scrollOffsetAttr: "scrollLeft",
242
- sizeAttr: "width",
243
- scrollSizeAttr: "scrollWidth",
244
- offsetSizeAttr: "offsetWidth",
245
- offsetAttr: "left",
246
- overflowAttr: "overflowX",
247
- dragOffset: 0,
248
- isOverflowing: true,
249
- isVisible: false,
250
- forceVisible: false,
251
- track: {},
252
- scrollbar: {}
253
- },
254
- y: {
255
- scrollOffsetAttr: "scrollTop",
256
- sizeAttr: "height",
257
- scrollSizeAttr: "scrollHeight",
258
- offsetSizeAttr: "offsetHeight",
259
- offsetAttr: "top",
260
- overflowAttr: "overflowY",
261
- dragOffset: 0,
262
- isOverflowing: true,
263
- isVisible: false,
264
- forceVisible: false,
265
- track: {},
266
- scrollbar: {}
267
- }
268
- };
269
- this.removePreventClickId = null; // Don't re-instantiate over an existing one
270
-
271
- if (SimpleBar.instances.has(this.el)) {
272
- return;
273
- } // Tita TODO: 修改 64 到 1,解决卡顿问题
274
-
275
-
276
- this.recalculate = (0, _lodash["default"])(this.recalculate.bind(this), 1);
277
- this.onMouseMove = (0, _lodash["default"])(this.onMouseMove.bind(this), 64);
278
- this.hideScrollbars = (0, _lodash2["default"])(this.hideScrollbars.bind(this), this.options.timeout);
279
- this.onWindowResize = (0, _lodash2["default"])(this.onWindowResize.bind(this), 64, {
280
- leading: true
281
- });
282
- SimpleBar.getRtlHelpers = (0, _lodash3["default"])(SimpleBar.getRtlHelpers);
283
- this.init();
284
- }
285
- /**
286
- * Static properties
287
- */
288
-
289
- /**
290
- * Helper to fix browsers inconsistency on RTL:
291
- * - Firefox inverts the scrollbar initial position
292
- * - IE11 inverts both scrollbar position and scrolling offset
293
- * Directly inspired by @KingSora's OverlayScrollbars https://github.com/KingSora/OverlayScrollbars/blob/master/js/OverlayScrollbars.js#L1634
294
- */
295
-
296
-
297
- _createClass(SimpleBar, [{
298
- key: "init",
299
- value: function init() {
300
- // Save a reference to the instance, so we know this DOM node has already been instancied
301
- SimpleBar.instances.set(this.el, this); // We stop here on server-side
302
-
303
- if (_canUseDom["default"]) {
304
- this.initDOM();
305
- this.setAccessibilityAttributes();
306
- this.scrollbarWidth = this.getScrollbarWidth();
307
- this.recalculate();
308
- this.initListeners();
309
- }
310
- }
311
- }, {
312
- key: "initDOM",
313
- value: function initDOM() {
314
- var _this2 = this;
315
-
316
- // make sure this element doesn't have the elements yet
317
- if (Array.prototype.filter.call(this.el.children, function (child) {
318
- return child.classList.contains(_this2.classNames.wrapper);
319
- }).length) {
320
- // assume that element has his DOM already initiated
321
- this.wrapperEl = this.el.querySelector(".".concat(this.classNames.wrapper));
322
- this.contentWrapperEl = this.options.scrollableNode || this.el.querySelector(".".concat(this.classNames.contentWrapper));
323
- this.contentEl = this.options.contentNode || this.el.querySelector(".".concat(this.classNames.contentEl));
324
- this.offsetEl = this.el.querySelector(".".concat(this.classNames.offset));
325
- this.maskEl = this.el.querySelector(".".concat(this.classNames.mask));
326
- this.placeholderEl = this.findChild(this.wrapperEl, ".".concat(this.classNames.placeholder));
327
- this.heightAutoObserverWrapperEl = this.el.querySelector(".".concat(this.classNames.heightAutoObserverWrapperEl));
328
- this.heightAutoObserverEl = this.el.querySelector(".".concat(this.classNames.heightAutoObserverEl));
329
- this.axis.x.track.el = this.findChild(this.el, ".".concat(this.classNames.track, ".").concat(this.classNames.horizontal));
330
- this.axis.y.track.el = this.findChild(this.el, ".".concat(this.classNames.track, ".").concat(this.classNames.vertical));
331
- } else {
332
- // Prepare DOM
333
- this.wrapperEl = document.createElement("div");
334
- this.contentWrapperEl = document.createElement("div");
335
- this.offsetEl = document.createElement("div");
336
- this.maskEl = document.createElement("div");
337
- this.contentEl = document.createElement("div");
338
- this.placeholderEl = document.createElement("div");
339
- this.heightAutoObserverWrapperEl = document.createElement("div");
340
- this.heightAutoObserverEl = document.createElement("div");
341
- this.wrapperEl.classList.add(this.classNames.wrapper);
342
- this.contentWrapperEl.classList.add(this.classNames.contentWrapper);
343
- this.offsetEl.classList.add(this.classNames.offset);
344
- this.maskEl.classList.add(this.classNames.mask);
345
- this.contentEl.classList.add(this.classNames.contentEl);
346
- this.placeholderEl.classList.add(this.classNames.placeholder);
347
- this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl);
348
- this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);
349
-
350
- while (this.el.firstChild) {
351
- this.contentEl.appendChild(this.el.firstChild);
352
- }
353
-
354
- this.contentWrapperEl.appendChild(this.contentEl);
355
- this.offsetEl.appendChild(this.contentWrapperEl);
356
- this.maskEl.appendChild(this.offsetEl);
357
- this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl);
358
- this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl);
359
- this.wrapperEl.appendChild(this.maskEl);
360
- this.wrapperEl.appendChild(this.placeholderEl);
361
- this.el.appendChild(this.wrapperEl);
362
- }
363
-
364
- if (!this.axis.x.track.el || !this.axis.y.track.el) {
365
- var track = document.createElement("div");
366
- var scrollbar = document.createElement("div");
367
- track.classList.add(this.classNames.track);
368
- scrollbar.classList.add(this.classNames.scrollbar);
369
- track.appendChild(scrollbar);
370
- this.axis.x.track.el = track.cloneNode(true);
371
- this.axis.x.track.el.classList.add(this.classNames.horizontal);
372
- this.axis.y.track.el = track.cloneNode(true);
373
- this.axis.y.track.el.classList.add(this.classNames.vertical);
374
- this.el.appendChild(this.axis.x.track.el);
375
- this.el.appendChild(this.axis.y.track.el);
376
- }
377
-
378
- this.axis.x.scrollbar.el = this.axis.x.track.el.querySelector(".".concat(this.classNames.scrollbar));
379
- this.axis.y.scrollbar.el = this.axis.y.track.el.querySelector(".".concat(this.classNames.scrollbar));
380
-
381
- if (!this.options.autoHide) {
382
- this.axis.x.scrollbar.el.classList.add(this.classNames.visible);
383
- this.axis.y.scrollbar.el.classList.add(this.classNames.visible);
384
- }
385
-
386
- this.el.setAttribute("data-simplebar", "init");
387
- }
388
- }, {
389
- key: "setAccessibilityAttributes",
390
- value: function setAccessibilityAttributes() {
391
- var ariaLabel = this.options.ariaLabel || "scrollable content";
392
- this.contentWrapperEl.setAttribute("tabindex", "0");
393
- this.contentWrapperEl.setAttribute("role", "region");
394
- this.contentWrapperEl.setAttribute("aria-label", ariaLabel);
395
- }
396
- }, {
397
- key: "initListeners",
398
- value: function initListeners() {
399
- var _this3 = this;
400
-
401
- var elWindow = (0, _helpers.getElementWindow)(this.el); // Event listeners
402
-
403
- if (this.options.autoHide) {
404
- this.el.addEventListener("mouseenter", this.onMouseEnter);
405
- }
406
-
407
- ["mousedown", "click", "dblclick"].forEach(function (e) {
408
- _this3.el.addEventListener(e, _this3.onPointerEvent, true);
409
- });
410
- ["touchstart", "touchend", "touchmove"].forEach(function (e) {
411
- _this3.el.addEventListener(e, _this3.onPointerEvent, {
412
- capture: true,
413
- passive: true
414
- });
415
- });
416
- this.el.addEventListener("mousemove", this.onMouseMove);
417
- this.el.addEventListener("mouseleave", this.onMouseLeave);
418
- this.contentWrapperEl.addEventListener("scroll", this.onScroll); // Browser zoom triggers a window resize
419
-
420
- elWindow.addEventListener("resize", this.onWindowResize); // Hack for https://github.com/WICG/ResizeObserver/issues/38
421
-
422
- var resizeObserverStarted = false;
423
- var resizeObserver = elWindow.ResizeObserver || _resizeObserverPolyfill["default"];
424
- this.resizeObserver = new resizeObserver(function () {
425
- if (!resizeObserverStarted) return;
426
-
427
- _this3.recalculate();
428
- });
429
- this.resizeObserver.observe(this.el);
430
- this.resizeObserver.observe(this.contentEl);
431
- elWindow.requestAnimationFrame(function () {
432
- resizeObserverStarted = true;
433
- }); // This is required to detect horizontal scroll. Vertical scroll only needs the resizeObserver.
434
-
435
- this.mutationObserver = new elWindow.MutationObserver(this.recalculate);
436
- this.mutationObserver.observe(this.contentEl, {
437
- childList: true,
438
- subtree: true,
439
- characterData: true
440
- });
441
- }
442
- }, {
443
- key: "recalculate",
444
- value: function recalculate() {
445
- var elWindow = (0, _helpers.getElementWindow)(this.el);
446
- this.elStyles = elWindow.getComputedStyle(this.el);
447
- this.isRtl = this.elStyles.direction === "rtl";
448
- var isHeightAuto = this.heightAutoObserverEl.offsetHeight <= 1;
449
- var isWidthAuto = this.heightAutoObserverEl.offsetWidth <= 1;
450
- var contentElOffsetWidth = this.contentEl.offsetWidth;
451
- var contentWrapperElOffsetWidth = this.contentWrapperEl.offsetWidth;
452
- var elOverflowX = this.elStyles.overflowX;
453
- var elOverflowY = this.elStyles.overflowY;
454
- this.contentEl.style.padding = "".concat(this.elStyles.paddingTop, " ").concat(this.elStyles.paddingRight, " ").concat(this.elStyles.paddingBottom, " ").concat(this.elStyles.paddingLeft);
455
- this.wrapperEl.style.margin = "-".concat(this.elStyles.paddingTop, " -").concat(this.elStyles.paddingRight, " -").concat(this.elStyles.paddingBottom, " -").concat(this.elStyles.paddingLeft);
456
- var contentElScrollHeight = this.contentEl.scrollHeight;
457
- var contentElScrollWidth = this.contentEl.scrollWidth;
458
- this.contentWrapperEl.style.height = isHeightAuto ? "auto" : "100%"; // Determine placeholder size
459
-
460
- this.placeholderEl.style.width = isWidthAuto ? "".concat(contentElOffsetWidth, "px") : "auto";
461
- this.placeholderEl.style.height = "".concat(contentElScrollHeight, "px");
462
- var contentWrapperElOffsetHeight = this.contentWrapperEl.offsetHeight;
463
- this.axis.x.isOverflowing = contentElScrollWidth > contentElOffsetWidth;
464
- this.axis.y.isOverflowing = contentElScrollHeight > contentWrapperElOffsetHeight; // Set isOverflowing to false if user explicitely set hidden overflow
465
-
466
- this.axis.x.isOverflowing = elOverflowX === "hidden" ? false : this.axis.x.isOverflowing;
467
- this.axis.y.isOverflowing = elOverflowY === "hidden" ? false : this.axis.y.isOverflowing;
468
- this.axis.x.forceVisible = this.options.forceVisible === "x" || this.options.forceVisible === true;
469
- this.axis.y.forceVisible = this.options.forceVisible === "y" || this.options.forceVisible === true;
470
- this.hideNativeScrollbar(); // Set isOverflowing to false if scrollbar is not necessary (content is shorter than offset)
471
-
472
- var offsetForXScrollbar = this.axis.x.isOverflowing ? this.scrollbarWidth : 0;
473
- var offsetForYScrollbar = this.axis.y.isOverflowing ? this.scrollbarWidth : 0;
474
- this.axis.x.isOverflowing = this.axis.x.isOverflowing && contentElScrollWidth > contentWrapperElOffsetWidth - offsetForYScrollbar;
475
- this.axis.y.isOverflowing = this.axis.y.isOverflowing && contentElScrollHeight > contentWrapperElOffsetHeight - offsetForXScrollbar;
476
- this.axis.x.scrollbar.size = this.getScrollbarSize("x");
477
- this.axis.y.scrollbar.size = this.getScrollbarSize("y");
478
- this.axis.x.scrollbar.el.style.width = "".concat(this.axis.x.scrollbar.size, "px");
479
- this.axis.y.scrollbar.el.style.height = "".concat(this.axis.y.scrollbar.size, "px");
480
- this.positionScrollbar("x");
481
- this.positionScrollbar("y");
482
- this.toggleTrackVisibility("x");
483
- this.toggleTrackVisibility("y");
484
- }
485
- /**
486
- * Calculate scrollbar size
487
- */
488
-
489
- }, {
490
- key: "getScrollbarSize",
491
- value: function getScrollbarSize() {
492
- var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
493
-
494
- if (!this.axis[axis].isOverflowing) {
495
- return 0;
496
- }
497
-
498
- var contentSize = this.contentEl[this.axis[axis].scrollSizeAttr];
499
- var trackSize = this.axis[axis].track.el[this.axis[axis].offsetSizeAttr];
500
- var scrollbarSize;
501
- var scrollbarRatio = trackSize / contentSize; // Calculate new height/position of drag handle.
502
-
503
- scrollbarSize = Math.max(~~(scrollbarRatio * trackSize), this.options.scrollbarMinSize);
504
-
505
- if (this.options.scrollbarMaxSize) {
506
- scrollbarSize = Math.min(scrollbarSize, this.options.scrollbarMaxSize);
507
- }
508
-
509
- return scrollbarSize;
510
- }
511
- }, {
512
- key: "positionScrollbar",
513
- value: function positionScrollbar() {
514
- var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
515
-
516
- if (!this.axis[axis].isOverflowing) {
517
- return;
518
- }
519
-
520
- var contentSize = this.contentWrapperEl[this.axis[axis].scrollSizeAttr];
521
- var trackSize = this.axis[axis].track.el[this.axis[axis].offsetSizeAttr];
522
- var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
523
- var scrollbar = this.axis[axis].scrollbar;
524
- var scrollOffset = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
525
- scrollOffset = axis === "x" && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollOffset : scrollOffset;
526
- var scrollPourcent = scrollOffset / (contentSize - hostSize);
527
- var handleOffset = ~~((trackSize - scrollbar.size) * scrollPourcent);
528
- handleOffset = axis === "x" && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? handleOffset + (trackSize - scrollbar.size) : handleOffset;
529
- scrollbar.el.style.transform = axis === "x" ? "translate3d(".concat(handleOffset, "px, 0, 0)") : "translate3d(0, ".concat(handleOffset, "px, 0)");
530
- }
531
- }, {
532
- key: "toggleTrackVisibility",
533
- value: function toggleTrackVisibility() {
534
- var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
535
- var track = this.axis[axis].track.el;
536
- var scrollbar = this.axis[axis].scrollbar.el;
537
-
538
- if (this.axis[axis].isOverflowing || this.axis[axis].forceVisible) {
539
- track.style.visibility = "visible";
540
- this.contentWrapperEl.style[this.axis[axis].overflowAttr] = "scroll";
541
- } else {
542
- track.style.visibility = "hidden";
543
- this.contentWrapperEl.style[this.axis[axis].overflowAttr] = "hidden";
544
- } // Even if forceVisible is enabled, scrollbar itself should be hidden
545
-
546
-
547
- if (this.axis[axis].isOverflowing) {
548
- scrollbar.style.display = "block";
549
- } else {
550
- scrollbar.style.display = "none";
551
- }
552
- }
553
- }, {
554
- key: "hideNativeScrollbar",
555
- value: function hideNativeScrollbar() {
556
- this.offsetEl.style[this.isRtl ? "left" : "right"] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? "-".concat(this.scrollbarWidth, "px") : 0;
557
- this.offsetEl.style.bottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? "-".concat(this.scrollbarWidth, "px") : 0;
558
- }
559
- /**
560
- * On scroll event handling
561
- */
562
-
563
- }, {
564
- key: "onMouseMoveForAxis",
565
- value: function onMouseMoveForAxis() {
566
- var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
567
- this.axis[axis].track.rect = this.axis[axis].track.el.getBoundingClientRect();
568
- this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
569
- var isWithinScrollbarBoundsX = this.isWithinBounds(this.axis[axis].scrollbar.rect);
570
-
571
- if (isWithinScrollbarBoundsX) {
572
- this.axis[axis].scrollbar.el.classList.add(this.classNames.hover);
573
- } else {
574
- this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
575
- }
576
-
577
- if (this.isWithinBounds(this.axis[axis].track.rect)) {
578
- this.showScrollbar(axis);
579
- this.axis[axis].track.el.classList.add(this.classNames.hover);
580
- } else {
581
- this.axis[axis].track.el.classList.remove(this.classNames.hover);
582
- }
583
- }
584
- }, {
585
- key: "onMouseLeaveForAxis",
586
- value: function onMouseLeaveForAxis() {
587
- var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
588
- this.axis[axis].track.el.classList.remove(this.classNames.hover);
589
- this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
590
- }
591
- }, {
592
- key: "showScrollbar",
593
- value:
594
- /**
595
- * Show scrollbar
596
- */
597
- function showScrollbar() {
598
- var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "y";
599
- var scrollbar = this.axis[axis].scrollbar.el;
600
-
601
- if (!this.axis[axis].isVisible) {
602
- scrollbar.classList.add(this.classNames.visible);
603
- this.axis[axis].isVisible = true;
604
- }
605
-
606
- if (this.options.autoHide) {
607
- this.hideScrollbars();
608
- }
609
- }
610
- /**
611
- * Hide Scrollbar
612
- */
613
-
614
- }, {
615
- key: "onDragStart",
616
- value:
617
- /**
618
- * on scrollbar handle drag movement starts
619
- */
620
- function onDragStart(e) {
621
- var axis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "y";
622
- var elDocument = (0, _helpers.getElementDocument)(this.el);
623
- var elWindow = (0, _helpers.getElementWindow)(this.el);
624
- var scrollbar = this.axis[axis].scrollbar; // Measure how far the user's mouse is from the top of the scrollbar drag handle.
625
-
626
- var eventOffset = axis === "y" ? e.pageY : e.pageX;
627
- this.axis[axis].dragOffset = eventOffset - scrollbar.rect[this.axis[axis].offsetAttr];
628
- this.draggedAxis = axis;
629
- this.el.classList.add(this.classNames.dragging);
630
- elDocument.addEventListener("mousemove", this.drag, true);
631
- elDocument.addEventListener("mouseup", this.onEndDrag, true);
632
-
633
- if (this.removePreventClickId === null) {
634
- elDocument.addEventListener("click", this.preventClick, true);
635
- elDocument.addEventListener("dblclick", this.preventClick, true);
636
- } else {
637
- elWindow.clearTimeout(this.removePreventClickId);
638
- this.removePreventClickId = null;
639
- }
640
- }
641
- /**
642
- * Drag scrollbar handle
643
- */
644
-
645
- }, {
646
- key: "onTrackClick",
647
- value: function onTrackClick(e) {
648
- var _this4 = this;
649
-
650
- var axis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "y";
651
- if (!this.options.clickOnTrack) return;
652
- var elWindow = (0, _helpers.getElementWindow)(this.el);
653
- this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
654
- var scrollbar = this.axis[axis].scrollbar;
655
- var scrollbarOffset = scrollbar.rect[this.axis[axis].offsetAttr];
656
- var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
657
- var scrolled = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
658
- var t = axis === "y" ? this.mouseY - scrollbarOffset : this.mouseX - scrollbarOffset;
659
- var dir = t < 0 ? -1 : 1;
660
- var scrollSize = dir === -1 ? scrolled - hostSize : scrolled + hostSize;
661
-
662
- var scrollTo = function scrollTo() {
663
- if (dir === -1) {
664
- if (scrolled > scrollSize) {
665
- scrolled -= _this4.options.clickOnTrackSpeed;
666
-
667
- _this4.contentWrapperEl.scrollTo(_defineProperty({}, _this4.axis[axis].offsetAttr, scrolled));
668
-
669
- elWindow.requestAnimationFrame(scrollTo);
670
- }
671
- } else if (scrolled < scrollSize) {
672
- scrolled += _this4.options.clickOnTrackSpeed;
673
-
674
- _this4.contentWrapperEl.scrollTo(_defineProperty({}, _this4.axis[axis].offsetAttr, scrolled));
675
-
676
- elWindow.requestAnimationFrame(scrollTo);
677
- }
678
- };
679
-
680
- scrollTo();
681
- }
682
- /**
683
- * Getter for content element
684
- */
685
-
686
- }, {
687
- key: "getContentElement",
688
- value: function getContentElement() {
689
- return this.contentEl;
690
- }
691
- /**
692
- * Getter for original scrolling element
693
- */
694
-
695
- }, {
696
- key: "getScrollElement",
697
- value: function getScrollElement() {
698
- return this.contentWrapperEl;
699
- }
700
- }, {
701
- key: "getScrollbarWidth",
702
- value: function getScrollbarWidth() {
703
- // Try/catch for FF 56 throwing on undefined computedStyles
704
- try {
705
- // Detect browsers supporting CSS scrollbar styling and do not calculate
706
- if (getComputedStyle(this.contentWrapperEl, "::-webkit-scrollbar").display === "none" || "scrollbarWidth" in document.documentElement.style || "-ms-overflow-style" in document.documentElement.style) {
707
- return 0;
708
- }
709
-
710
- return (0, _scrollbarWidth["default"])(this.el);
711
- } catch (e) {
712
- return (0, _scrollbarWidth["default"])(this.el);
713
- }
714
- }
715
- }, {
716
- key: "removeListeners",
717
- value: function removeListeners() {
718
- var _this5 = this;
719
-
720
- var elWindow = (0, _helpers.getElementWindow)(this.el); // Event listeners
721
-
722
- if (this.options.autoHide) {
723
- this.el.removeEventListener("mouseenter", this.onMouseEnter);
724
- }
725
-
726
- ["mousedown", "click", "dblclick"].forEach(function (e) {
727
- _this5.el.removeEventListener(e, _this5.onPointerEvent, true);
728
- });
729
- ["touchstart", "touchend", "touchmove"].forEach(function (e) {
730
- _this5.el.removeEventListener(e, _this5.onPointerEvent, {
731
- capture: true,
732
- passive: true
733
- });
734
- });
735
- this.el.removeEventListener("mousemove", this.onMouseMove);
736
- this.el.removeEventListener("mouseleave", this.onMouseLeave);
737
-
738
- if (this.contentWrapperEl) {
739
- this.contentWrapperEl.removeEventListener("scroll", this.onScroll);
740
- }
741
-
742
- elWindow.removeEventListener("resize", this.onWindowResize);
743
-
744
- if (this.mutationObserver) {
745
- this.mutationObserver.disconnect();
746
- }
747
-
748
- if (this.resizeObserver) {
749
- this.resizeObserver.disconnect();
750
- } // Cancel all debounced functions
751
-
752
-
753
- this.recalculate.cancel();
754
- this.onMouseMove.cancel();
755
- this.hideScrollbars.cancel();
756
- this.onWindowResize.cancel();
757
- }
758
- /**
759
- * UnMount mutation observer and delete SimpleBar instance from DOM element
760
- */
761
-
762
- }, {
763
- key: "unMount",
764
- value: function unMount() {
765
- this.removeListeners();
766
- SimpleBar.instances["delete"](this.el);
767
- }
768
- /**
769
- * Check if mouse is within bounds
770
- */
771
-
772
- }, {
773
- key: "isWithinBounds",
774
- value: function isWithinBounds(bbox) {
775
- return this.mouseX >= bbox.left && this.mouseX <= bbox.left + bbox.width && this.mouseY >= bbox.top && this.mouseY <= bbox.top + bbox.height;
776
- }
777
- /**
778
- * Find element children matches query
779
- */
780
-
781
- }, {
782
- key: "findChild",
783
- value: function findChild(el, query) {
784
- var matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
785
- return Array.prototype.filter.call(el.children, function (child) {
786
- return matches.call(child, query);
787
- })[0];
788
- }
789
- }], [{
790
- key: "getRtlHelpers",
791
- value: function getRtlHelpers() {
792
- var dummyDiv = document.createElement("div");
793
- dummyDiv.innerHTML = "<div class=\"hs-dummy-scrollbar-size\"><div style=\"height: 200%; width: 200%; margin: 10px 0;\"></div></div>";
794
- var scrollbarDummyEl = dummyDiv.firstElementChild;
795
- document.body.appendChild(scrollbarDummyEl);
796
- var dummyContainerChild = scrollbarDummyEl.firstElementChild;
797
- scrollbarDummyEl.scrollLeft = 0;
798
- var dummyContainerOffset = SimpleBar.getOffset(scrollbarDummyEl);
799
- var dummyContainerChildOffset = SimpleBar.getOffset(dummyContainerChild);
800
- scrollbarDummyEl.scrollLeft = 999;
801
- var dummyContainerScrollOffsetAfterScroll = SimpleBar.getOffset(dummyContainerChild);
802
- return {
803
- // determines if the scrolling is responding with negative values
804
- isRtlScrollingInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left && dummyContainerChildOffset.left - dummyContainerScrollOffsetAfterScroll.left !== 0,
805
- // determines if the origin scrollbar position is inverted or not (positioned on left or right)
806
- isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
807
- };
808
- }
809
- }, {
810
- key: "getOffset",
811
- value: function getOffset(el) {
812
- var rect = el.getBoundingClientRect();
813
- var elDocument = (0, _helpers.getElementDocument)(el);
814
- var elWindow = (0, _helpers.getElementWindow)(el);
815
- return {
816
- top: rect.top + (elWindow.pageYOffset || elDocument.documentElement.scrollTop),
817
- left: rect.left + (elWindow.pageXOffset || elDocument.documentElement.scrollLeft)
818
- };
819
- }
820
- }]);
821
-
822
- return SimpleBar;
823
- }();
824
-
825
- exports["default"] = SimpleBar;
826
- SimpleBar.defaultOptions = {
827
- autoHide: true,
828
- forceVisible: false,
829
- clickOnTrack: true,
830
- clickOnTrackSpeed: 40,
831
- classNames: {
832
- contentEl: "simplebar-content",
833
- contentWrapper: "simplebar-content-wrapper",
834
- offset: "simplebar-offset",
835
- mask: "simplebar-mask",
836
- wrapper: "simplebar-wrapper",
837
- placeholder: "simplebar-placeholder",
838
- scrollbar: "simplebar-scrollbar",
839
- track: "simplebar-track",
840
- heightAutoObserverWrapperEl: "simplebar-height-auto-observer-wrapper",
841
- heightAutoObserverEl: "simplebar-height-auto-observer",
842
- visible: "simplebar-visible",
843
- horizontal: "simplebar-horizontal",
844
- vertical: "simplebar-vertical",
845
- hover: "simplebar-hover",
846
- dragging: "simplebar-dragging"
847
- },
848
- scrollbarMinSize: 25,
849
- scrollbarMaxSize: 0,
850
- timeout: 1000
851
- };
852
- SimpleBar.instances = new WeakMap();