mdc.animation.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
  7. */
  8. (function webpackUniversalModuleDefinition(root, factory) {
  9. if(typeof exports === 'object' && typeof module === 'object')
  10. module.exports = factory();
  11. else if(typeof define === 'function' && define.amd)
  12. define("@material/animation", [], factory);
  13. else if(typeof exports === 'object')
  14. exports["animation"] = factory();
  15. else
  16. root["mdc"] = root["mdc"] || {}, root["mdc"]["animation"] = factory();
  17. })(this, function() {
  18. return /******/ (function(modules) { // webpackBootstrap
  19. /******/ // The module cache
  20. /******/ var installedModules = {};
  21. /******/
  22. /******/ // The require function
  23. /******/ function __webpack_require__(moduleId) {
  24. /******/
  25. /******/ // Check if module is in cache
  26. /******/ if(installedModules[moduleId]) {
  27. /******/ return installedModules[moduleId].exports;
  28. /******/ }
  29. /******/ // Create a new module (and put it into the cache)
  30. /******/ var module = installedModules[moduleId] = {
  31. /******/ i: moduleId,
  32. /******/ l: false,
  33. /******/ exports: {}
  34. /******/ };
  35. /******/
  36. /******/ // Execute the module function
  37. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  38. /******/
  39. /******/ // Flag the module as loaded
  40. /******/ module.l = true;
  41. /******/
  42. /******/ // Return the exports of the module
  43. /******/ return module.exports;
  44. /******/ }
  45. /******/
  46. /******/
  47. /******/ // expose the modules object (__webpack_modules__)
  48. /******/ __webpack_require__.m = modules;
  49. /******/
  50. /******/ // expose the module cache
  51. /******/ __webpack_require__.c = installedModules;
  52. /******/
  53. /******/ // define getter function for harmony exports
  54. /******/ __webpack_require__.d = function(exports, name, getter) {
  55. /******/ if(!__webpack_require__.o(exports, name)) {
  56. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  57. /******/ }
  58. /******/ };
  59. /******/
  60. /******/ // define __esModule on exports
  61. /******/ __webpack_require__.r = function(exports) {
  62. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  63. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  64. /******/ }
  65. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  66. /******/ };
  67. /******/
  68. /******/ // create a fake namespace object
  69. /******/ // mode & 1: value is a module id, require it
  70. /******/ // mode & 2: merge all properties of value into the ns
  71. /******/ // mode & 4: return value when already ns object
  72. /******/ // mode & 8|1: behave like require
  73. /******/ __webpack_require__.t = function(value, mode) {
  74. /******/ if(mode & 1) value = __webpack_require__(value);
  75. /******/ if(mode & 8) return value;
  76. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  77. /******/ var ns = Object.create(null);
  78. /******/ __webpack_require__.r(ns);
  79. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  80. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  81. /******/ return ns;
  82. /******/ };
  83. /******/
  84. /******/ // getDefaultExport function for compatibility with non-harmony modules
  85. /******/ __webpack_require__.n = function(module) {
  86. /******/ var getter = module && module.__esModule ?
  87. /******/ function getDefault() { return module['default']; } :
  88. /******/ function getModuleExports() { return module; };
  89. /******/ __webpack_require__.d(getter, 'a', getter);
  90. /******/ return getter;
  91. /******/ };
  92. /******/
  93. /******/ // Object.prototype.hasOwnProperty.call
  94. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  95. /******/
  96. /******/ // __webpack_public_path__
  97. /******/ __webpack_require__.p = "";
  98. /******/
  99. /******/
  100. /******/ // Load entry module and return exports
  101. /******/ return __webpack_require__(__webpack_require__.s = "./packages/mdc-animation/index.ts");
  102. /******/ })
  103. /************************************************************************/
  104. /******/ ({
  105. /***/ "./packages/mdc-animation/animationframe.ts":
  106. /*!**************************************************!*\
  107. !*** ./packages/mdc-animation/animationframe.ts ***!
  108. \**************************************************/
  109. /*! no static exports found */
  110. /***/ (function(module, exports, __webpack_require__) {
  111. "use strict";
  112. /**
  113. * @license
  114. * Copyright 2020 Google Inc.
  115. *
  116. * Permission is hereby granted, free of charge, to any person obtaining a copy
  117. * of this software and associated documentation files (the "Software"), to deal
  118. * in the Software without restriction, including without limitation the rights
  119. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  120. * copies of the Software, and to permit persons to whom the Software is
  121. * furnished to do so, subject to the following conditions:
  122. *
  123. * The above copyright notice and this permission notice shall be included in
  124. * all copies or substantial portions of the Software.
  125. *
  126. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  127. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  128. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  129. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  130. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  131. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  132. * THE SOFTWARE.
  133. */
  134. Object.defineProperty(exports, "__esModule", { value: true });
  135. exports.AnimationFrame = void 0;
  136. /**
  137. * AnimationFrame provides a user-friendly abstraction around requesting
  138. * and canceling animation frames.
  139. */
  140. var AnimationFrame = /** @class */function () {
  141. function AnimationFrame() {
  142. this.rafIDs = new Map();
  143. }
  144. /**
  145. * Requests an animation frame. Cancels any existing frame with the same key.
  146. * @param {string} key The key for this callback.
  147. * @param {FrameRequestCallback} callback The callback to be executed.
  148. */
  149. AnimationFrame.prototype.request = function (key, callback) {
  150. var _this = this;
  151. this.cancel(key);
  152. var frameID = requestAnimationFrame(function (frame) {
  153. _this.rafIDs.delete(key);
  154. // Callback must come *after* the key is deleted so that nested calls to
  155. // request with the same key are not deleted.
  156. callback(frame);
  157. });
  158. this.rafIDs.set(key, frameID);
  159. };
  160. /**
  161. * Cancels a queued callback with the given key.
  162. * @param {string} key The key for this callback.
  163. */
  164. AnimationFrame.prototype.cancel = function (key) {
  165. var rafID = this.rafIDs.get(key);
  166. if (rafID) {
  167. cancelAnimationFrame(rafID);
  168. this.rafIDs.delete(key);
  169. }
  170. };
  171. /**
  172. * Cancels all queued callback.
  173. */
  174. AnimationFrame.prototype.cancelAll = function () {
  175. var _this = this;
  176. // Need to use forEach because it's the only iteration method supported
  177. // by IE11. Suppress the underscore because we don't need it.
  178. // tslint:disable-next-line:enforce-name-casing
  179. this.rafIDs.forEach(function (_, key) {
  180. _this.cancel(key);
  181. });
  182. };
  183. /**
  184. * Returns the queue of unexecuted callback keys.
  185. */
  186. AnimationFrame.prototype.getQueue = function () {
  187. var queue = [];
  188. // Need to use forEach because it's the only iteration method supported
  189. // by IE11. Suppress the underscore because we don't need it.
  190. // tslint:disable-next-line:enforce-name-casing
  191. this.rafIDs.forEach(function (_, key) {
  192. queue.push(key);
  193. });
  194. return queue;
  195. };
  196. return AnimationFrame;
  197. }();
  198. exports.AnimationFrame = AnimationFrame;
  199. /***/ }),
  200. /***/ "./packages/mdc-animation/index.ts":
  201. /*!*****************************************!*\
  202. !*** ./packages/mdc-animation/index.ts ***!
  203. \*****************************************/
  204. /*! no static exports found */
  205. /***/ (function(module, exports, __webpack_require__) {
  206. "use strict";
  207. /**
  208. * @license
  209. * Copyright 2019 Google Inc.
  210. *
  211. * Permission is hereby granted, free of charge, to any person obtaining a copy
  212. * of this software and associated documentation files (the "Software"), to deal
  213. * in the Software without restriction, including without limitation the rights
  214. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  215. * copies of the Software, and to permit persons to whom the Software is
  216. * furnished to do so, subject to the following conditions:
  217. *
  218. * The above copyright notice and this permission notice shall be included in
  219. * all copies or substantial portions of the Software.
  220. *
  221. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  222. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  223. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  224. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  225. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  226. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  227. * THE SOFTWARE.
  228. */
  229. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  230. if (k2 === undefined) k2 = k;
  231. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  232. return m[k];
  233. } });
  234. } : function (o, m, k, k2) {
  235. if (k2 === undefined) k2 = k;
  236. o[k2] = m[k];
  237. });
  238. var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
  239. Object.defineProperty(o, "default", { enumerable: true, value: v });
  240. } : function (o, v) {
  241. o["default"] = v;
  242. });
  243. var __importStar = this && this.__importStar || function (mod) {
  244. if (mod && mod.__esModule) return mod;
  245. var result = {};
  246. if (mod != null) for (var k in mod) {
  247. if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  248. }__setModuleDefault(result, mod);
  249. return result;
  250. };
  251. var __exportStar = this && this.__exportStar || function (m, exports) {
  252. for (var p in m) {
  253. if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  254. }
  255. };
  256. Object.defineProperty(exports, "__esModule", { value: true });
  257. exports.util = void 0;
  258. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-animation/util.ts"));
  259. exports.util = util;
  260. __exportStar(__webpack_require__(/*! ./animationframe */ "./packages/mdc-animation/animationframe.ts"), exports);
  261. __exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-animation/types.ts"), exports);
  262. __exportStar(__webpack_require__(/*! ./util */ "./packages/mdc-animation/util.ts"), exports); // Old namespace for backward compatibility
  263. /***/ }),
  264. /***/ "./packages/mdc-animation/types.ts":
  265. /*!*****************************************!*\
  266. !*** ./packages/mdc-animation/types.ts ***!
  267. \*****************************************/
  268. /*! no static exports found */
  269. /***/ (function(module, exports, __webpack_require__) {
  270. "use strict";
  271. /**
  272. * @license
  273. * Copyright 2019 Google Inc.
  274. *
  275. * Permission is hereby granted, free of charge, to any person obtaining a copy
  276. * of this software and associated documentation files (the "Software"), to deal
  277. * in the Software without restriction, including without limitation the rights
  278. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  279. * copies of the Software, and to permit persons to whom the Software is
  280. * furnished to do so, subject to the following conditions:
  281. *
  282. * The above copyright notice and this permission notice shall be included in
  283. * all copies or substantial portions of the Software.
  284. *
  285. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  286. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  287. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  288. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  289. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  290. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  291. * THE SOFTWARE.
  292. */
  293. Object.defineProperty(exports, "__esModule", { value: true });
  294. /***/ }),
  295. /***/ "./packages/mdc-animation/util.ts":
  296. /*!****************************************!*\
  297. !*** ./packages/mdc-animation/util.ts ***!
  298. \****************************************/
  299. /*! no static exports found */
  300. /***/ (function(module, exports, __webpack_require__) {
  301. "use strict";
  302. /**
  303. * @license
  304. * Copyright 2016 Google Inc.
  305. *
  306. * Permission is hereby granted, free of charge, to any person obtaining a copy
  307. * of this software and associated documentation files (the "Software"), to deal
  308. * in the Software without restriction, including without limitation the rights
  309. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  310. * copies of the Software, and to permit persons to whom the Software is
  311. * furnished to do so, subject to the following conditions:
  312. *
  313. * The above copyright notice and this permission notice shall be included in
  314. * all copies or substantial portions of the Software.
  315. *
  316. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  317. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  318. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  319. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  320. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  321. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  322. * THE SOFTWARE.
  323. */
  324. Object.defineProperty(exports, "__esModule", { value: true });
  325. exports.getCorrectEventName = exports.getCorrectPropertyName = void 0;
  326. var cssPropertyNameMap = {
  327. animation: {
  328. prefixed: '-webkit-animation',
  329. standard: 'animation'
  330. },
  331. transform: {
  332. prefixed: '-webkit-transform',
  333. standard: 'transform'
  334. },
  335. transition: {
  336. prefixed: '-webkit-transition',
  337. standard: 'transition'
  338. }
  339. };
  340. var jsEventTypeMap = {
  341. animationend: {
  342. cssProperty: 'animation',
  343. prefixed: 'webkitAnimationEnd',
  344. standard: 'animationend'
  345. },
  346. animationiteration: {
  347. cssProperty: 'animation',
  348. prefixed: 'webkitAnimationIteration',
  349. standard: 'animationiteration'
  350. },
  351. animationstart: {
  352. cssProperty: 'animation',
  353. prefixed: 'webkitAnimationStart',
  354. standard: 'animationstart'
  355. },
  356. transitionend: {
  357. cssProperty: 'transition',
  358. prefixed: 'webkitTransitionEnd',
  359. standard: 'transitionend'
  360. }
  361. };
  362. function isWindow(windowObj) {
  363. return Boolean(windowObj.document) && typeof windowObj.document.createElement === 'function';
  364. }
  365. function getCorrectPropertyName(windowObj, cssProperty) {
  366. if (isWindow(windowObj) && cssProperty in cssPropertyNameMap) {
  367. var el = windowObj.document.createElement('div');
  368. var _a = cssPropertyNameMap[cssProperty],
  369. standard = _a.standard,
  370. prefixed = _a.prefixed;
  371. var isStandard = standard in el.style;
  372. return isStandard ? standard : prefixed;
  373. }
  374. return cssProperty;
  375. }
  376. exports.getCorrectPropertyName = getCorrectPropertyName;
  377. function getCorrectEventName(windowObj, eventType) {
  378. if (isWindow(windowObj) && eventType in jsEventTypeMap) {
  379. var el = windowObj.document.createElement('div');
  380. var _a = jsEventTypeMap[eventType],
  381. standard = _a.standard,
  382. prefixed = _a.prefixed,
  383. cssProperty = _a.cssProperty;
  384. var isStandard = cssProperty in el.style;
  385. return isStandard ? standard : prefixed;
  386. }
  387. return eventType;
  388. }
  389. exports.getCorrectEventName = getCorrectEventName;
  390. /***/ })
  391. /******/ });
  392. });
  393. //# sourceMappingURL=mdc.animation.js.map