diff --git a/layoutAnimationShim/src/layout-animation.js b/layoutAnimationShim/src/layout-animation.js index 64d7694..8d2bc56 100644 --- a/layoutAnimationShim/src/layout-animation.js +++ b/layoutAnimationShim/src/layout-animation.js @@ -15,7 +15,6 @@ * limitations under the License. */ var LOCATE_FOUC = false; - /** * Returns a transform value (translation in X and Y plus scale in X and Y) that * converts a rectangle at current (left, top, width, height) with origin at @@ -80,6 +79,7 @@ function animationToPositionLayout(target, from, positions, duration) { return { offset: position.offset, value: str}; }); + var mkPosList = function(property, list) { return list.map(function(input) { contentRect = boundingRectToContentRect(target, input); @@ -613,7 +613,7 @@ function sensePosition(target) { var parent = target.parentElement; while (parent) { var style = getComputedStyle(parent); - if (style.position == 'absolute' || style.position == 'relative') { + if (style.position == 'absolute' || style.position == 'relative' || parent._layout) { break; } parent = parent.parentElement; @@ -725,6 +725,17 @@ function positionListFromKeyframes(keyframes, element) { } } + // Re-apply parent offsets so that these coordinates are absolute. + if (element._transitionParent) { + var parentList = element._transitionParent._transitionPositionList; + for (var i = 0; i < parentList.length; i++) { + // TODO: deal with mismatched offsets + console.assert(parentList[i].offset == positions[i].offset); + positions[i].left += parentList[i].left; + positions[i].top += parentList[i].top; + } + } + return positions; } @@ -764,7 +775,10 @@ function transitionThis(action) { list[i]._transitionPositionList = []; for (var j = 0; j < positionList.length; j++) { - list[i]._transitionPositionList.push({left: positionList[j].left, top: positionList[j].top}); + list[i]._transitionPositionList.push({ + left: positionList[j].left, + top: positionList[j].top, + offset: positionList[j].offset}); } parGroup.append(generateAnimation(list[i], positionList)); diff --git a/layoutAnimationShim/tests/test-nested-effects-2.html b/layoutAnimationShim/tests/test-nested-effects-2.html new file mode 100644 index 0000000..56d87d5 --- /dev/null +++ b/layoutAnimationShim/tests/test-nested-effects-2.html @@ -0,0 +1,78 @@ + + +