From aba0578a3ec00d073c4fdcce0b5b13af8ad3d48b Mon Sep 17 00:00:00 2001 From: thawk Date: Sat, 18 Sep 2021 16:23:36 +0800 Subject: [PATCH] make data-rel-reset="all" ignore the rotation of previous slide --- js/impress.js | 2 +- src/plugins/rel/rel.js | 2 +- test/plugins/rel/padding_tests.js | 9 +++++++++ test/plugins/rel/padding_tests_presentation.html | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/js/impress.js b/js/impress.js index 3e6dee5a1..6341439de 100644 --- a/js/impress.js +++ b/js/impress.js @@ -4205,7 +4205,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( diff --git a/src/plugins/rel/rel.js b/src/plugins/rel/rel.js index d8d49de33..a9877ab76 100644 --- a/src/plugins/rel/rel.js +++ b/src/plugins/rel/rel.js @@ -184,7 +184,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( diff --git a/test/plugins/rel/padding_tests.js b/test/plugins/rel/padding_tests.js index 5c893a50d..c02eb5f7c 100644 --- a/test/plugins/rel/padding_tests.js +++ b/test/plugins/rel/padding_tests.js @@ -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" ); @@ -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)" ); } ) diff --git a/test/plugins/rel/padding_tests_presentation.html b/test/plugins/rel/padding_tests_presentation.html index 10f39f554..6bcb4243e 100644 --- a/test/plugins/rel/padding_tests_presentation.html +++ b/test/plugins/rel/padding_tests_presentation.html @@ -52,6 +52,10 @@
+
+ by data prel-reset="all", paddings should be calculated as if data-rotate-*=0 +
+