(element, event, options, animations, fnName)
| 2015 | } |
| 2016 | |
| 2017 | function packageAnimations(element, event, options, animations, fnName) { |
| 2018 | var operations = groupEventedAnimations(element, event, options, animations, fnName); |
| 2019 | if (operations.length === 0) { |
| 2020 | var a, b; |
| 2021 | if (fnName === 'beforeSetClass') { |
| 2022 | a = groupEventedAnimations(element, 'removeClass', options, animations, 'beforeRemoveClass'); |
| 2023 | b = groupEventedAnimations(element, 'addClass', options, animations, 'beforeAddClass'); |
| 2024 | } else if (fnName === 'setClass') { |
| 2025 | a = groupEventedAnimations(element, 'removeClass', options, animations, 'removeClass'); |
| 2026 | b = groupEventedAnimations(element, 'addClass', options, animations, 'addClass'); |
| 2027 | } |
| 2028 | |
| 2029 | if (a) { |
| 2030 | operations = operations.concat(a); |
| 2031 | } |
| 2032 | if (b) { |
| 2033 | operations = operations.concat(b); |
| 2034 | } |
| 2035 | } |
| 2036 | |
| 2037 | if (operations.length === 0) return; |
| 2038 | |
| 2039 | // TODO(matsko): add documentation |
| 2040 | return function startAnimation(callback) { |
| 2041 | var runners = []; |
| 2042 | if (operations.length) { |
| 2043 | forEach(operations, function(animateFn) { |
| 2044 | runners.push(animateFn()); |
| 2045 | }); |
| 2046 | } |
| 2047 | |
| 2048 | if (runners.length) { |
| 2049 | $$AnimateRunner.all(runners, callback); |
| 2050 | } else { |
| 2051 | callback(); |
| 2052 | } |
| 2053 | |
| 2054 | return function endFn(reject) { |
| 2055 | forEach(runners, function(runner) { |
| 2056 | if (reject) { |
| 2057 | runner.cancel(); |
| 2058 | } else { |
| 2059 | runner.end(); |
| 2060 | } |
| 2061 | }); |
| 2062 | }; |
| 2063 | }; |
| 2064 | } |
| 2065 | }; |
| 2066 | |
| 2067 | function lookupAnimations(classes) { |
no test coverage detected