use cloned document for measurements

This fixed a problem I was having in my main project. Looks like you were always referring to window.document which measured the js container instead of the iFrame.