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 8.5KB

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