Files
impress.js/test/plugins/rel/padding_tests_presentation.html
thawk 629f7686f3 Add relative move and rotate to rel plugin (#794)
The relative position in rel plugin is currently based on the world coordinate. So for the same effect, like fly in from the right-hand side, we must use different `data-rel-x/y/z` value. Why not let the plugin do the hard part?

So I introduce a `data-rel-position`, when set to `relative`, all relative attribute is based on the position and rotation of previous slide. So no matter the rotation of previous slide, data-rel-x="1000" always looks like fly in from the right-hand side. We can change the position and rotation of one slide, and the position of all following slides will be changed too.

When `data-rel-position` is set to `relative`, relative rotation has a clear meaning. It describes the relative rotations between slides. We don't need to set rotations for all slide, setting the key slides is enough. If `data-rel-position` is not relative, the effect of `data-rel-rotate-x/y/z` is not clear, so they're only used when `data-rel-position="relative"`.

After the introduction of relative rotation, there're 6 attribute that will inherit from previous slide. If we want to set a relative X move, we have to set all other 5 attributes to 0. It's boring. So a `data-rel-clear` is used to set all 6 attributes to 0, and then the value specified in current slide is applied. 

The `examples/3D-positions/index.html` shows some usage. As you can see, the html code of two slide ring is the same, and slides except for the first two in a ring has no position attributes. It work by inheriting the previous one.

This PR invokes a lot math calculations. Basically, the rotation of a slide is translated into the coordinate describing the directions of X/Y/Z axes. And `data-rel-x/y/z` can be easily calculated by that. The rotations is the hard part, I mainly use the algorithm in the Quaternions and spatial rotation - Wikipedia to compose two and more rotations.  I'm not a math guy, hope I don't make much mistakes.
2022-04-24 21:37:50 +03:00

68 lines
2.7 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>The presentation steps used in an iframe in rel/padding_tests.js</title>
<style type="text/css" media="screen">
.step {
position: relative;
width: 500px;
height: 500px;
padding: 40px 60px;
margin: 20px auto;
box-sizing: border-box;
line-height: 1.5;
background-color: yellow;
border-radius: 10px;
box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
text-shadow: 0 2px 2px rgba(0, 0, 0, .1);
font-family: 'Open Sans', Arial, sans-serif;
font-size: 40pt;
letter-spacing: -1px;
border: solid 1px red;
opacity: 50%;
}
</style>
</head>
<body class="impress-not-supported">
<div id="impress">
<div id="origin" class="step" data-rel-position="relative" data-x="0" data-y="0" data-z="0"></div>
<div id="origin_x" class="step" data-rel-to="origin" data-rel-reset data-rel-x="500"></div>
<div id="origin_y" class="step" data-rel-to="origin" data-rel-reset data-rel-y="500"></div>
<div id="origin_z" class="step" data-rel-to="origin" data-rel-reset data-rel-z="500"></div>
<div id="x" class="step" data-rel-reset="all" data-x="0" data-y="0" data-z="0" data-rotate-x="90"></div>
<div id="x_x" class="step" data-rel-reset data-rel-to="x" data-rel-x="500"></div>
<div id="x_y" class="step" data-rel-reset data-rel-to="x" data-rel-y="500"></div>
<div id="x_z" class="step" data-rel-reset data-rel-to="x" data-rel-z="500"></div>
<div id="y" class="step" data-rel-reset="all" data-x="0" data-y="0" data-z="0" data-rotate-y="90"></div>
<div id="y_x" class="step" data-rel-reset data-rel-to="y" data-rel-x="500"></div>
<div id="y_y" class="step" data-rel-reset data-rel-to="y" data-rel-y="500"></div>
<div id="y_z" class="step" data-rel-reset data-rel-to="y" data-rel-z="500"></div>
<div id="z" class="step" data-rel-reset="all" data-x="0" data-y="0" data-z="0" data-rotate-z="90"></div>
<div id="z_x" class="step" data-rel-reset data-rel-to="z" data-rel-x="500"></div>
<div id="z_y" class="step" data-rel-reset data-rel-to="z" data-rel-y="500"></div>
<div id="z_z" class="step" data-rel-reset data-rel-to="z" data-rel-z="500"></div>
<div id="reset" class="step" data-rel-reset="all" data-rel-x="100" data-rel-y="200" data-rel-z="300">
by data prel-reset="all", paddings should be calculated as if data-rotate-*=0
</div>
<div id="overview" class="step overview" data-x="0" data-y="-1000" data-z="100" data-scale="4" data-rotate-x="45">
</div>
</div>
<script src="../../../js/impress.js"></script>
<!-- <script>impress().init();</script> -->
</body>
<html>