After Effects template that allows you to intuitively create collage like grid animations.
Functionality Overview
Automatic reposition and resize
Frames center and scale to fill in the available space in the best way. Functions like the "cover" option in CSS.
Composition Viewer
Source Footage
Project
"Cover" behaviour from CSS in After Effects
Parent a footage layer to a Shape layer rectangle and add the following expresssion on the position and scale attribute
Position
-- CODE language-js --
[parent.content("Rectangle: 1").size[0]/2,parent.content("Rectangle: 1").size[1]/2]
Scale
-- CODE language-js --
pRectX= parent.sourceRectAtTime(time,true).width;
pRectY= parent.sourceRectAtTime(time,true).height;
lRectX= thisLayer.sourceRectAtTime(time,true).width;
lRectY= thisLayer.sourceRectAtTime(time,true).height;
aR= thisLayer.width/thisLayer.height;
if(pRectX/pRectY>=aR) {
[pRectX/lRectX,pRectX/lRectX]*100
} else {
[pRectY/lRectY,pRectY/lRectY]*100
}