quasar 1.16.3 → 1.17.0

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 (296) hide show
  1. package/dist/api/BottomSheet.json +2 -2
  2. package/dist/api/Loading.json +0 -2
  3. package/dist/api/Notify.json +15 -15
  4. package/dist/api/QAvatar.json +1 -1
  5. package/dist/api/QBreadcrumbsEl.json +32 -11
  6. package/dist/api/QBtn.json +35 -14
  7. package/dist/api/QBtnDropdown.json +36 -15
  8. package/dist/api/QBtnToggle.json +1 -1
  9. package/dist/api/QCarousel.json +7 -7
  10. package/dist/api/QCarouselSlide.json +2 -2
  11. package/dist/api/QChatMessage.json +1 -5
  12. package/dist/api/QChip.json +4 -4
  13. package/dist/api/QColor.json +6 -0
  14. package/dist/api/QDialog.json +7 -1
  15. package/dist/api/QExpansionItem.json +34 -13
  16. package/dist/api/QFab.json +34 -2
  17. package/dist/api/QFabAction.json +9 -1
  18. package/dist/api/QField.json +80 -6
  19. package/dist/api/QFile.json +80 -6
  20. package/dist/api/QImg.json +2 -2
  21. package/dist/api/QInnerLoading.json +32 -0
  22. package/dist/api/QInput.json +82 -6
  23. package/dist/api/QItem.json +31 -10
  24. package/dist/api/QOptionGroup.json +58 -1
  25. package/dist/api/QPagination.json +4 -4
  26. package/dist/api/QParallax.json +1 -1
  27. package/dist/api/QPopupEdit.json +14 -7
  28. package/dist/api/QPullToRefresh.json +1 -1
  29. package/dist/api/QRange.json +581 -96
  30. package/dist/api/QRating.json +3 -3
  31. package/dist/api/QRouteTab.json +32 -12
  32. package/dist/api/QScrollArea.json +188 -20
  33. package/dist/api/QSelect.json +81 -9
  34. package/dist/api/QSeparator.json +1 -1
  35. package/dist/api/QSlider.json +499 -34
  36. package/dist/api/QStep.json +4 -4
  37. package/dist/api/QStepper.json +4 -4
  38. package/dist/api/QTab.json +1 -1
  39. package/dist/api/QTable.json +4 -4
  40. package/dist/api/QTabs.json +9 -0
  41. package/dist/api/QTimelineEntry.json +2 -2
  42. package/dist/api/QToggle.json +1 -1
  43. package/dist/api/QTree.json +7 -1
  44. package/dist/api/QVideo.json +10 -0
  45. package/dist/icon-set/bootstrap-icons.umd.min.js +1 -1
  46. package/dist/icon-set/eva-icons.umd.min.js +1 -1
  47. package/dist/icon-set/fontawesome-v5-pro.umd.min.js +1 -1
  48. package/dist/icon-set/fontawesome-v5.umd.min.js +1 -1
  49. package/dist/icon-set/ionicons-v4.umd.min.js +1 -1
  50. package/dist/icon-set/line-awesome.umd.min.js +1 -1
  51. package/dist/icon-set/material-icons-outlined.umd.min.js +1 -1
  52. package/dist/icon-set/material-icons-round.umd.min.js +1 -1
  53. package/dist/icon-set/material-icons-sharp.umd.min.js +1 -1
  54. package/dist/icon-set/material-icons.umd.min.js +1 -1
  55. package/dist/icon-set/mdi-v3.umd.min.js +1 -1
  56. package/dist/icon-set/mdi-v4.umd.min.js +1 -1
  57. package/dist/icon-set/mdi-v5.umd.min.js +1 -1
  58. package/dist/icon-set/mdi-v6.umd.min.js +1 -1
  59. package/dist/icon-set/svg-bootstrap-icons.umd.min.js +1 -1
  60. package/dist/icon-set/svg-eva-icons.umd.min.js +1 -1
  61. package/dist/icon-set/svg-fontawesome-v5.umd.min.js +1 -1
  62. package/dist/icon-set/svg-ionicons-v4.umd.min.js +1 -1
  63. package/dist/icon-set/svg-ionicons-v5.umd.min.js +1 -1
  64. package/dist/icon-set/svg-ionicons-v6.umd.min.js +6 -0
  65. package/dist/icon-set/svg-line-awesome.umd.min.js +1 -1
  66. package/dist/icon-set/svg-material-icons-outlined.umd.min.js +1 -1
  67. package/dist/icon-set/svg-material-icons-round.umd.min.js +1 -1
  68. package/dist/icon-set/svg-material-icons-sharp.umd.min.js +1 -1
  69. package/dist/icon-set/svg-material-icons.umd.min.js +1 -1
  70. package/dist/icon-set/svg-mdi-v4.umd.min.js +1 -1
  71. package/dist/icon-set/svg-mdi-v5.umd.min.js +1 -1
  72. package/dist/icon-set/svg-mdi-v6.umd.min.js +1 -1
  73. package/dist/icon-set/svg-themify.umd.min.js +1 -1
  74. package/dist/icon-set/themify.umd.min.js +1 -1
  75. package/dist/lang/ar.umd.min.js +2 -2
  76. package/dist/lang/az-latn.umd.min.js +1 -1
  77. package/dist/lang/bg.umd.min.js +1 -1
  78. package/dist/lang/ca.umd.min.js +1 -1
  79. package/dist/lang/cs.umd.min.js +1 -1
  80. package/dist/lang/da.umd.min.js +1 -1
  81. package/dist/lang/de.umd.min.js +1 -1
  82. package/dist/lang/el.umd.min.js +1 -1
  83. package/dist/lang/en-gb.umd.min.js +1 -1
  84. package/dist/lang/en-us.umd.min.js +1 -1
  85. package/dist/lang/eo.umd.min.js +1 -1
  86. package/dist/lang/es.umd.min.js +1 -1
  87. package/dist/lang/et.umd.min.js +1 -1
  88. package/dist/lang/fa-ir.umd.min.js +1 -1
  89. package/dist/lang/fa.umd.min.js +1 -1
  90. package/dist/lang/fi.umd.min.js +1 -1
  91. package/dist/lang/fr.umd.min.js +2 -2
  92. package/dist/lang/gn.umd.min.js +1 -1
  93. package/dist/lang/he.umd.min.js +1 -1
  94. package/dist/lang/hr.umd.min.js +1 -1
  95. package/dist/lang/hu.umd.min.js +1 -1
  96. package/dist/lang/id.umd.min.js +1 -1
  97. package/dist/lang/is.umd.min.js +1 -1
  98. package/dist/lang/it.umd.min.js +1 -1
  99. package/dist/lang/ja.umd.min.js +1 -1
  100. package/dist/lang/km.umd.min.js +1 -1
  101. package/dist/lang/ko-kr.umd.min.js +1 -1
  102. package/dist/lang/kur-ckb.umd.min.js +1 -1
  103. package/dist/lang/lu.umd.min.js +1 -1
  104. package/dist/lang/lv.umd.min.js +1 -1
  105. package/dist/lang/ml.umd.min.js +1 -1
  106. package/dist/lang/ms.umd.min.js +1 -1
  107. package/dist/lang/nb-no.umd.min.js +1 -1
  108. package/dist/lang/nl.umd.min.js +1 -1
  109. package/dist/lang/pl.umd.min.js +1 -1
  110. package/dist/lang/pt-br.umd.min.js +1 -1
  111. package/dist/lang/pt.umd.min.js +1 -1
  112. package/dist/lang/ro.umd.min.js +1 -1
  113. package/dist/lang/ru.umd.min.js +1 -1
  114. package/dist/lang/sk.umd.min.js +1 -1
  115. package/dist/lang/sl.umd.min.js +1 -1
  116. package/dist/lang/sr.umd.min.js +2 -2
  117. package/dist/lang/sv.umd.min.js +1 -1
  118. package/dist/lang/ta.umd.min.js +1 -1
  119. package/dist/lang/th.umd.min.js +1 -1
  120. package/dist/lang/tr.umd.min.js +1 -1
  121. package/dist/lang/ug.umd.min.js +2 -2
  122. package/dist/lang/uk.umd.min.js +1 -1
  123. package/dist/lang/vi.umd.min.js +1 -1
  124. package/dist/lang/zh-hans.umd.min.js +2 -2
  125. package/dist/lang/zh-hant.umd.min.js +2 -2
  126. package/dist/quasar.addon.css +1 -1
  127. package/dist/quasar.addon.rtl.css +1 -1
  128. package/dist/quasar.common.js +2 -2
  129. package/dist/quasar.css +376 -225
  130. package/dist/quasar.esm.js +2 -2
  131. package/dist/quasar.ie.polyfills.js +1 -1
  132. package/dist/quasar.ie.polyfills.umd.min.js +1 -1
  133. package/dist/quasar.min.css +1 -1
  134. package/dist/quasar.rtl.css +508 -301
  135. package/dist/quasar.rtl.min.css +1 -1
  136. package/dist/quasar.sass +324 -208
  137. package/dist/quasar.styl +324 -208
  138. package/dist/quasar.umd.js +3098 -1836
  139. package/dist/quasar.umd.min.js +2 -2
  140. package/dist/quasar.umd.modern.js +3057 -1817
  141. package/dist/quasar.umd.modern.min.js +2 -2
  142. package/dist/transform-asset-urls.json +20 -0
  143. package/dist/types/index.d.ts +421 -103
  144. package/dist/types/utils/scroll.d.ts +1 -0
  145. package/dist/vetur/quasar-attributes.json +313 -89
  146. package/dist/vetur/quasar-tags.json +74 -18
  147. package/dist/web-types/web-types.json +1289 -259
  148. package/icon-set/svg-ionicons-v6.js +225 -0
  149. package/lang/ar.js +1 -1
  150. package/lang/fa-ir.js +3 -1
  151. package/lang/fa.js +3 -1
  152. package/lang/fr.js +1 -1
  153. package/lang/index.json +1 -1
  154. package/lang/kur-ckb.js +2 -2
  155. package/lang/sr.js +4 -4
  156. package/lang/ug.js +48 -46
  157. package/lang/zh-hans.js +1 -1
  158. package/lang/zh-hant.js +18 -18
  159. package/package.json +1 -1
  160. package/src/api.extends.json +1 -2
  161. package/src/components/breadcrumbs/QBreadcrumbs.js +15 -11
  162. package/src/components/breadcrumbs/QBreadcrumbs.sass +0 -3
  163. package/src/components/breadcrumbs/QBreadcrumbs.styl +0 -3
  164. package/src/components/breadcrumbs/QBreadcrumbsEl.js +25 -9
  165. package/src/components/btn/QBtn.js +3 -3
  166. package/src/components/btn-dropdown/QBtnDropdown.sass +2 -0
  167. package/src/components/btn-dropdown/QBtnDropdown.styl +2 -0
  168. package/src/components/carousel/QCarousel.js +6 -2
  169. package/src/components/carousel/QCarousel.json +9 -1
  170. package/src/components/carousel/QCarouselSlide.json +2 -2
  171. package/src/components/chat/QChatMessage.json +1 -1
  172. package/src/components/color/QColor.js +100 -85
  173. package/src/components/color/QColor.json +7 -0
  174. package/src/components/color/QColor.sass +14 -24
  175. package/src/components/color/QColor.styl +14 -24
  176. package/src/components/date/QDate.js +7 -1
  177. package/src/components/date/QDate.sass +2 -0
  178. package/src/components/date/QDate.styl +2 -0
  179. package/src/components/dialog/QDialog.js +8 -4
  180. package/src/components/dialog/QDialog.json +8 -1
  181. package/src/components/drawer/QDrawer.js +16 -15
  182. package/src/components/editor/QEditor.js +2 -2
  183. package/src/components/editor/QEditor.sass +13 -1
  184. package/src/components/editor/QEditor.styl +13 -1
  185. package/src/components/expansion-item/QExpansionItem.js +13 -11
  186. package/src/components/fab/QFab.js +20 -11
  187. package/src/components/fab/QFab.json +35 -0
  188. package/src/components/fab/QFabAction.js +16 -9
  189. package/src/components/fab/QFabAction.json +10 -0
  190. package/src/components/field/QField.js +28 -23
  191. package/src/components/field/__QField.json +72 -8
  192. package/src/components/file/QFile.js +12 -4
  193. package/src/components/file/QFile.sass +4 -3
  194. package/src/components/file/QFile.styl +4 -3
  195. package/src/components/footer/QFooter.js +1 -1
  196. package/src/components/form/QForm.js +1 -1
  197. package/src/components/header/QHeader.js +1 -1
  198. package/src/components/icon/QIcon.js +54 -49
  199. package/src/components/img/QImg.json +2 -2
  200. package/src/components/infinite-scroll/QInfiniteScroll.js +49 -36
  201. package/src/components/inner-loading/QInnerLoading.js +54 -22
  202. package/src/components/inner-loading/QInnerLoading.json +29 -0
  203. package/src/components/inner-loading/QInnerLoading.sass +3 -0
  204. package/src/components/inner-loading/QInnerLoading.styl +3 -0
  205. package/src/components/item/QItem.js +9 -15
  206. package/src/components/linear-progress/QLinearProgress.js +6 -2
  207. package/src/components/menu/QMenu.js +5 -1
  208. package/src/components/option-group/QOptionGroup.js +32 -22
  209. package/src/components/option-group/QOptionGroup.json +50 -1
  210. package/src/components/parallax/QParallax.js +3 -0
  211. package/src/components/parallax/QParallax.json +1 -1
  212. package/src/components/popup-edit/QPopupEdit.js +41 -16
  213. package/src/components/popup-edit/QPopupEdit.json +15 -8
  214. package/src/components/range/QRange.js +223 -278
  215. package/src/components/range/QRange.json +11 -122
  216. package/src/components/rating/QRating.js +56 -38
  217. package/src/components/rating/QRating.json +3 -3
  218. package/src/components/rating/QRating.sass +8 -6
  219. package/src/components/rating/QRating.styl +8 -6
  220. package/src/components/resize-observer/QResizeObserver.js +15 -10
  221. package/src/components/scroll-area/QScrollArea.js +342 -126
  222. package/src/components/scroll-area/QScrollArea.json +164 -20
  223. package/src/components/scroll-area/QScrollArea.sass +4 -0
  224. package/src/components/scroll-area/QScrollArea.styl +4 -0
  225. package/src/components/scroll-observer/QScrollObserver.js +9 -2
  226. package/src/components/select/QSelect.js +8 -2
  227. package/src/components/separator/QSeparator.js +0 -1
  228. package/src/components/separator/QSeparator.json +1 -1
  229. package/src/components/slider/QSlider.js +97 -140
  230. package/src/components/slider/QSlider.json +1 -122
  231. package/src/components/slider/QSlider.sass +205 -139
  232. package/src/components/slider/QSlider.styl +205 -139
  233. package/src/components/slider/slider-utils.js +468 -123
  234. package/src/components/slider/slider-utils.json +546 -0
  235. package/src/components/stepper/QStepper.js +1 -1
  236. package/src/components/stepper/QStepper.sass +25 -26
  237. package/src/components/stepper/QStepper.styl +25 -26
  238. package/src/components/table/QTable.sass +3 -0
  239. package/src/components/table/QTable.styl +3 -0
  240. package/src/components/tabs/QRouteTab.js +13 -13
  241. package/src/components/tabs/QRouteTab.json +0 -7
  242. package/src/components/tabs/QTab.js +71 -20
  243. package/src/components/tabs/QTabs.js +237 -52
  244. package/src/components/tabs/QTabs.json +8 -0
  245. package/src/components/tabs/QTabs.sass +6 -6
  246. package/src/components/tabs/QTabs.styl +6 -6
  247. package/src/components/time/QTime.js +6 -2
  248. package/src/components/timeline/QTimelineEntry.json +1 -1
  249. package/src/components/tree/QTree.js +10 -6
  250. package/src/components/tree/QTree.json +5 -0
  251. package/src/components/tree/QTree.sass +58 -4
  252. package/src/components/tree/QTree.styl +58 -4
  253. package/src/components/uploader/QUploaderBase.js +15 -19
  254. package/src/components/video/QVideo.js +4 -1
  255. package/src/components/video/QVideo.json +11 -0
  256. package/src/components/virtual-scroll/QVirtualScroll.sass +1 -0
  257. package/src/components/virtual-scroll/QVirtualScroll.styl +1 -0
  258. package/src/css/core/helpers.sass +3 -0
  259. package/src/css/core/helpers.styl +3 -0
  260. package/src/css/core/positioning.sass +5 -0
  261. package/src/css/core/positioning.styl +5 -0
  262. package/src/css/variables.sass +4 -6
  263. package/src/css/variables.styl +4 -6
  264. package/src/directives/Scroll.js +2 -2
  265. package/src/directives/ScrollFire.js +1 -0
  266. package/src/ie-compat/ie.js +13 -13
  267. package/src/install.js +1 -1
  268. package/src/lang.js +7 -4
  269. package/src/mixins/anchor.js +3 -13
  270. package/src/mixins/btn.js +30 -38
  271. package/src/mixins/btn.json +26 -11
  272. package/src/mixins/file.js +27 -5
  273. package/src/mixins/fullscreen.js +16 -4
  274. package/src/mixins/portal.js +10 -10
  275. package/src/mixins/router-link.js +88 -14
  276. package/src/mixins/router-link.json +26 -10
  277. package/src/mixins/validate.js +33 -15
  278. package/src/mixins/virtual-scroll.js +40 -42
  279. package/src/plugins/AppFullscreen.js +41 -16
  280. package/src/plugins/BottomSheet.json +1 -1
  281. package/src/plugins/Cookies.js +1 -1
  282. package/src/plugins/Loading.js +8 -0
  283. package/src/plugins/LoadingBar.js +9 -0
  284. package/src/plugins/Notify.js +351 -333
  285. package/src/plugins/Notify.json +10 -10
  286. package/src/plugins/Notify.sass +9 -3
  287. package/src/plugins/Notify.styl +9 -3
  288. package/src/utils/clone.js +53 -4
  289. package/src/utils/date.js +134 -69
  290. package/src/utils/dom.js +28 -9
  291. package/src/utils/extend.js +2 -2
  292. package/src/utils/focus-manager.js +8 -10
  293. package/src/utils/global-dialog.js +18 -1
  294. package/src/utils/is.js +2 -2
  295. package/src/utils/morph.js +2 -12
  296. package/src/utils/scroll.js +71 -35
