Skip to content

Instantly share code, notes, and snippets.

@hilukasz
Created June 7, 2012 01:10
Show Gist options
  • Save hilukasz/2885881 to your computer and use it in GitHub Desktop.
Save hilukasz/2885881 to your computer and use it in GitHub Desktop.
function SymbolContainer(theSymbol){
this.child = null; // reference to single child container
this.symbolItems = null; //array of symbols
this.parent = null;
}
SymbolContainer.prototype.checkIfChild = function(containerToCheckIfChild) {
this.parent = [];
var childVB = containerToCheckIfChild.visibleBounds,
childLeft = childVB[0],
childTop = Math.abs(childVB[1]),
childRight = childVB[2],
childBottom = Math.abs(childVB[3]);
var parentVB = this.parent.visibleBounds,
parentLeft = parentVB[0],
parentTop = Math.abs(parentVB[1]),
parentRight = parentVB[2],
parentBottom = Math.abs(parentVB[3]);
if(childLeft >= parentLeft && childTop >= parentTop && childRight <= parentRight && childBottom <= parentBottom){
this.parent = containerToCheckIfSmaller;
}
}
var containerToCheckIfChild = doc.pageItems[0];
var mySymbolContainer = new SymbolContainer();
mySymbolContainer.checkIfChild(containerToCheckIfChild);
$.writeln(mySymbolContainer.parent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment