123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- 'use strict';
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- 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
-
- // Mixins
-
- // Directives
-
- // Types
-
-
- require('../../../src/stylus/components/_toolbar.styl');
-
- var _applicationable = require('../../mixins/applicationable');
-
- var _applicationable2 = _interopRequireDefault(_applicationable);
-
- var _colorable = require('../../mixins/colorable');
-
- var _colorable2 = _interopRequireDefault(_colorable);
-
- var _themeable = require('../../mixins/themeable');
-
- var _themeable2 = _interopRequireDefault(_themeable);
-
- var _ssrBootable = require('../../mixins/ssr-bootable');
-
- var _ssrBootable2 = _interopRequireDefault(_ssrBootable);
-
- var _scroll = require('../../directives/scroll');
-
- var _scroll2 = _interopRequireDefault(_scroll);
-
- var _console = require('../../util/console');
-
- var _mixins = require('../../util/mixins');
-
- var _mixins2 = _interopRequireDefault(_mixins);
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- exports.default = (0, _mixins2.default)((0, _applicationable2.default)('top', ['clippedLeft', 'clippedRight', 'computedHeight', 'invertedScroll', 'manualScroll']), _colorable2.default, _ssrBootable2.default, _themeable2.default
- /* @vue/component */
- ).extend({
- name: 'v-toolbar',
- directives: { Scroll: _scroll2.default },
- props: {
- card: Boolean,
- clippedLeft: Boolean,
- clippedRight: Boolean,
- dense: Boolean,
- extended: Boolean,
- extensionHeight: {
- type: [Number, String],
- validator: function validator(v) {
- return !isNaN(parseInt(v));
- }
- },
- flat: Boolean,
- floating: Boolean,
- height: {
- type: [Number, String],
- validator: function validator(v) {
- return !isNaN(parseInt(v));
- }
- },
- invertedScroll: Boolean,
- manualScroll: Boolean,
- prominent: Boolean,
- scrollOffScreen: Boolean,
- /* @deprecated */
- scrollToolbarOffScreen: Boolean,
- scrollTarget: String,
- scrollThreshold: {
- type: Number,
- default: 300
- },
- tabs: Boolean
- },
- data: function data() {
- return {
- activeTimeout: null,
- currentScroll: 0,
- heights: {
- mobileLandscape: 48,
- mobile: 56,
- desktop: 64,
- dense: 48
- },
- isActive: true,
- isExtended: false,
- isScrollingUp: false,
- previousScroll: 0,
- savedScroll: 0,
- target: null
- };
- },
- computed: {
- canScroll: function canScroll() {
- // TODO: remove
- if (this.scrollToolbarOffScreen) {
- (0, _console.deprecate)('scrollToolbarOffScreen', 'scrollOffScreen', this);
- return true;
- }
- return this.scrollOffScreen || this.invertedScroll;
- },
- computedContentHeight: function computedContentHeight() {
- if (this.height) return parseInt(this.height);
- if (this.dense) return this.heights.dense;
- if (this.prominent || this.$vuetify.breakpoint.mdAndUp) return this.heights.desktop;
- if (this.$vuetify.breakpoint.smAndDown && this.$vuetify.breakpoint.width > this.$vuetify.breakpoint.height) return this.heights.mobileLandscape;
- return this.heights.mobile;
- },
- computedExtensionHeight: function computedExtensionHeight() {
- if (this.tabs) return 48;
- if (this.extensionHeight) return parseInt(this.extensionHeight);
- return this.computedContentHeight;
- },
- computedHeight: function computedHeight() {
- if (!this.isExtended) return this.computedContentHeight;
- return this.computedContentHeight + this.computedExtensionHeight;
- },
- computedMarginTop: function computedMarginTop() {
- if (!this.app) return 0;
- return this.$vuetify.application.bar;
- },
- classes: function classes() {
- return _extends({
- 'v-toolbar': true,
- 'elevation-0': this.flat || !this.isActive && !this.tabs && this.canScroll,
- 'v-toolbar--absolute': this.absolute,
- 'v-toolbar--card': this.card,
- 'v-toolbar--clipped': this.clippedLeft || this.clippedRight,
- 'v-toolbar--dense': this.dense,
- 'v-toolbar--extended': this.isExtended,
- 'v-toolbar--fixed': !this.absolute && (this.app || this.fixed),
- 'v-toolbar--floating': this.floating,
- 'v-toolbar--prominent': this.prominent
- }, this.themeClasses);
- },
- computedPaddingLeft: function computedPaddingLeft() {
- if (!this.app || this.clippedLeft) return 0;
- return this.$vuetify.application.left;
- },
- computedPaddingRight: function computedPaddingRight() {
- if (!this.app || this.clippedRight) return 0;
- return this.$vuetify.application.right;
- },
- computedTransform: function computedTransform() {
- return !this.isActive ? this.canScroll ? -this.computedContentHeight : -this.computedHeight : 0;
- },
- currentThreshold: function currentThreshold() {
- return Math.abs(this.currentScroll - this.savedScroll);
- },
- styles: function styles() {
- return {
- marginTop: this.computedMarginTop + 'px',
- paddingRight: this.computedPaddingRight + 'px',
- paddingLeft: this.computedPaddingLeft + 'px',
- transform: 'translateY(' + this.computedTransform + 'px)'
- };
- }
- },
- watch: {
- currentThreshold: function currentThreshold(val) {
- if (this.invertedScroll) {
- this.isActive = this.currentScroll > this.scrollThreshold;
- return;
- }
- if (val < this.scrollThreshold || !this.isBooted) return;
- this.isActive = this.isScrollingUp;
- this.savedScroll = this.currentScroll;
- },
- isActive: function isActive() {
- this.savedScroll = 0;
- },
- invertedScroll: function invertedScroll(val) {
- this.isActive = !val;
- },
- manualScroll: function manualScroll(val) {
- this.isActive = !val;
- },
- isScrollingUp: function isScrollingUp() {
- this.savedScroll = this.savedScroll || this.currentScroll;
- }
- },
- created: function created() {
- if (this.invertedScroll || this.manualScroll) this.isActive = false;
- },
- mounted: function mounted() {
- if (this.scrollTarget) {
- this.target = document.querySelector(this.scrollTarget);
- }
- },
-
- methods: {
- onScroll: function onScroll() {
- if (!this.canScroll || this.manualScroll || typeof window === 'undefined') return;
- this.currentScroll = this.target ? this.target.scrollTop : window.pageYOffset;
- this.isScrollingUp = this.currentScroll < this.previousScroll;
- this.previousScroll = this.currentScroll;
- },
- updateApplication: function updateApplication() {
- return this.invertedScroll || this.manualScroll ? 0 : this.computedHeight;
- }
- },
- render: function render(h) {
- this.isExtended = this.extended || !!this.$slots.extension;
- var children = [];
- var data = this.setBackgroundColor(this.color, {
- 'class': this.classes,
- style: this.styles,
- on: this.$listeners
- });
- data.directives = [{
- arg: this.scrollTarget,
- name: 'scroll',
- value: this.onScroll
- }];
- children.push(h('div', {
- staticClass: 'v-toolbar__content',
- style: { height: this.computedContentHeight + 'px' },
- ref: 'content'
- }, this.$slots.default));
- if (this.isExtended) {
- children.push(h('div', {
- staticClass: 'v-toolbar__extension',
- style: { height: this.computedExtensionHeight + 'px' }
- }, this.$slots.extension));
- }
- return h('nav', data, children);
- }
- });
- //# sourceMappingURL=VToolbar.js.map
|