Skip to content

Commit

Permalink
make data-rel-reset="all" ignore the rotation of previous slide
Browse files Browse the repository at this point in the history
  • Loading branch information
thawk committed Mar 19, 2022
1 parent d114736 commit 3bbda65
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/impress.js
Original file line number Diff line number Diff line change
Expand Up @@ -4214,7 +4214,7 @@
// The final relatives maybe or maybe not the same with orignal data-rel-*
var relative = step.relative;

if ( step.relative.position === "relative" ) {
if ( step.relative.position === "relative" && inheritRotation ) {

// Calculate relatives based on previous slide
relative = api.lib.rotation.translateRelative(
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/rel/rel.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
// The final relatives maybe or maybe not the same with orignal data-rel-*
var relative = step.relative;

if ( step.relative.position === "relative" ) {
if ( step.relative.position === "relative" && inheritRotation ) {

// Calculate relatives based on previous slide
relative = api.lib.rotation.translateRelative(
Expand Down
9 changes: 9 additions & 0 deletions test/plugins/rel/padding_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ QUnit.test( "padding_relative", function( assert ) {
var z_y = iframeDoc.querySelector( "div#z_y" );
var z_z = iframeDoc.querySelector( "div#z_z" );

var reset = iframeDoc.querySelector( "div#reset" );

assert.close( origin.dataset.x, 0, 1, "origin data-x attribute" );
assert.close( origin.dataset.y, 0, 1, "origin data-y attribute" );
assert.close( origin.dataset.z, 0, 1, "origin data-z attribute" );
Expand Down Expand Up @@ -143,6 +145,13 @@ QUnit.test( "padding_relative", function( assert ) {
assert.close( z_z.dataset.rotateY, 0, 1, "z_z data-rotate-y" );
assert.close( z_z.dataset.rotateZ, 90, 1, "z_z data-rotate-z" );

assert.close( reset.dataset.x, 100, 1, "reset data-x attribute" );
assert.close( reset.dataset.y, 200, 1, "reset data-y attribute" );
assert.close( reset.dataset.z, 800, 1, "reset data-z attribute" );
assert.close( reset.dataset.rotateX, 0, 1, "reset data-rotate-x" );
assert.close( reset.dataset.rotateY, 0, 1, "reset data-rotate-y" );
assert.close( reset.dataset.rotateZ, 0, 1, "reset data-rotate-z" );

done();
console.log( "End padding test (sync)" );
} )
Expand Down
4 changes: 4 additions & 0 deletions test/plugins/rel/padding_tests_presentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<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>

Expand Down

0 comments on commit 3bbda65

Please sign in to comment.