ionic.material.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory((function webpackLoadOptionalExternalModule() { try { return require("angular"); } catch(e) {} }()));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["angular"], factory);
  6. else if(typeof exports === 'object')
  7. exports["ionicMaterial"] = factory((function webpackLoadOptionalExternalModule() { try { return require("angular"); } catch(e) {} }()));
  8. else
  9. root["ionicMaterial"] = factory(root["angular"]);
  10. })(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId])
  20. /******/ return installedModules[moduleId].exports;
  21. /******/
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ exports: {},
  25. /******/ id: moduleId,
  26. /******/ loaded: false
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.loaded = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // __webpack_public_path__
  47. /******/ __webpack_require__.p = "";
  48. /******/
  49. /******/ // Load entry module and return exports
  50. /******/ return __webpack_require__(0);
  51. /******/ })
  52. /************************************************************************/
  53. /******/ ([
  54. /* 0 */
  55. /***/ function(module, exports, __webpack_require__) {
  56. /**
  57. * Ionic Material
  58. * "Bundle Index" / "Entryfile"
  59. * https://github.com/zachsoft/ionic-material
  60. *
  61. * Recommended: use a compiled version, especially in production!
  62. */
  63. 'use strict';
  64. module.exports = (function(){
  65. var angular;
  66. try {
  67. angular = __webpack_require__(1);
  68. } catch(err){ }
  69. if(!angular || !angular.version){
  70. /*global window: true*/
  71. angular = window.angular;
  72. /*global window: false*/
  73. }
  74. if(!angular || !angular.version){
  75. throw new Error('ionic-material could not load angular module :(');
  76. }
  77. // set up angular module
  78. var app = angular.module('ionic-material', ['ionic']);
  79. // Import Dependencies
  80. __webpack_require__(2)(app);
  81. __webpack_require__(3)(app);
  82. return 'ionic-material';
  83. })();
  84. /***/ },
  85. /* 1 */
  86. /***/ function(module, exports, __webpack_require__) {
  87. if(typeof __WEBPACK_EXTERNAL_MODULE_1__ === 'undefined') {var e = new Error("Cannot find module \"angular\""); e.code = 'MODULE_NOT_FOUND'; throw e;}
  88. module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
  89. /***/ },
  90. /* 2 */
  91. /***/ function(module, exports, __webpack_require__) {
  92. 'use strict';
  93. /*!
  94. * Fork by Zach Fitzgerald and other contributors of Ionic Material
  95. *
  96. * Waves v0.5.4
  97. * http://fian.my.id/Waves
  98. *
  99. * Copyright 2014 Alfiana E. Sibuea and other contributors
  100. *
  101. * Released under the MIT license
  102. * https://github.com/fians/Waves/blob/master/LICENSE
  103. *
  104. */
  105. module.exports = function (angularApp) {
  106. angularApp.factory('ionicMaterialInk', ink);
  107. function ink (){
  108. /*global document*/
  109. var Ink = Ink || {};
  110. // all DOM nodes
  111. var $$;
  112. // phantomJS throws an error when you try to use document.querySelectorAll.bind
  113. if(document && document.querySelectorAll && document.querySelectorAll.bind){
  114. try{
  115. // all DOM nodes
  116. $$ = document.querySelectorAll.bind(document);
  117. } catch(e){}
  118. } else if (window && window.angular && window.angular.element) {
  119. // we can use angular.element instead
  120. $$ = window.angular.element;
  121. } else {
  122. /**
  123. * mout.js 0.11.0 bind and slice polyfills (substitutes?)
  124. * TODO: pull out mout.js bind and slice molyfills and inject into material.ink
  125. */
  126. /**
  127. * Create slice of source array or array-like object
  128. */
  129. var slicePolyfill = function moutslicePolyfill(arr, start, end){
  130. var len = arr.length;
  131. /*jshint eqnull:true */
  132. if (start == null) {
  133. start = 0;
  134. } else if (start < 0) {
  135. start = Math.max(len + start, 0);
  136. } else {
  137. start = Math.min(start, len);
  138. }
  139. if (end == null) {
  140. end = len;
  141. } else if (end < 0) {
  142. end = Math.max(len + end, 0);
  143. } else {
  144. end = Math.min(end, len);
  145. }
  146. var result = [];
  147. while (start < end) {
  148. result.push(arr[start++]);
  149. }
  150. return result;
  151. };
  152. /**
  153. * Return a function that will execute in the given context, optionally adding any additional supplied parameters to the beginning of the arguments collection.
  154. * @param {Function} fn Function.
  155. * @param {object} context Execution context.
  156. * @param {rest} args Arguments (0...n arguments).
  157. * @return {Function} Wrapped Function.
  158. */
  159. var bindPolyfill = function moutBind(fn, context, args){
  160. var argsArr = slicePolyfill(arguments, 2); //curried args
  161. return function(){
  162. return fn.apply(context, argsArr.concat(slicePolyfill(arguments)));
  163. };
  164. };
  165. $$ = bindPolyfill(document.querySelectorAll, document);
  166. /*jshint ignore:end */
  167. }
  168. if (!$$){
  169. throw new Error('ionic material ink module could not create reference of DOM nodes');
  170. }
  171. // Find exact position of element
  172. function isWindow(obj) {
  173. return obj !== null && obj === obj.window;
  174. }
  175. function getWindow(elem) {
  176. return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView;
  177. }
  178. function offset(elem) {
  179. var docElem, win,
  180. box = {
  181. top: 0,
  182. left: 0
  183. },
  184. doc = elem && elem.ownerDocument;
  185. docElem = doc.documentElement;
  186. if (typeof elem.getBoundingClientRect !== typeof undefined) {
  187. box = elem.getBoundingClientRect();
  188. }
  189. win = getWindow(doc);
  190. return {
  191. top: box.top + win.pageYOffset - docElem.clientTop,
  192. left: box.left + win.pageXOffset - docElem.clientLeft
  193. };
  194. }
  195. function hexToRgb(hex) {
  196. var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  197. return result ? {
  198. r: parseInt(result[1], 16),
  199. g: parseInt(result[2], 16),
  200. b: parseInt(result[3], 16)
  201. } : null;
  202. }
  203. function convertStyle(obj) {
  204. var style = '';
  205. for (var a in obj) {
  206. if (obj.hasOwnProperty(a)) {
  207. style += (a + ':' + obj[a] + ';');
  208. }
  209. }
  210. return style;
  211. }
  212. var Effect = {
  213. // Effect delay
  214. duration: 500,
  215. show: function(e) {
  216. // Disable right click
  217. if (e.button === 2) {
  218. return false;
  219. }
  220. var el = this;
  221. // Create ripple
  222. var ripple = document.createElement('div');
  223. var customColor = this.dataset.inkColor;
  224. var customOpacity = this.dataset.inkOpacity;
  225. var hasCustomRipple = customColor || customOpacity;
  226. ripple.className = 'ink-ripple';
  227. el.appendChild(ripple);
  228. // Get click coordinate and element witdh
  229. var pos = offset(el);
  230. var relativeY = (e.pageY - pos.top);
  231. var relativeX = (e.pageX - pos.left);
  232. var scale = 'scale(' + ((el.clientWidth / 100) * 2.5) + ')';
  233. // Support for touch devices
  234. if ('touches' in e) {
  235. relativeY = (e.touches[0].pageY - pos.top);
  236. relativeX = (e.touches[0].pageX - pos.left);
  237. }
  238. // Attach data to element
  239. ripple.setAttribute('data-hold', Date.now());
  240. ripple.setAttribute('data-scale', scale);
  241. ripple.setAttribute('data-x', relativeX);
  242. ripple.setAttribute('data-y', relativeY);
  243. // Set ripple position
  244. var rippleStyle = {
  245. 'top': relativeY + 'px',
  246. 'left': relativeX + 'px'
  247. };
  248. ripple.className = ripple.className + ' ink-notransition';
  249. if (hasCustomRipple) {
  250. var colorRgb;
  251. if (customColor) {
  252. var fromHex = hexToRgb(customColor);
  253. colorRgb = fromHex.r + ',' + fromHex.g + ',' + fromHex.b;
  254. } else {
  255. colorRgb = '0,0,0';
  256. }
  257. if (!customOpacity) {
  258. customOpacity = 0.2;
  259. }
  260. var bg = 'rgba(' + colorRgb + ',' + customOpacity + ')';
  261. rippleStyle['background-color'] = bg;
  262. }
  263. ripple.setAttribute('style', convertStyle(rippleStyle));
  264. ripple.className = ripple.className.replace('ink-notransition', '');
  265. // Scale the ripple
  266. rippleStyle['-webkit-transform'] = scale;
  267. rippleStyle['-moz-transform'] = scale;
  268. rippleStyle['-ms-transform'] = scale;
  269. rippleStyle['-o-transform'] = scale;
  270. rippleStyle.transform = scale;
  271. rippleStyle.opacity = '1';
  272. rippleStyle['-webkit-transition-duration'] = Effect.duration + 'ms';
  273. rippleStyle['-moz-transition-duration'] = Effect.duration + 'ms';
  274. rippleStyle['-o-transition-duration'] = Effect.duration + 'ms';
  275. rippleStyle['transition-duration'] = Effect.duration + 'ms';
  276. ripple.setAttribute('style', convertStyle(rippleStyle));
  277. },
  278. hide: function() {
  279. var el = this;
  280. var width = el.clientWidth * 1.4;
  281. // Get first ripple
  282. var ripple = null;
  283. var childrenLength = el.children.length;
  284. for (var a = 0; a < childrenLength; a++) {
  285. if (el.children[a].className.indexOf('ink-ripple') !== -1) {
  286. ripple = el.children[a];
  287. continue;
  288. }
  289. }
  290. if (!ripple) {
  291. return false;
  292. }
  293. var relativeX = ripple.getAttribute('data-x');
  294. var relativeY = ripple.getAttribute('data-y');
  295. var scale = ripple.getAttribute('data-scale');
  296. // Get delay beetween mousedown and mouse leave
  297. var diff = Date.now() - Number(ripple.getAttribute('data-hold'));
  298. var delay = 500 - diff;
  299. if (delay < 0) {
  300. delay = 0;
  301. }
  302. // Fade out ripple after delay
  303. setTimeout(function() {
  304. var style = {
  305. 'top': relativeY + 'px',
  306. 'left': relativeX + 'px',
  307. 'opacity': '0',
  308. // Duration
  309. '-webkit-transition-duration': Effect.duration + 'ms',
  310. '-moz-transition-duration': Effect.duration + 'ms',
  311. '-o-transition-duration': Effect.duration + 'ms',
  312. 'transition-duration': Effect.duration + 'ms',
  313. '-webkit-transform': scale,
  314. '-moz-transform': scale,
  315. '-ms-transform': scale,
  316. '-o-transform': scale,
  317. 'transform': scale,
  318. };
  319. ripple.setAttribute('style', convertStyle(style));
  320. setTimeout(function() {
  321. try {
  322. el.removeChild(ripple);
  323. } catch (e) {
  324. return false;
  325. }
  326. }, Effect.duration);
  327. }, delay);
  328. },
  329. // Little hack to make <input> can perform ink effect
  330. wrapInput: function(elements) {
  331. for (var a = 0; a < elements.length; a++) {
  332. var el = elements[a];
  333. if (el.tagName.toLowerCase() === 'input') {
  334. var parent = el.parentNode;
  335. // If input already have parent just pass through
  336. if (parent.tagName.toLowerCase() === 'i' &&
  337. parent.className.indexOf('ink') !== -1 &&
  338. parent.className.indexOf('tab-item') !== -1 &&
  339. parent.className.indexOf('button-fab') !== -1 &&
  340. parent.className.indexOf('button-raised') !== -1 &&
  341. parent.className.indexOf('button-flat') !== -1 &&
  342. parent.className.indexOf('button-clear') !== -1 &&
  343. parent.className.indexOf('button') !== -1 &&
  344. parent.className.indexOf('item') !== -1) {
  345. return false;
  346. }
  347. // Put element class and style to the specified parent
  348. var wrapper = document.createElement('i');
  349. wrapper.className = el.className + ' ink-input-wrapper';
  350. var elementStyle = el.getAttribute('style');
  351. if (!elementStyle) {
  352. elementStyle = '';
  353. }
  354. wrapper.setAttribute('style', elementStyle);
  355. el.className = 'ink-button-input';
  356. el.removeAttribute('style');
  357. // Put element as child
  358. parent.replaceChild(wrapper, el);
  359. wrapper.appendChild(el);
  360. }
  361. }
  362. }
  363. };
  364. Ink.displayEffect = function(options) {
  365. options = options || {};
  366. if ('duration' in options) {
  367. Effect.duration = options.duration;
  368. }
  369. //Wrap input inside <i> tag
  370. var selectors = '.ink,.tab-item,.button-fab,.button-raised,.button-flat,.button-clear,a.item,.popup .button';
  371. Effect.wrapInput($$(selectors));
  372. Array.prototype.forEach.call($$(selectors), function(i) {
  373. if ('ontouchstart' in window) {
  374. i.addEventListener('touchstart', Effect.show, false);
  375. i.addEventListener('touchend', Effect.hide, false);
  376. i.addEventListener('touchcancel', Effect.hide, false);
  377. } else {
  378. i.addEventListener('mousedown', Effect.show, false);
  379. i.addEventListener('mouseup', Effect.hide, false);
  380. i.addEventListener('mouseleave', Effect.hide, false);
  381. }
  382. });
  383. };
  384. return Ink;
  385. }
  386. ink.inject = [];
  387. };
  388. /***/ },
  389. /* 3 */
  390. /***/ function(module, exports, __webpack_require__) {
  391. module.exports = function(angularApp) {
  392. angularApp.factory('ionicMaterialMotion', Motion);
  393. function Motion() {
  394. /*global document, window*/
  395. 'use strict';
  396. /*============================================================================*/
  397. /* HELPERS (non-exports)
  398. /=============================================================================*
  399. / Abstract common lookups and manipulations in case better alternatives
  400. / arise or future cross-platform differences warrant separate handling
  401. /=============================================================================*/
  402. function getViewportHeight() {
  403. return window.innerHeight;
  404. }
  405. function getBoundingClientRect(domNode) {
  406. return domNode.getBoundingClientRect;
  407. }
  408. function showNotAnimatedElements(elements, total) {
  409. // Load the elements without effect
  410. for (var i = 0; i < total; i++) {
  411. var child = elements[i];
  412. child.className += ' in';
  413. child.className += ' done';
  414. }
  415. }
  416. /*============================================================================*/
  417. /* MOTION (EXPORT)
  418. /=============================================================================*
  419. / Animation methods for the library
  420. /=============================================================================*/
  421. var motion = {
  422. blinds: blinds,
  423. fadeSlideIn: fadeSlideIn,
  424. fadeSlideInRight: fadeSlideInRight,
  425. panInLeft: panInLeft,
  426. pushDown: pushDown,
  427. ripple: ripple,
  428. slideUp: slideUp
  429. };
  430. function blinds(options) {
  431. // Declare our defaults
  432. var defaults = {
  433. finishDelayThrottle: 2,
  434. finishSpeedPercent: 0.5,
  435. leftOffsetPercentage: 0.8,
  436. selector: '.animate-blinds .item',
  437. startVelocity: 1100
  438. };
  439. // Apply defaults if properties are not passed
  440. if (typeof options === 'undefined') {
  441. options = {};
  442. }
  443. options.finishDelayThrottle = options.finishDelayThrottle || defaults.finishDelayThrottle;
  444. options.finishSpeedPercent = options.finishSpeedPercent || defaults.finishSpeedPercent;
  445. options.leftOffsetPercentage = options.leftOffsetPercentage || defaults.leftOffsetPercentage;
  446. options.startVelocity = options.startVelocity || defaults.startVelocity;
  447. if (typeof options.selector == 'undefined') {
  448. options.selector = defaults.selector;
  449. }
  450. // Fail early & silently log
  451. var isInvalidSelector = typeof options.selector === 'undefined' || options.selector === '';
  452. if (isInvalidSelector) {
  453. console.log('invalid blinds selector');
  454. return false;
  455. }
  456. var animateBlindsDom = document.querySelectorAll(options.selector);
  457. var elementsCount = animateBlindsDom.length;
  458. var elementAnimationCount = 0;
  459. // Count the elements within the starting viewport so we're not exacting
  460. // more effort than required...
  461. //
  462. // We use css visiblity: hidden instead of display: none so the elements
  463. // maintain their DOM flow
  464. var viewportHeight = getViewportHeight();
  465. for (var i = 0; i < elementsCount; i++) {
  466. if (animateBlindsDom[i].offsetTop < viewportHeight) {
  467. elementAnimationCount += 1;
  468. continue;
  469. }
  470. break;
  471. }
  472. // Sequentially animate with a delay based on proximity
  473. var speed = options.startVelocity;
  474. for (var i = 0; i < elementAnimationCount; i++) {
  475. var child = animateBlindsDom[i];
  476. var childOffset = child.getBoundingClientRect();
  477. var offset = childOffset.left * options.leftOffsetPercentage + childOffset.top;
  478. var delay = parseFloat(offset / speed).toFixed(2);
  479. child.style.webkitTransitionDelay = delay + "s";
  480. child.style.transitionDelay = delay + "s";
  481. child.className += ' in';
  482. }
  483. // When we're done animating, switch the class to 'done'
  484. setTimeout(function() {
  485. for (var i = 0; i < elementAnimationCount; i++) {
  486. var child = animateBlindsDom[i];
  487. var childOffset = child.getBoundingClientRect();
  488. var offset = childOffset.left * options.leftOffsetPercentage + childOffset.top;
  489. var delay = parseFloat(offset / speed / options.finishDelayThrottle).toFixed(2);
  490. //child.querySelector('img').style.webkitTransitionDelay = delay + "s";
  491. //child.querySelector('img').style.transitionDelay = delay + "s";
  492. //child.querySelector('img').className += ' in';
  493. animateBlindsDom[i].className += ' done';
  494. }
  495. }, speed * options.finishSpeedPercent);
  496. // Load the elements without effect
  497. showNotAnimatedElements(animateBlindsDom, elementsCount);
  498. }
  499. function fadeSlideIn(options) {
  500. // Declare our defaults
  501. var defaults = {
  502. finishDelayThrottle: 2,
  503. finishSpeedPercent: 0.72,
  504. leftOffsetPercentage: 0.8,
  505. selector: '.animate-fade-slide-in .item',
  506. startVelocity: 1100
  507. };
  508. // Apply defaults if properties are not passed
  509. if (typeof options === 'undefined') {
  510. options = {};
  511. }
  512. options.finishDelayThrottle = options.finishDelayThrottle || defaults.finishDelayThrottle;
  513. options.finishSpeedPercent = options.finishSpeedPercent || defaults.finishSpeedPercent;
  514. options.leftOffsetPercentage = options.leftOffsetPercentage || defaults.leftOffsetPercentage;
  515. options.startVelocity = options.startVelocity || defaults.startVelocity;
  516. if (typeof options.selector == 'undefined') {
  517. options.selector = defaults.selector;
  518. }
  519. // Fail early & silently log
  520. var isInvalidSelector = typeof options.selector === 'undefined' || options.selector === '';
  521. if (isInvalidSelector) {
  522. console.log('invalid fadeSlideIn selector');
  523. return false;
  524. }
  525. var animateFadeSlideInDom = document.querySelectorAll(options.selector);
  526. var elementsCount = animateFadeSlideInDom.length;
  527. var elementAnimationCount = 0;
  528. // Count the elements within the starting viewport so we're not exacting
  529. // more effort than required...
  530. //
  531. // We use css visiblity: hidden instead of display: none so the elements
  532. // maintain their DOM flow
  533. var viewportHeight = getViewportHeight();
  534. for (var i = 0; i < elementsCount; i++) {
  535. if (animateFadeSlideInDom[i].offsetTop < viewportHeight) {
  536. elementAnimationCount += 1;
  537. continue;
  538. }
  539. break;
  540. }
  541. // Sequentially animate with a delay based on proximity
  542. var speed = options.startVelocity;
  543. for (var i = 0; i < elementAnimationCount; i++) {
  544. var child = animateFadeSlideInDom[i];
  545. var childOffset = child.getBoundingClientRect();
  546. var offset = childOffset.left * options.leftOffsetPercentage + childOffset.top;
  547. var delay = parseFloat(offset / speed).toFixed(2);
  548. child.style.webkitTransitionDelay = delay + "s";
  549. child.style.transitionDelay = delay + "s";
  550. child.className += ' in';
  551. }
  552. // When we're done animating, switch the class to 'done'
  553. setTimeout(function() {
  554. for (var i = 0; i < elementAnimationCount; i++) {
  555. var child = animateFadeSlideInDom[i];
  556. var childOffset = child.getBoundingClientRect();
  557. var offset = childOffset.left * options.leftOffsetPercentage + childOffset.top;
  558. var delayValue = offset / speed / options.finishDelayThrottle;
  559. var delay = parseFloat(delayValue).toFixed(2);
  560. }
  561. animateFadeSlideInDom[0].className += ' done';
  562. }, speed * options.finishSpeedPercent);
  563. // Load the elements without effect
  564. showNotAnimatedElements(animateFadeSlideInDom, elementsCount);
  565. }
  566. function fadeSlideInRight(options) {
  567. // Declare our defaults
  568. var defaults = {
  569. finishDelayThrottle: 2,
  570. finishSpeedPercent: 0.72,
  571. leftOffsetPercentage: 0.8,
  572. selector: '.animate-fade-slide-in-right .item',
  573. startVelocity: 1100
  574. };
  575. // Apply defaults if properties are not passed
  576. if (typeof options === 'undefined') {
  577. options = {};
  578. }
  579. options.finishDelayThrottle = options.finishDelayThrottle || defaults.finishDelayThrottle;
  580. options.finishSpeedPercent = options.finishSpeedPercent || defaults.finishSpeedPercent;
  581. options.leftOffsetPercentage = options.leftOffsetPercentage || defaults.leftOffsetPercentage;
  582. options.startVelocity = options.startVelocity || defaults.startVelocity;
  583. if (typeof options.selector == 'undefined') {
  584. options.selector = defaults.selector;
  585. }
  586. // Fail early & silently log
  587. var isInvalidSelector = typeof options.selector === 'undefined' || options.selector === '';
  588. if (isInvalidSelector) {
  589. console.log('invalid fadeSlideInRight selector');
  590. return false;
  591. }
  592. var animateSlideInRightDom = document.querySelectorAll(options.selector);
  593. var elementsCount = animateSlideInRightDom.length;
  594. var elementAnimationCount = 0;
  595. // Count the elements within the starting viewport so we're not
  596. // exacting more effort than required...
  597. //
  598. // We use css visiblity: hidden instead of display: none so the
  599. // elements maintain their DOM flow
  600. var viewportHeight = getViewportHeight();
  601. for (var i = 0; i < elementsCount; i++) {
  602. if (animateSlideInRightDom[i].offsetTop < viewportHeight) {
  603. elementAnimationCount += 1;
  604. continue;
  605. }
  606. break;
  607. }
  608. // Sequentially animate with a delay based on proximity
  609. var speed = options.startVelocity;
  610. for (var i = 0; i < elementAnimationCount; i++) {
  611. var child = animateSlideInRightDom[i];
  612. var childOffset = child.getBoundingClientRect();
  613. var offset = childOffset.left * options.leftOffsetPercentage + childOffset.top;
  614. var delay = parseFloat(offset / speed).toFixed(2);
  615. child.style.webkitTransitionDelay = delay + "s";
  616. child.style.transitionDelay = delay + "s";
  617. child.className += ' in';
  618. }
  619. // When we're done animating, switch the class to 'done'
  620. setTimeout(function() {
  621. for (var i = 0; i < elementAnimationCount; i++) {
  622. var child = animateSlideInRightDom[i];
  623. var childOffset = child.getBoundingClientRect();
  624. var offset = childOffset.left * options.leftOffsetPercentage + childOffset.top;
  625. var delayValue = offset / speed / options.finishDelayThrottle;
  626. var delay = parseFloat(delayValue).toFixed(2);
  627. }
  628. animateSlideInRightDom[0].className += ' done';
  629. }, speed * options.finishSpeedPercent);
  630. // Load the elements without effect
  631. showNotAnimatedElements(animateSlideInRightDom, elementsCount);
  632. }
  633. function ripple(options) {
  634. // Declare our defaults
  635. var defaults = {
  636. finishDelayThrottle: 2,
  637. finishSpeedPercent: 0.72,
  638. leftOffsetPercentage: 0.8,
  639. selector: '.animate-ripple .item',
  640. startVelocity: 1100
  641. };
  642. // Apply defaults if properties are not passed
  643. if (typeof options === 'undefined') {
  644. options = {};
  645. }
  646. options.finishDelayThrottle = options.finishDelayThrottle || defaults.finishDelayThrottle;
  647. options.finishSpeedPercent = options.finishSpeedPercent || defaults.finishSpeedPercent;
  648. options.leftOffsetPercentage = options.leftOffsetPercentage || defaults.leftOffsetPercentage;
  649. options.startVelocity = options.startVelocity || defaults.startVelocity;
  650. if (typeof options.selector == 'undefined') {
  651. options.selector = defaults.selector;
  652. }
  653. // Fail early & silently log
  654. var isInvalidSelector = typeof options.selector === 'undefined' || options.selector === '';
  655. if (isInvalidSelector) {
  656. console.log('invalid ripple selector');
  657. return false;
  658. }
  659. var animateRippleDom = document.querySelectorAll(options.selector);
  660. var elementsCount = animateRippleDom.length;
  661. var elementAnimationCount = 0;
  662. // Count the elements within the starting viewport so we're not
  663. // exacting more effort than required...
  664. //
  665. // We use css visiblity: hidden instead of display: none so the
  666. // elements maintain their DOM flow
  667. var viewportHeight = getViewportHeight();
  668. for (var i = 0; i < animateRippleDom.length; i++) {
  669. if (animateRippleDom[i].offsetTop < viewportHeight) {
  670. elementAnimationCount += 1;
  671. continue;
  672. }
  673. break;
  674. }
  675. // Sequentially animate with a delay based on proximity
  676. var speed = options.startVelocity;
  677. for (var i = 0; i < elementAnimationCount; i++) {
  678. var child = animateRippleDom[i];
  679. var childOffset = child.getBoundingClientRect();
  680. var offset = childOffset.left * options.leftOffsetPercentage + childOffset.top;
  681. var delay = parseFloat(offset / speed).toFixed(2);
  682. child.style.webkitTransitionDelay = delay + "s";
  683. child.style.transitionDelay = delay + "s";
  684. child.className += ' in';
  685. }
  686. // When we're done animating, switch the class to 'done'
  687. setTimeout(function() {
  688. for (var i = 0; i < elementAnimationCount; i++) {
  689. var child = animateRippleDom[i];
  690. var childOffset = child.getBoundingClientRect();
  691. var offset = childOffset.left * options.leftOffsetPercentage + childOffset.top;
  692. var delayValue = offset / speed / options.finishDelayThrottle;
  693. var delay = parseFloat(delayValue).toFixed(2);
  694. }
  695. animateRippleDom[0].className += ' done';
  696. }, speed * options.finishSpeedPercent);
  697. // Load the elements without effect
  698. showNotAnimatedElements(animateRippleDom, elementsCount);
  699. }
  700. function panInLeft(options) {
  701. // We have a single option, so it may be passed as a string or property
  702. if (typeof options === 'string') {
  703. options = {
  704. selector: options
  705. };
  706. }
  707. // Fail early & silently log
  708. var isInvalidSelector = typeof options.selector === 'undefined' || options.selector === '';
  709. if (isInvalidSelector) {
  710. console.log('invalid pushDown selector');
  711. return false;
  712. }
  713. var animatePanInLeftDom = document.querySelectorAll(options.selector);
  714. var elementAnimationCount = animatePanInLeftDom.length;
  715. for (var i = 0; i < elementAnimationCount; i++) {
  716. var element = animatePanInLeftDom[i];
  717. var classNameToRemove = 'animate-pan-in-left';
  718. var indexOfClassNameToRemove = element.className.lastIndexOf(classNameToRemove);
  719. element.className = element.className.substr(0, indexOfClassNameToRemove);
  720. }
  721. }
  722. function pushDown(options) {
  723. // We have a single option, so it may be passed as a string or property
  724. if (typeof options === 'string') {
  725. options = {
  726. selector: options
  727. };
  728. }
  729. // Fail early & silently log
  730. var isInvalidSelector = typeof options.selector === 'undefined' || options.selector === '';
  731. if (isInvalidSelector) {
  732. console.log('invalid pushDown selector');
  733. return false;
  734. }
  735. var animatePushDownDom = document.querySelectorAll(options.selector);
  736. var elementAnimationCount = animatePushDownDom.length;
  737. for (var i = 0; i < elementAnimationCount; i++) {
  738. var element = animatePushDownDom[i];
  739. var classNameToRemove = options.selector.split('.')[1];
  740. var indexOfClassNameToRemove = element.className.lastIndexOf(classNameToRemove);
  741. element.className = element.className.substr(0, indexOfClassNameToRemove);
  742. }
  743. }
  744. function slideUp(options) {
  745. // We have a single option, so it may be passed as a string or property
  746. if (typeof options === 'string') {
  747. options = {
  748. selector: options
  749. };
  750. }
  751. // Fail early & silently log
  752. var isInvalidSelector = typeof options.selector === 'undefined' || options.selector === '';
  753. if (isInvalidSelector) {
  754. console.log('invalid pushDown selector');
  755. return false;
  756. }
  757. var animateSlideUpDom = document.querySelectorAll(options.selector);
  758. var elementAnimationCount = animateSlideUpDom.length;
  759. for (var i = 0; i < elementAnimationCount; i++) {
  760. var element = animateSlideUpDom[i];
  761. var classNameToRemove = options.selector.split('.')[1];
  762. var indexOfClassNameToRemove = element.className.lastIndexOf(classNameToRemove);
  763. element.className = element.className.substr(0, indexOfClassNameToRemove);
  764. }
  765. }
  766. /* Export object
  767. /============================================================================*/
  768. return motion;
  769. }
  770. Motion.$inject = [];
  771. };
  772. /***/ }
  773. /******/ ])
  774. });
  775. ;
  776. //# sourceMappingURL=ionic.material.min.js.map