UNPKG

@material/toolbar

Version:
1,008 lines 73.2 kB
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE */ (function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === "object" && typeof module === "object") module.exports = factory(); else if (typeof define === "function" && define.amd) define([], factory); else if (typeof exports === "object") exports["toolbar"] = factory(); else root["mdc"] = root["mdc"] || {}, root["mdc"]["toolbar"] = factory(); })(this, function() { return function(modules) { var installedModules = {}; function __webpack_require__(moduleId) { if (installedModules[moduleId]) { return installedModules[moduleId].exports; } var module = installedModules[moduleId] = { i: moduleId, l: false, exports: {} }; modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); module.l = true; return module.exports; } __webpack_require__.m = modules; __webpack_require__.c = installedModules; __webpack_require__.d = function(exports, name, getter) { if (!__webpack_require__.o(exports, name)) { Object.defineProperty(exports, name, { configurable: false, enumerable: true, get: getter }); } }; __webpack_require__.n = function(module) { var getter = module && module.__esModule ? function getDefault() { return module["default"]; } : function getModuleExports() { return module; }; __webpack_require__.d(getter, "a", getter); return getter; }; __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; __webpack_require__.p = ""; return __webpack_require__(__webpack_require__.s = 173); }({ 0: function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var MDCFoundation = function() { function MDCFoundation(adapter) { if (adapter === void 0) { adapter = {}; } this.adapter_ = adapter; } Object.defineProperty(MDCFoundation, "cssClasses", { get: function get() { return {}; }, enumerable: true, configurable: true }); Object.defineProperty(MDCFoundation, "strings", { get: function get() { return {}; }, enumerable: true, configurable: true }); Object.defineProperty(MDCFoundation, "numbers", { get: function get() { return {}; }, enumerable: true, configurable: true }); Object.defineProperty(MDCFoundation, "defaultAdapter", { get: function get() { return {}; }, enumerable: true, configurable: true }); MDCFoundation.prototype.init = function() {}; MDCFoundation.prototype.destroy = function() {}; return MDCFoundation; }(); exports.MDCFoundation = MDCFoundation; exports.default = MDCFoundation; }, 1: function(module, exports, __webpack_require__) { "use strict"; var __read = this && this.__read || function(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) { ar.push(r.value); } } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread = this && this.__spread || function() { for (var ar = [], i = 0; i < arguments.length; i++) { ar = ar.concat(__read(arguments[i])); } return ar; }; Object.defineProperty(exports, "__esModule", { value: true }); var foundation_1 = __webpack_require__(0); var MDCComponent = function() { function MDCComponent(root, foundation) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } this.root_ = root; this.initialize.apply(this, __spread(args)); this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation; this.foundation_.init(); this.initialSyncWithDOM(); } MDCComponent.attachTo = function(root) { return new MDCComponent(root, new foundation_1.MDCFoundation({})); }; MDCComponent.prototype.initialize = function() { var _args = []; for (var _i = 0; _i < arguments.length; _i++) { _args[_i] = arguments[_i]; } }; MDCComponent.prototype.getDefaultFoundation = function() { throw new Error("Subclasses must override getDefaultFoundation to return a properly configured " + "foundation class"); }; MDCComponent.prototype.initialSyncWithDOM = function() {}; MDCComponent.prototype.destroy = function() { this.foundation_.destroy(); }; MDCComponent.prototype.listen = function(evtType, handler) { this.root_.addEventListener(evtType, handler); }; MDCComponent.prototype.unlisten = function(evtType, handler) { this.root_.removeEventListener(evtType, handler); }; MDCComponent.prototype.emit = function(evtType, evtData, shouldBubble) { if (shouldBubble === void 0) { shouldBubble = false; } var evt; if (typeof CustomEvent === "function") { evt = new CustomEvent(evtType, { bubbles: shouldBubble, detail: evtData }); } else { evt = document.createEvent("CustomEvent"); evt.initCustomEvent(evtType, shouldBubble, false, evtData); } this.root_.dispatchEvent(evt); }; return MDCComponent; }(); exports.MDCComponent = MDCComponent; exports.default = MDCComponent; }, 107: function(module, exports, __webpack_require__) { "use strict"; var __extends = this && this.__extends || function() { var _extendStatics = function extendStatics(d, b) { _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) { d.__proto__ = b; } || function(d, b) { for (var p in b) { if (b.hasOwnProperty(p)) d[p] = b[p]; } }; return _extendStatics(d, b); }; return function(d, b) { _extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); var __assign = this && this.__assign || function() { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var foundation_1 = __webpack_require__(0); var constants_1 = __webpack_require__(108); var MDCToolbarFoundation = function(_super) { __extends(MDCToolbarFoundation, _super); function MDCToolbarFoundation(adapter) { var _this = _super.call(this, __assign({}, MDCToolbarFoundation.defaultAdapter, adapter)) || this; _this.checkRowHeightFrame_ = 0; _this.scrollFrame_ = 0; _this.executedLastChange_ = false; _this.isFixed_ = false; _this.isFixedLastRow_ = false; _this.hasFlexibleFirstRow_ = false; _this.useFlexDefaultBehavior_ = false; _this.calculations_ = { flexibleExpansionHeight: 0, flexibleExpansionRatio: 0, maxTranslateYDistance: 0, maxTranslateYRatio: 0, scrollThreshold: 0, scrollThresholdRatio: 0, toolbarHeight: 0, toolbarRatio: 0, toolbarRowHeight: 0 }; return _this; } Object.defineProperty(MDCToolbarFoundation, "cssClasses", { get: function get() { return constants_1.cssClasses; }, enumerable: true, configurable: true }); Object.defineProperty(MDCToolbarFoundation, "strings", { get: function get() { return constants_1.strings; }, enumerable: true, configurable: true }); Object.defineProperty(MDCToolbarFoundation, "numbers", { get: function get() { return constants_1.numbers; }, enumerable: true, configurable: true }); Object.defineProperty(MDCToolbarFoundation, "defaultAdapter", { get: function get() { return { hasClass: function hasClass() { return false; }, addClass: function addClass() { return undefined; }, removeClass: function removeClass() { return undefined; }, registerScrollHandler: function registerScrollHandler() { return undefined; }, deregisterScrollHandler: function deregisterScrollHandler() { return undefined; }, registerResizeHandler: function registerResizeHandler() { return undefined; }, deregisterResizeHandler: function deregisterResizeHandler() { return undefined; }, getViewportWidth: function getViewportWidth() { return 0; }, getViewportScrollY: function getViewportScrollY() { return 0; }, getOffsetHeight: function getOffsetHeight() { return 0; }, getFirstRowElementOffsetHeight: function getFirstRowElementOffsetHeight() { return 0; }, notifyChange: function notifyChange() { return undefined; }, setStyle: function setStyle() { return undefined; }, setStyleForTitleElement: function setStyleForTitleElement() { return undefined; }, setStyleForFlexibleRowElement: function setStyleForFlexibleRowElement() { return undefined; }, setStyleForFixedAdjustElement: function setStyleForFixedAdjustElement() { return undefined; } }; }, enumerable: true, configurable: true }); MDCToolbarFoundation.prototype.init = function() { var _this = this; this.isFixed_ = this.adapter_.hasClass(constants_1.cssClasses.FIXED); this.isFixedLastRow_ = this.adapter_.hasClass(constants_1.cssClasses.FIXED_LASTROW) && this.isFixed_; this.hasFlexibleFirstRow_ = this.adapter_.hasClass(constants_1.cssClasses.TOOLBAR_ROW_FLEXIBLE); if (this.hasFlexibleFirstRow_) { this.useFlexDefaultBehavior_ = this.adapter_.hasClass(constants_1.cssClasses.FLEXIBLE_DEFAULT_BEHAVIOR); } this.resizeHandler_ = function() { return _this.checkRowHeight_(); }; this.scrollHandler_ = function() { return _this.updateToolbarStyles_(); }; this.adapter_.registerResizeHandler(this.resizeHandler_); this.adapter_.registerScrollHandler(this.scrollHandler_); this.initKeyRatio_(); this.setKeyHeights_(); }; MDCToolbarFoundation.prototype.destroy = function() { this.adapter_.deregisterResizeHandler(this.resizeHandler_); this.adapter_.deregisterScrollHandler(this.scrollHandler_); }; MDCToolbarFoundation.prototype.updateAdjustElementStyles = function() { if (this.isFixed_) { this.adapter_.setStyleForFixedAdjustElement("margin-top", this.calculations_.toolbarHeight + "px"); } }; MDCToolbarFoundation.prototype.getFlexibleExpansionRatio_ = function(scrollTop) { var delta = 1e-4; return Math.max(0, 1 - scrollTop / (this.calculations_.flexibleExpansionHeight + delta)); }; MDCToolbarFoundation.prototype.checkRowHeight_ = function() { var _this = this; cancelAnimationFrame(this.checkRowHeightFrame_); this.checkRowHeightFrame_ = requestAnimationFrame(function() { return _this.setKeyHeights_(); }); }; MDCToolbarFoundation.prototype.setKeyHeights_ = function() { var newToolbarRowHeight = this.getRowHeight_(); if (newToolbarRowHeight !== this.calculations_.toolbarRowHeight) { this.calculations_.toolbarRowHeight = newToolbarRowHeight; this.calculations_.toolbarHeight = this.calculations_.toolbarRatio * this.calculations_.toolbarRowHeight; this.calculations_.flexibleExpansionHeight = this.calculations_.flexibleExpansionRatio * this.calculations_.toolbarRowHeight; this.calculations_.maxTranslateYDistance = this.calculations_.maxTranslateYRatio * this.calculations_.toolbarRowHeight; this.calculations_.scrollThreshold = this.calculations_.scrollThresholdRatio * this.calculations_.toolbarRowHeight; this.updateAdjustElementStyles(); this.updateToolbarStyles_(); } }; MDCToolbarFoundation.prototype.updateToolbarStyles_ = function() { var _this = this; cancelAnimationFrame(this.scrollFrame_); this.scrollFrame_ = requestAnimationFrame(function() { var scrollTop = _this.adapter_.getViewportScrollY(); var hasScrolledOutOfThreshold = _this.scrolledOutOfThreshold_(scrollTop); if (hasScrolledOutOfThreshold && _this.executedLastChange_) { return; } var flexibleExpansionRatio = _this.getFlexibleExpansionRatio_(scrollTop); _this.updateToolbarFlexibleState_(flexibleExpansionRatio); if (_this.isFixedLastRow_) { _this.updateToolbarFixedState_(scrollTop); } if (_this.hasFlexibleFirstRow_) { _this.updateFlexibleRowElementStyles_(flexibleExpansionRatio); } _this.executedLastChange_ = hasScrolledOutOfThreshold; _this.adapter_.notifyChange({ flexibleExpansionRatio: flexibleExpansionRatio }); }); }; MDCToolbarFoundation.prototype.scrolledOutOfThreshold_ = function(scrollTop) { return scrollTop > this.calculations_.scrollThreshold; }; MDCToolbarFoundation.prototype.initKeyRatio_ = function() { var toolbarRowHeight = this.getRowHeight_(); var firstRowMaxRatio = this.adapter_.getFirstRowElementOffsetHeight() / toolbarRowHeight; this.calculations_.toolbarRatio = this.adapter_.getOffsetHeight() / toolbarRowHeight; this.calculations_.flexibleExpansionRatio = firstRowMaxRatio - 1; this.calculations_.maxTranslateYRatio = this.isFixedLastRow_ ? this.calculations_.toolbarRatio - firstRowMaxRatio : 0; this.calculations_.scrollThresholdRatio = (this.isFixedLastRow_ ? this.calculations_.toolbarRatio : firstRowMaxRatio) - 1; }; MDCToolbarFoundation.prototype.getRowHeight_ = function() { var breakpoint = constants_1.numbers.TOOLBAR_MOBILE_BREAKPOINT; return this.adapter_.getViewportWidth() < breakpoint ? constants_1.numbers.TOOLBAR_ROW_MOBILE_HEIGHT : constants_1.numbers.TOOLBAR_ROW_HEIGHT; }; MDCToolbarFoundation.prototype.updateToolbarFlexibleState_ = function(flexibleExpansionRatio) { this.adapter_.removeClass(constants_1.cssClasses.FLEXIBLE_MAX); this.adapter_.removeClass(constants_1.cssClasses.FLEXIBLE_MIN); if (flexibleExpansionRatio === 1) { this.adapter_.addClass(constants_1.cssClasses.FLEXIBLE_MAX); } else if (flexibleExpansionRatio === 0) { this.adapter_.addClass(constants_1.cssClasses.FLEXIBLE_MIN); } }; MDCToolbarFoundation.prototype.updateToolbarFixedState_ = function(scrollTop) { var translateDistance = Math.max(0, Math.min(scrollTop - this.calculations_.flexibleExpansionHeight, this.calculations_.maxTranslateYDistance)); this.adapter_.setStyle("transform", "translateY(" + -translateDistance + "px)"); if (translateDistance === this.calculations_.maxTranslateYDistance) { this.adapter_.addClass(constants_1.cssClasses.FIXED_AT_LAST_ROW); } else { this.adapter_.removeClass(constants_1.cssClasses.FIXED_AT_LAST_ROW); } }; MDCToolbarFoundation.prototype.updateFlexibleRowElementStyles_ = function(flexibleExpansionRatio) { if (this.isFixed_) { var height = this.calculations_.flexibleExpansionHeight * flexibleExpansionRatio; this.adapter_.setStyleForFlexibleRowElement("height", height + this.calculations_.toolbarRowHeight + "px"); } if (this.useFlexDefaultBehavior_) { this.updateElementStylesDefaultBehavior_(flexibleExpansionRatio); } }; MDCToolbarFoundation.prototype.updateElementStylesDefaultBehavior_ = function(flexibleExpansionRatio) { var maxTitleSize = constants_1.numbers.MAX_TITLE_SIZE; var minTitleSize = constants_1.numbers.MIN_TITLE_SIZE; var currentTitleSize = (maxTitleSize - minTitleSize) * flexibleExpansionRatio + minTitleSize; this.adapter_.setStyleForTitleElement("font-size", currentTitleSize + "rem"); }; return MDCToolbarFoundation; }(foundation_1.MDCFoundation); exports.MDCToolbarFoundation = MDCToolbarFoundation; exports.default = MDCToolbarFoundation; }, 108: function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cssClasses = { FIXED: "mdc-toolbar--fixed", FIXED_AT_LAST_ROW: "mdc-toolbar--fixed-at-last-row", FIXED_LASTROW: "mdc-toolbar--fixed-lastrow-only", FLEXIBLE_DEFAULT_BEHAVIOR: "mdc-toolbar--flexible-default-behavior", FLEXIBLE_MAX: "mdc-toolbar--flexible-space-maximized", FLEXIBLE_MIN: "mdc-toolbar--flexible-space-minimized", TOOLBAR_ROW_FLEXIBLE: "mdc-toolbar--flexible" }; exports.strings = { CHANGE_EVENT: "MDCToolbar:change", FIRST_ROW_SELECTOR: ".mdc-toolbar__row:first-child", ICON_SELECTOR: ".mdc-toolbar__icon", TITLE_SELECTOR: ".mdc-toolbar__title" }; exports.numbers = { MAX_TITLE_SIZE: 2.125, MIN_TITLE_SIZE: 1.25, TOOLBAR_MOBILE_BREAKPOINT: 600, TOOLBAR_ROW_HEIGHT: 64, TOOLBAR_ROW_MOBILE_HEIGHT: 56 }; }, 173: function(module, exports, __webpack_require__) { "use strict"; function __export(m) { for (var p in m) { if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } } Object.defineProperty(exports, "__esModule", { value: true }); __export(__webpack_require__(174)); __export(__webpack_require__(108)); __export(__webpack_require__(107)); }, 174: function(module, exports, __webpack_require__) { "use strict"; var __extends = this && this.__extends || function() { var _extendStatics = function extendStatics(d, b) { _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) { d.__proto__ = b; } || function(d, b) { for (var p in b) { if (b.hasOwnProperty(p)) d[p] = b[p]; } }; return _extendStatics(d, b); }; return function(d, b) { _extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); Object.defineProperty(exports, "__esModule", { value: true }); var component_1 = __webpack_require__(1); var component_2 = __webpack_require__(6); var foundation_1 = __webpack_require__(107); var strings = foundation_1.MDCToolbarFoundation.strings; var MDCToolbar = function(_super) { __extends(MDCToolbar, _super); function MDCToolbar() { return _super !== null && _super.apply(this, arguments) || this; } MDCToolbar.attachTo = function(root) { return new MDCToolbar(root); }; MDCToolbar.prototype.initialize = function() { var _this = this; this.ripples_ = []; this.fixedAdjustElement_ = null; this.titleElement_ = this.root_.querySelector(strings.TITLE_SELECTOR); var firstRowElement = this.root_.querySelector(strings.FIRST_ROW_SELECTOR); if (!firstRowElement) { throw new Error("MDCToolbar: Required sub-element '" + strings.FIRST_ROW_SELECTOR + "' is missing"); } this.firstRowElement_ = firstRowElement; [].forEach.call(this.root_.querySelectorAll(strings.ICON_SELECTOR), function(icon) { var ripple = component_2.MDCRipple.attachTo(icon); ripple.unbounded = true; _this.ripples_.push(ripple); }); }; MDCToolbar.prototype.destroy = function() { this.ripples_.forEach(function(ripple) { ripple.destroy(); }); _super.prototype.destroy.call(this); }; Object.defineProperty(MDCToolbar.prototype, "fixedAdjustElement", { get: function get() { return this.fixedAdjustElement_; }, set: function set(element) { this.fixedAdjustElement_ = element; this.foundation_.updateAdjustElementStyles(); }, enumerable: true, configurable: true }); MDCToolbar.prototype.getDefaultFoundation = function() { var _this = this; var adapter = { hasClass: function hasClass(className) { return _this.root_.classList.contains(className); }, addClass: function addClass(className) { return _this.root_.classList.add(className); }, removeClass: function removeClass(className) { return _this.root_.classList.remove(className); }, registerScrollHandler: function registerScrollHandler(handler) { return window.addEventListener("scroll", handler); }, deregisterScrollHandler: function deregisterScrollHandler(handler) { return window.removeEventListener("scroll", handler); }, registerResizeHandler: function registerResizeHandler(handler) { return window.addEventListener("resize", handler); }, deregisterResizeHandler: function deregisterResizeHandler(handler) { return window.removeEventListener("resize", handler); }, getViewportWidth: function getViewportWidth() { return window.innerWidth; }, getViewportScrollY: function getViewportScrollY() { return window.pageYOffset; }, getOffsetHeight: function getOffsetHeight() { return _this.root_.offsetHeight; }, getFirstRowElementOffsetHeight: function getFirstRowElementOffsetHeight() { return _this.firstRowElement_.offsetHeight; }, notifyChange: function notifyChange(evtData) { return _this.emit(strings.CHANGE_EVENT, evtData); }, setStyle: function setStyle(property, value) { return _this.root_.style.setProperty(property, value); }, setStyleForTitleElement: function setStyleForTitleElement(property, value) { if (_this.titleElement_) { _this.titleElement_.style.setProperty(property, value); } }, setStyleForFlexibleRowElement: function setStyleForFlexibleRowElement(property, value) { return _this.firstRowElement_.style.setProperty(property, value); }, setStyleForFixedAdjustElement: function setStyleForFixedAdjustElement(property, value) { if (_this.fixedAdjustElement) { _this.fixedAdjustElement.style.setProperty(property, value); } } }; return new foundation_1.MDCToolbarFoundation(adapter); }; return MDCToolbar; }(component_1.MDCComponent); exports.MDCToolbar = MDCToolbar; }, 2: function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function closest(element, selector) { if (element.closest) { return element.closest(selector); } var el = element; while (el) { if (matches(el, selector)) { return el; } el = el.parentElement; } return null; } exports.closest = closest; function matches(element, selector) { var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector; return nativeMatches.call(element, selector); } exports.matches = matches; }, 3: function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var supportsCssVariables_; var supportsPassive_; function detectEdgePseudoVarBug(windowObj) { var document = windowObj.document; var node = document.createElement("div"); node.className = "mdc-ripple-surface--test-edge-var-bug"; document.body.appendChild(node); var computedStyle = windowObj.getComputedStyle(node); var hasPseudoVarBug = computedStyle !== null && computedStyle.borderTopStyle === "solid"; if (node.parentNode) { node.parentNode.removeChild(node); } return hasPseudoVarBug; } function supportsCssVariables(windowObj, forceRefresh) { if (forceRefresh === void 0) { forceRefresh = false; } var CSS = windowObj.CSS; var supportsCssVars = supportsCssVariables_; if (typeof supportsCssVariables_ === "boolean" && !forceRefresh) { return supportsCssVariables_; } var supportsFunctionPresent = CSS && typeof CSS.supports === "function"; if (!supportsFunctionPresent) { return false; } var explicitlySupportsCssVars = CSS.supports("--css-vars", "yes"); var weAreFeatureDetectingSafari10plus = CSS.supports("(--css-vars: yes)") && CSS.supports("color", "#00000000"); if (explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus) { supportsCssVars = !detectEdgePseudoVarBug(windowObj); } else { supportsCssVars = false; } if (!forceRefresh) { supportsCssVariables_ = supportsCssVars; } return supportsCssVars; } exports.supportsCssVariables = supportsCssVariables; function applyPassive(globalObj, forceRefresh) { if (globalObj === void 0) { globalObj = window; } if (forceRefresh === void 0) { forceRefresh = false; } if (supportsPassive_ === undefined || forceRefresh) { var isSupported_1 = false; try { globalObj.document.addEventListener("test", function() { return undefined; }, { get passive() { isSupported_1 = true; return isSupported_1; } }); } catch (e) {} supportsPassive_ = isSupported_1; } return supportsPassive_ ? { passive: true } : false; } exports.applyPassive = applyPassive; function getNormalizedEventCoords(evt, pageOffset, clientRect) { if (!evt) { return { x: 0, y: 0 }; } var x = pageOffset.x, y = pageOffset.y; var documentX = x + clientRect.left; var documentY = y + clientRect.top; var normalizedX; var normalizedY; if (evt.type === "touchstart") { var touchEvent = evt; normalizedX = touchEvent.changedTouches[0].pageX - documentX; normalizedY = touchEvent.changedTouches[0].pageY - documentY; } else { var mouseEvent = evt; normalizedX = mouseEvent.pageX - documentX; normalizedY = mouseEvent.pageY - documentY; } return { x: normalizedX, y: normalizedY }; } exports.getNormalizedEventCoords = getNormalizedEventCoords; }, 4: function(module, exports, __webpack_require__) { "use strict"; var __extends = this && this.__extends || function() { var _extendStatics = function extendStatics(d, b) { _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) { d.__proto__ = b; } || function(d, b) { for (var p in b) { if (b.hasOwnProperty(p)) d[p] = b[p]; } }; return _extendStatics(d, b); }; return function(d, b) { _extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); var __assign = this && this.__assign || function() { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var foundation_1 = __webpack_require__(0); var constants_1 = __webpack_require__(5); var util_1 = __webpack_require__(3); var ACTIVATION_EVENT_TYPES = [ "touchstart", "pointerdown", "mousedown", "keydown" ]; var POINTER_DEACTIVATION_EVENT_TYPES = [ "touchend", "pointerup", "mouseup", "contextmenu" ]; var activatedTargets = []; var MDCRippleFoundation = function(_super) { __extends(MDCRippleFoundation, _super); function MDCRippleFoundation(adapter) { var _this = _super.call(this, __assign({}, MDCRippleFoundation.defaultAdapter, adapter)) || this; _this.activationAnimationHasEnded_ = false; _this.activationTimer_ = 0; _this.fgDeactivationRemovalTimer_ = 0; _this.fgScale_ = "0"; _this.frame_ = { width: 0, height: 0 }; _this.initialSize_ = 0; _this.layoutFrame_ = 0; _this.maxRadius_ = 0; _this.unboundedCoords_ = { left: 0, top: 0 }; _this.activationState_ = _this.defaultActivationState_(); _this.activationTimerCallback_ = function() { _this.activationAnimationHasEnded_ = true; _this.runDeactivationUXLogicIfReady_(); }; _this.activateHandler_ = function(e) { return _this.activate_(e); }; _this.deactivateHandler_ = function() { return _this.deactivate_(); }; _this.focusHandler_ = function() { return _this.handleFocus(); }; _this.blurHandler_ = function() { return _this.handleBlur(); }; _this.resizeHandler_ = function() { return _this.layout(); }; return _this; } Object.defineProperty(MDCRippleFoundation, "cssClasses", { get: function get() { return constants_1.cssClasses; }, enumerable: true, configurable: true }); Object.defineProperty(MDCRippleFoundation, "strings", { get: function get() { return constants_1.strings; }, enumerable: true, configurable: true }); Object.defineProperty(MDCRippleFoundation, "numbers", { get: function get() { return constants_1.numbers; }, enumerable: true, configurable: true }); Object.defineProperty(MDCRippleFoundation, "defaultAdapter", { get: function get() { return { addClass: function addClass() { return undefined; }, browserSupportsCssVars: function browserSupportsCssVars() { return true; }, computeBoundingRect: function computeBoundingRect() { return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 }; }, containsEventTarget: function containsEventTarget() { return true; }, deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() { return undefined; }, deregisterInteractionHandler: function deregisterInteractionHandler() { return undefined; }, deregisterResizeHandler: function deregisterResizeHandler() { return undefined; }, getWindowPageOffset: function getWindowPageOffset() { return { x: 0, y: 0 }; }, isSurfaceActive: function isSurfaceActive() { return true; }, isSurfaceDisabled: function isSurfaceDisabled() { return true; }, isUnbounded: function isUnbounded() { return true; }, registerDocumentInteractionHandler: function registerDocumentInteractionHandler() { return undefined; }, registerInteractionHandler: function registerInteractionHandler() { return undefined; }, registerResizeHandler: function registerResizeHandler() { return undefined; }, removeClass: function removeClass() { return undefined; }, updateCssVariable: function updateCssVariable() { return undefined; } }; }, enumerable: true, configurable: true }); MDCRippleFoundation.prototype.init = function() { var _this = this; var supportsPressRipple = this.supportsPressRipple_(); this.registerRootHandlers_(supportsPressRipple); if (supportsPressRipple) { var _a = MDCRippleFoundation.cssClasses, ROOT_1 = _a.ROOT, UNBOUNDED_1 = _a.UNBOUNDED; requestAnimationFrame(function() { _this.adapter_.addClass(ROOT_1); if (_this.adapter_.isUnbounded()) { _this.adapter_.addClass(UNBOUNDED_1); _this.layoutInternal_(); } }); } }; MDCRippleFoundation.prototype.destroy = function() { var _this = this; if (this.supportsPressRipple_()) { if (this.activationTimer_) { clearTimeout(this.activationTimer_); this.activationTimer_ = 0; this.adapter_.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION); } if (this.fgDeactivationRemovalTimer_) { clearTimeout(this.fgDeactivationRemovalTimer_); this.fgDeactivationRemovalTimer_ = 0; this.adapter_.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION); } var _a = MDCRippleFoundation.cssClasses, ROOT_2 = _a.ROOT, UNBOUNDED_2 = _a.UNBOUNDED; requestAnimationFrame(function() { _this.adapter_.removeClass(ROOT_2); _this.adapter_.removeClass(UNBOUNDED_2); _this.removeCssVars_(); }); } this.deregisterRootHandlers_(); this.deregisterDeactivationHandlers_(); }; MDCRippleFoundation.prototype.activate = function(evt) { this.activate_(evt); }; MDCRippleFoundation.prototype.deactivate = function() { this.deactivate_(); }; MDCRippleFoundation.prototype.layout = function() { var _this = this; if (this.layoutFrame_) { cancelAnimationFrame(this.layoutFrame_); } this.layoutFrame_ = requestAnimationFrame(function() { _this.layoutInternal_(); _this.layoutFrame_ = 0; }); }; MDCRippleFoundation.prototype.setUnbounded = function(unbounded) { var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED; if (unbounded) { this.adapter_.addClass(UNBOUNDED); } else { this.adapter_.removeClass(UNBOUNDED); } }; MDCRippleFoundation.prototype.handleFocus = function() { var _this = this; requestAnimationFrame(function() { return _this.adapter_.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED); }); }; MDCRippleFoundation.prototype.handleBlur = function() { var _this = this; requestAnimationFrame(function() { return _this.adapter_.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED); }); }; MDCRippleFoundation.prototype.supportsPressRipple_ = function() { return this.adapter_.browserSupportsCssVars(); }; MDCRippleFoundation.prototype.defaultActivationState_ = function() { return { activationEvent: undefined, hasDeactivationUXRun: false, isActi