* @param {string} path='' * @param {Object} source=animatable * @param {Object} target * @param {number} [time=500] * @param {number} [delay=0] * @param {boolean} [reverse] If `true`, animate * from the `target` to current state. * * @example * // Animate position * el._animateToS
(animatable, path, source, target, time, delay, reverse)
| 4996 | * }, 100, 100) |
| 4997 | */ |
| 4998 | function animateToShallow(animatable, path, source, target, time, delay, reverse) { |
| 4999 | var objShallow = {}; |
| 5000 | var propertyCount = 0; |
| 5001 | for (var name in target) { |
| 5002 | if (!target.hasOwnProperty(name)) { |
| 5003 | continue; |
| 5004 | } |
| 5005 | |
| 5006 | if (source[name] != null) { |
| 5007 | if (isObject$1(target[name]) && !isArrayLike(target[name])) { |
| 5008 | animateToShallow( |
| 5009 | animatable, |
| 5010 | path ? path + '.' + name : name, |
| 5011 | source[name], |
| 5012 | target[name], |
| 5013 | time, |
| 5014 | delay, |
| 5015 | reverse |
| 5016 | ); |
| 5017 | } |
| 5018 | else { |
| 5019 | if (reverse) { |
| 5020 | objShallow[name] = source[name]; |
| 5021 | setAttrByPath(animatable, path, name, target[name]); |
| 5022 | } |
| 5023 | else { |
| 5024 | objShallow[name] = target[name]; |
| 5025 | } |
| 5026 | propertyCount++; |
| 5027 | } |
| 5028 | } |
| 5029 | else if (target[name] != null && !reverse) { |
| 5030 | setAttrByPath(animatable, path, name, target[name]); |
| 5031 | } |
| 5032 | } |
| 5033 | |
| 5034 | if (propertyCount > 0) { |
| 5035 | animatable.animate(path, false) |
| 5036 | .when(time == null ? 500 : time, objShallow) |
| 5037 | .delay(delay || 0); |
| 5038 | } |
| 5039 | } |
| 5040 | |
| 5041 | function setAttrByPath(el, path, name, value) { |
| 5042 | // Attr directly if not has property |
no test coverage detected