@@ -1,17 +1,25 @@
1
1
  import Vue from 'vue'
2
2
 
3
+ import QResizeObserver from '../resize-observer/QResizeObserver.js'
4
+ import QScrollObserver from '../scroll-observer/QScrollObserver.js'
5
+
6
+ import TouchPan from '../../directives/TouchPan.js'
7
+
3
8
  import { between } from '../../utils/format.js'
4
- import { setScrollPosition, setHorizontalScrollPosition } from '../../utils/scroll.js'
9
+ import { setVerticalScrollPosition, setHorizontalScrollPosition } from '../../utils/scroll.js'
5
10
  import { mergeSlot } from '../../utils/slot.js'
6
11
  import cache from '../../utils/cache.js'
7
12
  import debounce from '../../utils/debounce.js'
8
13
 
9
- import QResizeObserver from '../resize-observer/QResizeObserver.js'
10
- import QScrollObserver from '../scroll-observer/QScrollObserver.js'
11
- import TouchPan from '../../directives/TouchPan.js'
12
14
  import DarkMixin from '../../mixins/dark.js'
13
15
  import { ariaHidden } from '../../mixins/attrs'
14
16
 
17
+ const axisList = [ 'vertical', 'horizontal' ]
18
+ const dirProps = {
19
+ vertical: { offset: 'offsetY', scroll: 'scrollTop', dir: 'down', dist: 'y' },
20
+ horizontal: { offset: 'offsetX', scroll: 'scrollLeft', dir: 'right', dist: 'x' }
21
+ }
22
+
15
23
  export default Vue.extend({
16
24
  name: 'QScrollArea',
17
25
 
@@ -22,13 +30,19 @@ export default Vue.extend({
22
30
  },
23
31
 
24
32
  props: {
25
- barStyle: [ Array, String, Object ],
26
33
  thumbStyle: Object,
34
+ verticalThumbStyle: Object,
35
+ horizontalThumbStyle: Object,
36
+
37
+ barStyle: [ Array, String, Object ],
38
+ verticalBarStyle: [ Array, String, Object ],
39
+ horizontalBarStyle: [ Array, String, Object ],
40
+
27
41
  contentStyle: [ Array, String, Object ],
28
42
  contentActiveStyle: [ Array, String, Object ],
29
43
 
30
44
  delay: {
31
- type: [String, Number],
45
+ type: [ String, Number ],
32
46
  default: 1000
33
47
  },
34
48
 
@@ -39,7 +53,7 @@ export default Vue.extend({
39
53
 
40
54
  horizontal: Boolean,
41
55
 
42
- tabindex: [String, Number]
56
+ tabindex: [ String, Number ]
43
57
  },
44
58
 
45
59
  data () {
@@ -50,10 +64,22 @@ export default Vue.extend({
50
64
  hover: false,
51
65
 
52
66
  // other...
53
- containerWidth: 0,
54
- containerHeight: 0,
55
- scrollPosition: 0,
56
- scrollSize: 0
67
+ container: {
68
+ vertical: 0,
69
+ horizontal: 0
70
+ },
71
+
72
+ scroll: {
73
+ vertical: {
74
+ position: 0,
75
+ size: 0
76
+ },
77
+
78
+ horizontal: {
79
+ position: 0,
80
+ size: 0
81
+ }
82
+ }
57
83
  }
58
84
  },
59
85
 
@@ -63,82 +89,148 @@ export default Vue.extend({
63
89
  (this.isDark === true ? ' q-scrollarea--dark' : '')
64
90
  },
65
91
 
66
- thumbHidden () {
92
+ verticalScrollPercentage () {
93
+ const diff = this.scroll.vertical.size - this.container.vertical
94
+ if (diff <= 0) { return 0 }
95
+ const p = between(this.scroll.vertical.position / diff, 0, 1)
96
+ return Math.round(p * 10000) / 10000
97
+ },
98
+
99
+ horizontalScrollPercentage () {
100
+ const diff = this.scroll.horizontal.size - this.container.horizontal
101
+ if (diff <= 0) { return 0 }
102
+ const p = between(this.scroll.horizontal.position / diff, 0, 1)
103
+ return Math.round(p * 10000) / 10000
104
+ },
105
+
106
+ verticalThumbHidden () {
67
107
  return (
68
108
  (this.visible === null ? this.hover : this.visible) !== true &&
69
109
  this.tempShowing === false &&
70
110
  this.panning === false
71
- ) || this.scrollSize <= this.containerSize
111
+ ) || this.scroll.vertical.size <= this.container.vertical + 1
72
112
  },
73
113
 
74
- thumbSize () {
114
+ horizontalThumbHidden () {
115
+ return (
116
+ (this.visible === null ? this.hover : this.visible) !== true &&
117
+ this.tempShowing === false &&
118
+ this.panning === false
119
+ ) || this.scroll.horizontal.size <= this.container.horizontal + 1
120
+ },
121
+
122
+ verticalThumbSize () {
75
123
  return Math.round(
76
124
  between(
77
- this.containerSize * this.containerSize / this.scrollSize,
125
+ this.container.vertical * this.container.vertical / this.scroll.vertical.size,
78
126
  50,
79
- this.containerSize
127
+ this.container.vertical
80
128
  )
81
129
  )
82
130
  },
83
131
 
84
- style () {
85
- const pos = this.scrollPercentage * (this.containerSize - this.thumbSize)
86
- return Object.assign(
87
- {},
88
- this.thumbStyle,
89
- this.horizontal === true
90
- ? {
91
- left: `${pos}px`,
92
- width: `${this.thumbSize}px`
93
- }
94
- : {
95
- top: `${pos}px`,
96
- height: `${this.thumbSize}px`
97
- }
132
+ horizontalThumbSize () {
133
+ return Math.round(
134
+ between(
135
+ this.container.horizontal * this.container.horizontal / this.scroll.horizontal.size,
136
+ 50,
137
+ this.container.horizontal
138
+ )
98
139
  )
99
140
  },
100
141
 
101
- mainStyle () {
102
- return this.thumbHidden === true
103
- ? this.contentStyle
104
- : this.contentActiveStyle
142
+ verticalStyle () {
143
+ const pos = this.verticalScrollPercentage * (this.container.vertical - this.verticalThumbSize)
144
+ return {
145
+ ...this.thumbStyle,
146
+ ...this.verticalThumbStyle,
147
+ top: `${pos}px`,
148
+ height: `${this.verticalThumbSize}px`
149
+ }
105
150
  },
106
151
 
107
- scrollPercentage () {
108
- const p = between(this.scrollPosition / (this.scrollSize - this.containerSize), 0, 1)
109
- return Math.round(p * 10000) / 10000
152
+ horizontalStyle () {
153
+ const pos = this.horizontalScrollPercentage * (this.container.horizontal - this.horizontalThumbSize)
154
+ return {
155
+ ...this.thumbStyle,
156
+ ...this.horizontalThumbStyle,
157
+ left: `${pos}px`,
158
+ width: `${this.horizontalThumbSize}px`
159
+ }
110
160
  },
111
161
 
112
- containerSize () {
113
- return this[`container${this.dirProps.suffix}`]
162
+ verticalThumbClass () {
163
+ return 'q-scrollarea__thumb q-scrollarea__thumb--v absolute-right' +
164
+ (this.verticalThumbHidden === true ? ' q-scrollarea__thumb--invisible' : '')
114
165
  },
115
166
 
116
- dirProps () {
117
- return this.horizontal === true
118
- ? { prefix: 'horizontal', suffix: 'Width', scroll: 'scrollLeft', classSuffix: 'h absolute-bottom', dir: 'right', dist: 'x' }
119
- : { prefix: 'vertical', suffix: 'Height', scroll: 'scrollTop', classSuffix: 'v absolute-right', dir: 'down', dist: 'y' }
167
+ horizontalThumbClass () {
168
+ return 'q-scrollarea__thumb q-scrollarea__thumb--h absolute-bottom' +
169
+ (this.horizontalThumbHidden === true ? ' q-scrollarea__thumb--invisible' : '')
120
170
  },
121
171
 
122
- thumbClass () {
123
- return `q-scrollarea__thumb--${this.dirProps.classSuffix}` +
124
- (this.thumbHidden === true ? ' q-scrollarea__thumb--invisible' : '')
172
+ verticalBarClass () {
173
+ return 'q-scrollarea__bar q-scrollarea__bar--v absolute-right' +
174
+ (this.verticalThumbHidden === true ? ' q-scrollarea__bar--invisible' : '')
125
175
  },
126
176
 
127
- barClass () {
128
- return `q-scrollarea__bar--${this.dirProps.classSuffix}` +
129
- (this.thumbHidden === true ? ' q-scrollarea__bar--invisible' : '')
177
+ horizontalBarClass () {
178
+ return 'q-scrollarea__bar q-scrollarea__bar--h absolute-bottom' +
179
+ (this.horizontalThumbHidden === true ? ' q-scrollarea__bar--invisible' : '')
180
+ },
181
+
182
+ scrollComputed () {
183
+ return {
184
+ vertical: {
185
+ ...this.scroll.vertical,
186
+ percentage: this.verticalScrollPercentage,
187
+ thumbHidden: this.verticalThumbHidden,
188
+ thumbSize: this.verticalThumbSize,
189
+ style: this.verticalStyle,
190
+ thumbClass: this.verticalThumbClass,
191
+ barClass: this.verticalBarClass
192
+ },
193
+ horizontal: {
194
+ ...this.scroll.horizontal,
195
+ percentage: this.horizontalScrollPercentage,
196
+ thumbHidden: this.horizontalThumbHidden,
197
+ thumbSize: this.horizontalThumbSize,
198
+ style: this.horizontalStyle,
199
+ thumbClass: this.horizontalThumbClass,
200
+ barClass: this.horizontalBarClass
201
+ }
202
+ }
203
+ },
204
+
205
+ mainStyle () {
206
+ return this.verticalThumbHidden === true && this.horizontalThumbHidden === true
207
+ ? this.contentStyle
208
+ : this.contentActiveStyle
209
+ },
210
+
211
+ verticalThumbDirectives () {
212
+ return [{
213
+ name: 'touch-pan',
214
+ modifiers: {
215
+ vertical: true,
216
+ prevent: true,
217
+ mouse: true,
218
+ mouseAllDir: true
219
+ },
220
+ value: e => { this.__panThumb(e, 'vertical') }
221
+ }]
130
222
  },
131
223
 
132
- thumbDirectives () {
224
+ horizontalThumbDirectives () {
133
225
  return [{
134
226
  name: 'touch-pan',
135
227
  modifiers: {
136
- [ this.horizontal === true ? 'horizontal' : 'vertical' ]: true,
228
+ horizontal: true,
137
229
  prevent: true,
138
230
  mouse: true,
139
231
  mouseAllDir: true
140
232
  },
141
- value: this.__panThumb
233
+ value: e => { this.__panThumb(e, 'horizontal') }
142
234
  }]
143
235
  },
144
236
 
@@ -154,21 +246,81 @@ export default Vue.extend({
154
246
  return this.$refs.target
155
247
  },
156
248
 
157
- getScrollPosition () {
158
- return this.scrollPosition
249
+ getScroll () {
250
+ const info = {}
251
+
252
+ axisList.forEach(axis => {
253
+ const data = this.scrollComputed[ axis ]
254
+
255
+ info[ axis + 'Position' ] = data.position
256
+ info[ axis + 'Percentage' ] = data.percentage
257
+ info[ axis + 'Size' ] = data.size
258
+ info[ axis + 'ContainerSize' ] = this.container[ axis ]
259
+ })
260
+
261
+ return info
262
+ },
263
+
264
+ getScrollPosition (axis) {
265
+ if (axis === 'both') {
266
+ return {
267
+ top: this.scroll.vertical.position,
268
+ left: this.scroll.horizontal.position
269
+ }
270
+ }
271
+
272
+ if (axisList.includes(axis) !== true) {
273
+ axis = this.horizontal === true ? 'horizontal' : 'vertical'
274
+ }
275
+
276
+ return this.scroll[axis].position
277
+ },
278
+
279
+ getScrollPercentage (axis) {
280
+ if (axis === 'both') {
281
+ return {
282
+ top: this.verticalScrollPercentage,
283
+ left: this.horizontalScrollPercentage
284
+ }
285
+ }
286
+
287
+ if (axisList.includes(axis) !== true) {
288
+ axis = this.horizontal === true ? 'horizontal' : 'vertical'
289
+ }
290
+
291
+ return this[`${axis}ScrollPercentage`]
159
292
  },
160
293
 
161
- setScrollPosition (offset, duration) {
162
- const fn = this.horizontal === true
163
- ? setHorizontalScrollPosition
164
- : setScrollPosition
294
+ setScrollPosition (axis, offset, duration) {
295
+ if (axisList.includes(axis) === false) {
296
+ if (isNaN(axis) === true) {
297
+ console.error('[QScrollArea]: wrong first param of setScrollPosition (vertical/horizontal)')
298
+ return
299
+ }
300
+
301
+ [axis, offset, duration] = [this.horizontal === true ? 'horizontal' : 'vertical', axis, offset]
302
+ }
303
+
304
+ const fn = axis === 'vertical'
305
+ ? setVerticalScrollPosition
306
+ : setHorizontalScrollPosition
165
307
 
166
308
  fn(this.$refs.target, offset, duration)
167
309
  },
168
310
 
169
- setScrollPercentage (percentage, duration) {
311
+ setScrollPercentage (axis, percentage, duration) {
312
+ if (axisList.includes(axis) === false) {
313
+ if (isNaN(axis) === true) {
314
+ console.error('[QScrollArea]: wrong first param of setScrollPercentage (vertical/horizontal)')
315
+ return
316
+ }
317
+
318
+ [axis, percentage, duration] = [this.horizontal === true ? 'horizontal' : 'vertical', axis, percentage]
319
+ }
320
+
170
321
  this.setScrollPosition(
171
- percentage * (this.scrollSize - this.containerSize),
322
+ axis,
323
+ percentage * (this.scroll[axis].size - this.container[axis]),
172
324
  duration
173
325
  )
174
326
  },
@@ -176,75 +328,104 @@ export default Vue.extend({
176
328
  __updateContainer ({ height, width }) {
177
329
  let change = false
178
330
 
179
- if (this.containerWidth !== width) {
180
- this.containerWidth = width
331
+ if (this.container.vertical !== height) {
332
+ this.container.vertical = height
181
333
  change = true
182
334
  }
183
335
 
184
- if (this.containerHeight !== height) {
185
- this.containerHeight = height
336
+ if (this.container.horizontal !== width) {
337
+ this.container.horizontal = width
186
338
  change = true
187
339
  }
188
340
 
189
341
  change === true && this.__startTimer()
190
342
  },
191
343
 
192
- __updateScroll (info) {
193
- if (this.scrollPosition !== info.position) {
194
- this.scrollPosition = info.position
344
+ __updateVerticalScroll ({ position }) {
345
+ if (this.scroll.vertical.position !== position) {
346
+ this.scroll.vertical.position = position
347
+ this.__startTimer()
348
+ }
349
+ },
350
+
351
+ __updateHorizontalScroll ({ position }) {
352
+ if (this.scroll.horizontal.position !== position) {
353
+ this.scroll.horizontal.position = position
195
354
  this.__startTimer()
196
355
  }
197
356
  },
198
357
 
199
358
  __updateScrollSize ({ height, width }) {
200
- if (this.horizontal === true) {
201
- if (this.scrollSize !== width) {
202
- this.scrollSize = width
203
- this.__startTimer()
204
- }
359
+ let change = false
360
+
361
+ if (this.scroll.horizontal.size !== width) {
362
+ this.scroll.horizontal.size = width
363
+ change = true
205
364
  }
206
- else if (this.scrollSize !== height) {
207
- this.scrollSize = height
208
- this.__startTimer()
365
+
366
+ if (this.scroll.vertical.size !== height) {
367
+ this.scroll.vertical.size = height
368
+ change = true
209
369
  }
370
+
371
+ change === true && this.__startTimer()
210
372
  },
211
373
 
212
- __panThumb (e) {
213
- if (e.isFirst === true) {
214
- if (this.thumbHidden === true) {
374
+ __panThumb (e, axis) {
375
+ const data = this.scrollComputed[ axis ]
376
+
377
+ if (e.isFinal === true) {
378
+ if (this.panning !== true) {
215
379
  return
216
380
  }
217
381
 
218
- this.refPos = this.scrollPosition
382
+ this.panning = false
383
+ }
384
+ else if (e.isFirst === true) {
385
+ if (data.thumbHidden === true) {
386
+ return
387
+ }
388
+
389
+ this.refPos = data.position
219
390
  this.panning = true
220
391
  }
221
392
  else if (this.panning !== true) {
222
393
  return
223
394
  }
224
395
 
225
- if (e.isFinal === true) {
226
- this.panning = false
227
- }
396
+ const dProp = dirProps[ axis ]
397
+ const containerSize = this.container[axis]
228
398
 
229
- const multiplier = (this.scrollSize - this.containerSize) / (this.containerSize - this.thumbSize)
230
- const distance = e.distance[this.dirProps.dist]
231
- const pos = this.refPos + (e.direction === this.dirProps.dir ? 1 : -1) * distance * multiplier
399
+ const multiplier = (data.size - containerSize) / (containerSize - data.thumbSize)
400
+ const distance = e.distance[dProp.dist]
401
+ const pos = this.refPos + (e.direction === dProp.dir ? 1 : -1) * distance * multiplier
232
402
 
233
- this.__setScroll(pos)
403
+ this.__setScroll(pos, axis)
234
404
  },
235
405
 
236
- __mouseDown (evt) {
237
- if (this.thumbHidden !== true) {
238
- const pos = evt[`offset${this.horizontal === true ? 'X' : 'Y'}`] - this.thumbSize / 2
239
- this.__setScroll(pos / this.containerSize * this.scrollSize)
406
+ __mouseDown (evt, axis) {
407
+ const data = this.scrollComputed[ axis ]
408
+
409
+ if (data.thumbHidden !== true) {
410
+ const pos = evt[ dirProps[ axis ].offset ] - data.thumbSize / 2
411
+ this.__setScroll(pos / this.container[ axis ] * data.size, axis)
240
412
 
413
+ const ref = axis === 'vertical' ? this.$refs.verticalThumb : this.$refs.horizontalThumb
241
414
  // activate thumb pan
242
- if (this.$refs.thumb !== void 0) {
243
- this.$refs.thumb.dispatchEvent(new MouseEvent(evt.type, evt))
415
+ if (ref !== void 0) {
416
+ ref.dispatchEvent(new MouseEvent(evt.type, evt))
244
417
  }
245
418
  }
246
419
  },
247
420
 
421
+ __verticalMouseDown (evt) {
422
+ this.__mouseDown(evt, 'vertical')
423
+ },
424
+
425
+ __horizontalMouseDown (evt) {
426
+ this.__mouseDown(evt, 'horizontal')
427
+ },
428
+
248
429
  __startTimer () {
249
430
  if (this.tempShowing === true) {
250
431
  clearTimeout(this.timer)
@@ -253,15 +434,20 @@ export default Vue.extend({
253
434
  this.tempShowing = true
254
435
  }
255
436
 
256
- this.timer = setTimeout(() => {
257
- this.tempShowing = false
258
- }, this.delay)
437
+ this.timer = setTimeout(() => { this.tempShowing = false }, this.delay)
438
+ this.$listeners.scroll !== void 0 && this.__emitScroll()
439
+ },
440
+
441
+ __setScroll (offset, axis) {
442
+ this.$refs.target[ dirProps[ axis ].scroll ] = offset
443
+ },
259
444
 
260
- this.__emitScroll()
445
+ __mouseEnter () {
446
+ this.hover = true
261
447
  },
262
448
 
263
- __setScroll (offset) {
264
- this.$refs.target[this.dirProps.scroll] = offset
449
+ __mouseLeave () {
450
+ this.hover = false
265
451
  }
266
452
  },
267
453
 
@@ -269,52 +455,72 @@ export default Vue.extend({
269
455
  return h('div', {
270
456
  class: this.classes,
271
457
  on: cache(this, 'desk', {
272
- mouseenter: () => { this.hover = true },
273
- mouseleave: () => { this.hover = false }
458
+ mouseenter: this.__mouseEnter,
459
+ mouseleave: this.__mouseLeave
274
460
  })
275
461
  }, [
276
462
  h('div', {
277
463
  ref: 'target',
278
- staticClass: 'scroll relative-position fit hide-scrollbar',
464
+ staticClass: 'q-scrollarea__container scroll relative-position fit hide-scrollbar',
279
465
  attrs: this.scrollAttrs
280
466
  }, [
281
467
  h('div', {
282
- staticClass: 'absolute',
283
- style: this.mainStyle,
284
- class: `full-${this.horizontal === true ? 'height' : 'width'}`
468
+ staticClass: 'q-scrollarea__content absolute',
469
+ style: this.mainStyle
285
470
  }, mergeSlot([
286
471
  h(QResizeObserver, {
472
+ props: { debounce: 0 },
287
473
  on: cache(this, 'resizeIn', { resize: this.__updateScrollSize })
288
474
  })
289
475
  ], this, 'default')),
290
476
 
291
477
  h(QScrollObserver, {
292
- props: { horizontal: this.horizontal },
293
- on: cache(this, 'scroll', { scroll: this.__updateScroll })
478
+ on: cache(this, 'scrollV', { scroll: this.__updateVerticalScroll })
479
+ }),
480
+
481
+ h(QScrollObserver, {
482
+ props: { horizontal: true },
483
+ on: cache(this, 'scrollH', { scroll: this.__updateHorizontalScroll })
294
484
  })
295
485
  ]),
296
486
 
297
487
  h(QResizeObserver, {
488
+ props: { debounce: 0 },
298
489
  on: cache(this, 'resizeOut', { resize: this.__updateContainer })
299
490
  }),
300
491
 
301
492
  h('div', {
302
- staticClass: 'q-scrollarea__bar',
303
- style: this.barStyle,
304
- class: this.barClass,
493
+ class: this.verticalBarClass,
494
+ style: [ this.barStyle, this.verticalBarStyle ],
495
+ attrs: ariaHidden,
496
+ on: cache(this, 'barV', {
497
+ mousedown: this.__verticalMouseDown
498
+ })
499
+ }),
500
+
501
+ h('div', {
502
+ class: this.horizontalBarClass,
503
+ style: [ this.barStyle, this.horizontalBarStyle ],
305
504
  attrs: ariaHidden,
306
- on: cache(this, 'bar', {
307
- mousedown: this.__mouseDown
505
+ on: cache(this, 'barH', {
506
+ mousedown: this.__horizontalMouseDown
308
507
  })
309
508
  }),
310
509
 
311
510
  h('div', {
312
- ref: 'thumb',
313
- staticClass: 'q-scrollarea__thumb',
314
- style: this.style,
315
- class: this.thumbClass,
511
+ ref: 'verticalThumb',
512
+ class: this.verticalThumbClass,
513
+ style: this.verticalStyle,
316
514
  attrs: ariaHidden,
317
- directives: this.thumbDirectives
515
+ directives: this.verticalThumbDirectives
516
+ }),
517
+
518
+ h('div', {
519
+ ref: 'horizontalThumb',
520
+ class: this.horizontalThumbClass,
521
+ style: this.horizontalStyle,
522
+ attrs: ariaHidden,
523
+ directives: this.horizontalThumbDirectives
318
524
  })
319
525
  ])
320
526
  },
@@ -324,17 +530,27 @@ export default Vue.extend({
324
530
  // ensure we're not emitting same info
325
531
  // multiple times
326
532
  this.__emitScroll = debounce(() => {
327
- if (this.$listeners.scroll !== void 0) {
328
- const info = { ref: this }
329
- const prefix = this.dirProps.prefix
533
+ const info = this.getScroll()
534
+ info.ref = this
535
+ this.$emit('scroll', info)
536
+ }, 0)
537
+ },
330
538
 
331
- info[prefix + 'Position'] = this.scrollPosition
332
- info[prefix + 'Percentage'] = this.scrollPercentage
333
- info[prefix + 'Size'] = this.scrollSize
334
- info[prefix + 'ContainerSize'] = this.containerSize
539
+ activated () {
540
+ const scrollTarget = this.getScrollTarget()
335
541
 
336
- this.$emit('scroll', info)
337
- }
338
- }, 0)
542
+ if (scrollTarget !== void 0 && this.__scrollPosition !== void 0) {
543
+ setHorizontalScrollPosition(scrollTarget, this.__scrollPosition.left)
544
+ setVerticalScrollPosition(scrollTarget, this.__scrollPosition.top)
545
+ }
546
+ },
547
+
548
+ deactivated () {
549
+ this.__scrollPosition = this.getScrollPosition('both')
550
+ },
551
+
552
+ beforeDestroy () {
553
+ this.__emitScroll.cancel()
554
+ clearTimeout(this.timer)
339
555
  }
340
556
  })