(element, event, options, animations, fnName)
| 1993 | } |
| 1994 | |
| 1995 | function packageAnimations(element, event, options, animations, fnName) { |
| 1996 | var operations = groupEventedAnimations(element, event, options, animations, fnName); |
| 1997 | if (operations.length === 0) { |
| 1998 | var a, b; |
| 1999 | if (fnName === 'beforeSetClass') { |
| 2000 | a = groupEventedAnimations(element, 'removeClass', options, animations, 'beforeRemoveClass'); |
| 2001 | b = groupEventedAnimations(element, 'addClass', options, animations, 'beforeAddClass'); |
| 2002 | } else if (fnName === 'setClass') { |
| 2003 | a = groupEventedAnimations(element, 'removeClass', options, animations, 'removeClass'); |
| 2004 | b = groupEventedAnimations(element, 'addClass', options, animations, 'addClass'); |
| 2005 | } |
| 2006 | |
| 2007 | if (a) { |
| 2008 | operations = operations.concat(a); |
| 2009 | } |
| 2010 | if (b) { |
| 2011 | operations = operations.concat(b); |
| 2012 | } |
| 2013 | } |
| 2014 | |
| 2015 | if (operations.length === 0) return; |
| 2016 | |
| 2017 | // TODO(matsko): add documentation |
| 2018 | return function startAnimation(callback) { |
| 2019 | var runners = []; |
| 2020 | if (operations.length) { |
| 2021 | forEach(operations, function(animateFn) { |
| 2022 | runners.push(animateFn()); |
| 2023 | }); |
| 2024 | } |
| 2025 | |
| 2026 | if (runners.length) { |
| 2027 | $$AnimateRunner.all(runners, callback); |
| 2028 | } else { |
| 2029 | callback(); |
| 2030 | } |
| 2031 | |
| 2032 | return function endFn(reject) { |
| 2033 | forEach(runners, function(runner) { |
| 2034 | if (reject) { |
| 2035 | runner.cancel(); |
| 2036 | } else { |
| 2037 | runner.end(); |
| 2038 | } |
| 2039 | }); |
| 2040 | }; |
| 2041 | }; |
| 2042 | } |
| 2043 | }; |
| 2044 | |
| 2045 | function lookupAnimations(classes) { |
no test coverage detected