Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VToolbar.js 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  2. // Styles
  3. import '../../../src/stylus/components/_toolbar.styl';
  4. // Mixins
  5. import Applicationable from '../../mixins/applicationable';
  6. import Colorable from '../../mixins/colorable';
  7. import Themeable from '../../mixins/themeable';
  8. import SSRBootable from '../../mixins/ssr-bootable';
  9. // Directives
  10. import Scroll from '../../directives/scroll';
  11. import { deprecate } from '../../util/console';
  12. // Types
  13. import mixins from '../../util/mixins';
  14. export default mixins(Applicationable('top', ['clippedLeft', 'clippedRight', 'computedHeight', 'invertedScroll', 'manualScroll']), Colorable, SSRBootable, Themeable
  15. /* @vue/component */
  16. ).extend({
  17. name: 'v-toolbar',
  18. directives: { Scroll: Scroll },
  19. props: {
  20. card: Boolean,
  21. clippedLeft: Boolean,
  22. clippedRight: Boolean,
  23. dense: Boolean,
  24. extended: Boolean,
  25. extensionHeight: {
  26. type: [Number, String],
  27. validator: function validator(v) {
  28. return !isNaN(parseInt(v));
  29. }
  30. },
  31. flat: Boolean,
  32. floating: Boolean,
  33. height: {
  34. type: [Number, String],
  35. validator: function validator(v) {
  36. return !isNaN(parseInt(v));
  37. }
  38. },
  39. invertedScroll: Boolean,
  40. manualScroll: Boolean,
  41. prominent: Boolean,
  42. scrollOffScreen: Boolean,
  43. /* @deprecated */
  44. scrollToolbarOffScreen: Boolean,
  45. scrollTarget: String,
  46. scrollThreshold: {
  47. type: Number,
  48. default: 300
  49. },
  50. tabs: Boolean
  51. },
  52. data: function data() {
  53. return {
  54. activeTimeout: null,
  55. currentScroll: 0,
  56. heights: {
  57. mobileLandscape: 48,
  58. mobile: 56,
  59. desktop: 64,
  60. dense: 48
  61. },
  62. isActive: true,
  63. isExtended: false,
  64. isScrollingUp: false,
  65. previousScroll: 0,
  66. savedScroll: 0,
  67. target: null
  68. };
  69. },
  70. computed: {
  71. canScroll: function canScroll() {
  72. // TODO: remove
  73. if (this.scrollToolbarOffScreen) {
  74. deprecate('scrollToolbarOffScreen', 'scrollOffScreen', this);
  75. return true;
  76. }
  77. return this.scrollOffScreen || this.invertedScroll;
  78. },
  79. computedContentHeight: function computedContentHeight() {
  80. if (this.height) return parseInt(this.height);
  81. if (this.dense) return this.heights.dense;
  82. if (this.prominent || this.$vuetify.breakpoint.mdAndUp) return this.heights.desktop;
  83. if (this.$vuetify.breakpoint.smAndDown && this.$vuetify.breakpoint.width > this.$vuetify.breakpoint.height) return this.heights.mobileLandscape;
  84. return this.heights.mobile;
  85. },
  86. computedExtensionHeight: function computedExtensionHeight() {
  87. if (this.tabs) return 48;
  88. if (this.extensionHeight) return parseInt(this.extensionHeight);
  89. return this.computedContentHeight;
  90. },
  91. computedHeight: function computedHeight() {
  92. if (!this.isExtended) return this.computedContentHeight;
  93. return this.computedContentHeight + this.computedExtensionHeight;
  94. },
  95. computedMarginTop: function computedMarginTop() {
  96. if (!this.app) return 0;
  97. return this.$vuetify.application.bar;
  98. },
  99. classes: function classes() {
  100. return _extends({
  101. 'v-toolbar': true,
  102. 'elevation-0': this.flat || !this.isActive && !this.tabs && this.canScroll,
  103. 'v-toolbar--absolute': this.absolute,
  104. 'v-toolbar--card': this.card,
  105. 'v-toolbar--clipped': this.clippedLeft || this.clippedRight,
  106. 'v-toolbar--dense': this.dense,
  107. 'v-toolbar--extended': this.isExtended,
  108. 'v-toolbar--fixed': !this.absolute && (this.app || this.fixed),
  109. 'v-toolbar--floating': this.floating,
  110. 'v-toolbar--prominent': this.prominent
  111. }, this.themeClasses);
  112. },
  113. computedPaddingLeft: function computedPaddingLeft() {
  114. if (!this.app || this.clippedLeft) return 0;
  115. return this.$vuetify.application.left;
  116. },
  117. computedPaddingRight: function computedPaddingRight() {
  118. if (!this.app || this.clippedRight) return 0;
  119. return this.$vuetify.application.right;
  120. },
  121. computedTransform: function computedTransform() {
  122. return !this.isActive ? this.canScroll ? -this.computedContentHeight : -this.computedHeight : 0;
  123. },
  124. currentThreshold: function currentThreshold() {
  125. return Math.abs(this.currentScroll - this.savedScroll);
  126. },
  127. styles: function styles() {
  128. return {
  129. marginTop: this.computedMarginTop + 'px',
  130. paddingRight: this.computedPaddingRight + 'px',
  131. paddingLeft: this.computedPaddingLeft + 'px',
  132. transform: 'translateY(' + this.computedTransform + 'px)'
  133. };
  134. }
  135. },
  136. watch: {
  137. currentThreshold: function currentThreshold(val) {
  138. if (this.invertedScroll) {
  139. this.isActive = this.currentScroll > this.scrollThreshold;
  140. return;
  141. }
  142. if (val < this.scrollThreshold || !this.isBooted) return;
  143. this.isActive = this.isScrollingUp;
  144. this.savedScroll = this.currentScroll;
  145. },
  146. isActive: function isActive() {
  147. this.savedScroll = 0;
  148. },
  149. invertedScroll: function invertedScroll(val) {
  150. this.isActive = !val;
  151. },
  152. manualScroll: function manualScroll(val) {
  153. this.isActive = !val;
  154. },
  155. isScrollingUp: function isScrollingUp() {
  156. this.savedScroll = this.savedScroll || this.currentScroll;
  157. }
  158. },
  159. created: function created() {
  160. if (this.invertedScroll || this.manualScroll) this.isActive = false;
  161. },
  162. mounted: function mounted() {
  163. if (this.scrollTarget) {
  164. this.target = document.querySelector(this.scrollTarget);
  165. }
  166. },
  167. methods: {
  168. onScroll: function onScroll() {
  169. if (!this.canScroll || this.manualScroll || typeof window === 'undefined') return;
  170. this.currentScroll = this.target ? this.target.scrollTop : window.pageYOffset;
  171. this.isScrollingUp = this.currentScroll < this.previousScroll;
  172. this.previousScroll = this.currentScroll;
  173. },
  174. updateApplication: function updateApplication() {
  175. return this.invertedScroll || this.manualScroll ? 0 : this.computedHeight;
  176. }
  177. },
  178. render: function render(h) {
  179. this.isExtended = this.extended || !!this.$slots.extension;
  180. var children = [];
  181. var data = this.setBackgroundColor(this.color, {
  182. 'class': this.classes,
  183. style: this.styles,
  184. on: this.$listeners
  185. });
  186. data.directives = [{
  187. arg: this.scrollTarget,
  188. name: 'scroll',
  189. value: this.onScroll
  190. }];
  191. children.push(h('div', {
  192. staticClass: 'v-toolbar__content',
  193. style: { height: this.computedContentHeight + 'px' },
  194. ref: 'content'
  195. }, this.$slots.default));
  196. if (this.isExtended) {
  197. children.push(h('div', {
  198. staticClass: 'v-toolbar__extension',
  199. style: { height: this.computedExtensionHeight + 'px' }
  200. }, this.$slots.extension));
  201. }
  202. return h('nav', data, children);
  203. }
  204. });
  205. //# sourceMappingURL=VToolbar.js.map