We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The findParentRatio function:
function findParentRatio(jqObject) { var p = jqObject.parent(), displayType = p.css('display'); if (displayType == 'block' || displayType == '-webkit-box' && p.width() > 0) { return { obj: p, width: p.width(), height: p.height(), ratio: (p.width() / p.height()) }; } else { return findParentRatio(p); } }
can cause infinite recursion (e.g. when the element is not in the DOM yet).
I suggest something like:
function findParentRatio(jqObject) { var p = jqObject.parent(), displayType = p.css('display'); if (!p) { return a default or throw error here. } if (displayType == 'block' || displayType == '-webkit-box' && p.width() > 0) { return { obj: p, width: p.width(), height: p.height(), ratio: (p.width() / p.height()) }; } else { return findParentRatio(p); } }
Also, this approach doesn't mesh well with some MVC frameworks (like Backbone), where views are rendered before they're added to the DOM.
Can't think of another way to do it at the moment though :(
The text was updated successfully, but these errors were encountered:
fixes issue schmidsi#3
65f1055
Checks if the object is in the dom to avoid an infinite loop. Checks if the parent exists. If not, the ratio is not applied
No branches or pull requests
The findParentRatio function:
can cause infinite recursion (e.g. when the element is not in the DOM yet).
I suggest something like:
Also, this approach doesn't mesh well with some MVC frameworks (like Backbone),
where views are rendered before they're added to the DOM.
Can't think of another way to do it at the moment though :(
The text was updated successfully, but these errors were encountered: