Skip to content
Snippets Groups Projects
Commit 51de6545 authored by smmercuri's avatar smmercuri
Browse files

correct inner width and height calcs

parent fbfb98c3
No related branches found
No related tags found
No related merge requests found
...@@ -121,17 +121,15 @@ class stack_cas_castext2_jsxgraph extends stack_cas_castext2_block { ...@@ -121,17 +121,15 @@ class stack_cas_castext2_jsxgraph extends stack_cas_castext2_block {
$height = $xpars['height']; $height = $xpars['height'];
} }
$innerwidth = substr($width, -1) === 'px' ? "$width - 3px" : "100% - 3px"; $astyle = "width:calc(100% - 3px);height:calc(100% - 3px);";
$innerheight = substr($width, -1) === 'px' ? "$height - 3px" : "100% - 3px";
$astyle = "width:calc($innerwidth);height:calc($innerheight);";
if (array_key_exists('aspect-ratio', $xpars)) { if (array_key_exists('aspect-ratio', $xpars)) {
$aspectratio = $xpars['aspect-ratio']; $aspectratio = $xpars['aspect-ratio'];
// Unset the undefined dimension, if both are defined then we have a problem. // Unset the undefined dimension, if both are defined then we have a problem.
if (array_key_exists('height', $xpars)) { if (array_key_exists('height', $xpars)) {
$astyle = "height:calc($innerheight);aspect-ratio:$aspectratio;"; $astyle = "height:calc($100% - 3px);aspect-ratio:$aspectratio;";
} else if (array_key_exists('width', $xpars)) { } else if (array_key_exists('width', $xpars)) {
$astyle = "width:calc($innerwidth);aspect-ratio:$aspectratio;"; $astyle = "width:calc(100% - 3px);aspect-ratio:$aspectratio;";
} }
} }
......
...@@ -115,17 +115,14 @@ class stack_cas_castext2_parsons extends stack_cas_castext2_block { ...@@ -115,17 +115,14 @@ class stack_cas_castext2_parsons extends stack_cas_castext2_block {
// We need to define a size for the inner content. // We need to define a size for the inner content.
$aspectratio = false; $aspectratio = false;
$innerwidth = substr($width, -1) === 'px' ? "$width - 3px" : "100% - 3px"; $astyle = "width:calc(100% - 3px);height:calc(100% - 3px);";
$innerheight = substr($width, -1) === 'px' ? "$height - 3px" : "100% - 3px";
$astyle = "width:calc($innerwidth);height:calc($innerheight);";
if (array_key_exists('aspect-ratio', $xpars)) { if (array_key_exists('aspect-ratio', $xpars)) {
$aspectratio = $xpars['aspect-ratio']; $aspectratio = $xpars['aspect-ratio'];
// Unset the undefined dimension, if both are defined then we have a problem. // Unset the undefined dimension, if both are defined then we have a problem.
if (array_key_exists('height', $xpars)) { if (array_key_exists('height', $xpars)) {
$astyle = "height:calc($innerheight);aspect-ratio:$aspectratio;"; $astyle = "height:calc(100% - 3px);aspect-ratio:$aspectratio;";
} else if (array_key_exists('width', $xpars)) { } else if (array_key_exists('width', $xpars)) {
$astyle = "width:calc($innerwidth);aspect-ratio:$aspectratio;"; $astyle = "width:calc(100% - 3px);aspect-ratio:$aspectratio;";
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment