diff --git a/css/components/_pretext.scss b/css/components/_pretext.scss
index 45b9b4274a..7ef08d698c 100644
--- a/css/components/_pretext.scss
+++ b/css/components/_pretext.scss
@@ -28,6 +28,7 @@ $navbar-breakpoint: 800px !default;
@use 'google-search';
@use 'pretext-search';
@use 'interactives/runestone';
+@use 'interactives/other';
@use 'interactives/webwork';
@use 'interactives/sagecell';
diff --git a/css/components/interactives/_other.scss b/css/components/interactives/_other.scss
new file mode 100644
index 0000000000..a21373545d
--- /dev/null
+++ b/css/components/interactives/_other.scss
@@ -0,0 +1,34 @@
+.interactive-iframe-container {
+ max-width: 100%;
+ overflow: auto;
+ & > iframe {
+ margin-left: auto;
+ margin-right: auto;
+ display: block;
+ }
+}
+
+.interactive-iframe-container__opener {
+ display: block;
+ margin-right: 5px;
+ margin-top: 11px;
+ margin-bottom: 5px;
+ font-size: 0.8rem;
+ & .icon {
+ font-size: 18px;
+ }
+
+ // if figcaption or instructions follow, this should float next to that
+ &:has(+ figcaption, + .instructions) {
+ float: left;
+ z-index: 1; // place above fig caption in render stack
+ position: relative; // for z-index
+ }
+
+ // and if both, the figcaption should clear
+ + .instructions + figcaption {
+ clear: left;
+ }
+
+ + .instructions { margin-top: .5em; }
+}
diff --git a/doc/guide/publisher/publication-file.xml b/doc/guide/publisher/publication-file.xml
index ee8fd11d55..4f94d7c6ce 100644
--- a/doc/guide/publisher/publication-file.xml
+++ b/doc/guide/publisher/publication-file.xml
@@ -905,6 +905,48 @@
yes: show a button in the navigation bar, that when clicked, displays a popup allowing the user to copy an iframe code snippet to paste into their website or LMS.
+
+
+ Interactives Options
+ publisher optionshtml interactives
+
+
+ The
+
+ /publication/html
+
+ element can have an attribute design-width with an integer value. This will be used as the base value for converting the percentage based widths of an interactive into a pixel values when that is required. The default value is 600 (100% width is 600px).
+
+
+
+ The
+
+ /publication/html/interactives
+
+ element can have an attribute resize-behavior that is used to control how interactives respond to window resizing. Possible values are:
+
+ - fixed-height (default): interactives will maintain their initial height as the window size changes. When the content becomes too wide to display, a horizontal scrollbar will appear.
+ - responsive: interactives will resize dynamically as the window size changes to maintain their aspect ratio.
+
+ In addition to this global setting, you can add child elemements to
+
+ /publication/html/interactives
+
+ to set the resize behavior for specific types of interactives. Each child element should be named after the interactive type (e.g. geogebra or desmos) and have a resize-behavior attribute with the same possible values as above. Settings on these child elements will override the global setting for that specific interactive type. Known interactive types that can be specified this way are:
+
+ - calcplot3d
+ - circuitjs
+ - d3
+ - desmos
+ - doenetml
+ - geogebra
+ - iframe
+ - javascript
+ - jsxgraph
+ - sage
+
+
+
diff --git a/examples/sample-article/media/code/d3/collision.js b/examples/sample-article/media/code/d3/collision.js
index b82593ec81..8e7d38fcd8 100644
--- a/examples/sample-article/media/code/d3/collision.js
+++ b/examples/sample-article/media/code/d3/collision.js
@@ -21,7 +21,8 @@ force.start();
var svg = d3.select("#d3-collision").append("svg")
.attr("width", width)
- .attr("height", height);
+ .attr("height", height)
+ .attr("display", "block");
svg.selectAll("circle")
.data(nodes.slice(1))
diff --git a/examples/sample-article/media/code/d3/graph-layout.js b/examples/sample-article/media/code/d3/graph-layout.js
index 453bf1d8de..b572ea6743 100644
--- a/examples/sample-article/media/code/d3/graph-layout.js
+++ b/examples/sample-article/media/code/d3/graph-layout.js
@@ -14,19 +14,24 @@
main()
function main() {
- var range = 50
+ setSize(data)
+
+ // Add more data when we have a larger canvas
+ var range = Math.pow(width, 1.3) / 50
var data = {
nodes:d3.range(0, range).map(function(d){ return {label: "l"+d ,r:~~d3.randomUniform(4, 16)()}}),
links:d3.range(0, range).map(function(){ return {source:~~d3.randomUniform(range)(), target:~~d3.randomUniform(range)()} })
}
- setSize(data)
drawChart(data)
}
function setSize(data) {
- width = document.querySelector("#d3-graph-layout").clientWidth
- height = document.querySelector("#d3-graph-layout").clientHeight
+ // boundingRect provides true decimal values for dimensions.
+ // clientWidth/clientHeight are integer values that may have been rounded up
+ let boundingRect = document.querySelector("#d3-graph-layout").getBoundingClientRect()
+ width = Math.floor(boundingRect.width)
+ height = Math.floor(boundingRect.height)
margin = {top:0, left:0, bottom:0, right:0 }
@@ -34,7 +39,7 @@
chartWidth = width - (margin.left+margin.right)
chartHeight = height - (margin.top+margin.bottom)
- svg.attr("width", width).attr("height", height)
+ svg.attr("width", width).attr("height", height).attr("display", "block")
chartLayer
diff --git a/examples/sample-article/media/code/mcclure/slope.css b/examples/sample-article/media/code/mcclure/slope.css
index 999ff001d3..f4ff41a81b 100644
--- a/examples/sample-article/media/code/mcclure/slope.css
+++ b/examples/sample-article/media/code/mcclure/slope.css
@@ -36,7 +36,8 @@ h1 {
svg {
background: white;
border: 1px solid darkslategray;
- margin: 20px;
+ margin-top: 20px;
+ margin-bottom: 20px;
}
.function_radio_container {
diff --git a/examples/sample-article/media/code/mcclure/slope.js b/examples/sample-article/media/code/mcclure/slope.js
index d859bfd88d..119ae4d51c 100644
--- a/examples/sample-article/media/code/mcclure/slope.js
+++ b/examples/sample-article/media/code/mcclure/slope.js
@@ -4,7 +4,7 @@
var body_width = 600;
$("body").css("width", body_width);
-var svg_width = 580, svg_height = 400, graph_padding = 20;
+var svg_width = 600, svg_height = 400, graph_padding = 20;
$("#the_graph").css("margin-left", (body_width-svg_width)/2);
var svg = d3.select("#the_graph")
.attr("width", svg_width)
diff --git a/examples/sample-article/media/code/splice/splice-resize.js b/examples/sample-article/media/code/splice/splice-resize.js
new file mode 100644
index 0000000000..1cab4ce578
--- /dev/null
+++ b/examples/sample-article/media/code/splice/splice-resize.js
@@ -0,0 +1,19 @@
+const bodyEl = document.body;
+bodyEl.style.background = 'red';
+
+const growBtn = document.createElement('button');
+growBtn.textContent = 'Grow';
+document.currentScript.parentElement.appendChild(growBtn);
+
+growBtn.addEventListener('click', () => {
+ const currentHeight = bodyEl.clientHeight;
+ const newHeight = currentHeight + 100;
+ bodyEl.style.height = `${newHeight}px`;
+ window.parent.postMessage(
+ {
+ subject: 'lti.frameResize',
+ height: newHeight,
+ },
+ '*'
+ )
+});
\ No newline at end of file
diff --git a/examples/sample-article/media/code/threejs/catenoid.js b/examples/sample-article/media/code/threejs/catenoid.js
index 81680d0c3e..2e22c45b16 100644
--- a/examples/sample-article/media/code/threejs/catenoid.js
+++ b/examples/sample-article/media/code/threejs/catenoid.js
@@ -1,7 +1,7 @@
var scene = new THREE.Scene();
var renderer = new THREE.WebGLRenderer( { antialias: true } );
- renderer.setSize( window.innerWidth, window.innerHeight );
+ renderer.setSize( window.innerWidth, window.innerHeight - 5 );
renderer.setClearColor( 0xfff000, 1 );
// RAB edit 2021-08-10
// document.body.appendChild( renderer.domElement );
diff --git a/examples/sample-article/media/code/threejs/saddle.js b/examples/sample-article/media/code/threejs/saddle.js
index d26f44b2ee..aebd5c41e8 100644
--- a/examples/sample-article/media/code/threejs/saddle.js
+++ b/examples/sample-article/media/code/threejs/saddle.js
@@ -14,6 +14,7 @@
// document.body.appendChild( renderer.domElement );
var renderDiv = document.getElementById("threejs-saddle");
renderDiv.appendChild( renderer.domElement );
+ renderer.domElement.style.display = 'block'; // Prevents scroll bars
var b = [{"x":-1.0, "y":-1.0, "z":-0.9993425378040762}, {"x":1.0, "y":1.0, "z":0.9993425378040762}]; // bounds
diff --git a/examples/sample-article/publication.xml b/examples/sample-article/publication.xml
index 454d6f9469..e59d447eab 100644
--- a/examples/sample-article/publication.xml
+++ b/examples/sample-article/publication.xml
@@ -152,6 +152,13 @@ along with PreTeXt. If not, see .
+
+
+
+
+
+
+