Fixes to data-rel-to

Fixes 80ffff0e8f
This commit is contained in:
Henrik Ingo
2018-05-08 20:01:11 +03:00
parent 67079504b5
commit 194ae3bb62
4 changed files with 16 additions and 15 deletions

View File

@@ -101,7 +101,7 @@
powerpoint slide show. The "slide" class is entirely optional and indeed you wouldn't use it for powerpoint slide show. The "slide" class is entirely optional and indeed you wouldn't use it for
your cooler impress.js presentations. your cooler impress.js presentations.
--> -->
<div class="step slide title" data-x="-1000" data-y="-1500"> <div id="title" class="step slide title" data-x="-1000" data-y="-1500">
<h1>Example Presentation: <br /> <h1>Example Presentation: <br />
Classic Slides</h1> Classic Slides</h1>
<h2>Henrik Ingo</h2> <h2>Henrik Ingo</h2>
@@ -114,7 +114,7 @@
</div> </div>
</div> </div>
<div class="step slide" data-rel-x="1000" data-rel-y="0"> <div id="toc" class="step slide" data-rel-x="1000" data-rel-y="0">
<h1>Table of Contents</h1> <h1>Table of Contents</h1>
<ul> <ul>
<li><a href="#step-1">A title slide</a></li> <li><a href="#step-1">A title slide</a></li>
@@ -151,7 +151,7 @@
</div> </div>
</div> </div>
<div class="step slide"> <div class="step slide" data-rel-to="title" data-y="2000">
<h1>Bullet points</h1> <h1>Bullet points</h1>
<ul> <ul>
<li>A slide with bullet points. This is the first point.</li> <li>A slide with bullet points. This is the first point.</li>

View File

@@ -6,6 +6,7 @@
<ul><br /> <ul><br />
<li><a href="2D-navigation/">2D-navigation</a></li> <li><a href="2D-navigation/">2D-navigation</a></li>
<li><a href="3D-rotations/">3D-rotations</a></li> <li><a href="3D-rotations/">3D-rotations</a></li>
<li><a href="692/">692</a></li>
<li><a href="classic-slides/">classic-slides</a></li> <li><a href="classic-slides/">classic-slides</a></li>
<li><a href="cube/">cube</a></li> <li><a href="cube/">cube</a></li>
<li><a href="markdown/">markdown</a></li> <li><a href="markdown/">markdown</a></li>

View File

@@ -3566,7 +3566,7 @@
} }
}; };
var computeRelativePositions = function( el, prev, root ) { var computeRelativePositions = function( el, prev ) {
var data = el.dataset; var data = el.dataset;
if ( !prev ) { if ( !prev ) {
@@ -3577,14 +3577,14 @@
if ( data.relTo ) { if ( data.relTo ) {
var ref = root.getElementById( data.relTo ); var ref = document.getElementById( data.relTo );
if ( ref ) { if ( ref ) {
// Test, if it is a previous step that already has some assigned position data // Test, if it is a previous step that already has some assigned position data
if ( el.compareDocumentPosition( ref ) & Node.DOCUMENT_POSITION_PRECEDING ) { if ( el.compareDocumentPosition( ref ) & Node.DOCUMENT_POSITION_PRECEDING ) {
prev.x = ref.getAttribute( "data-x" ); prev.x = toNumber( ref.getAttribute( "data-x" ) );
prev.y = ref.getAttribute( "data-y" ); prev.y = toNumber( ref.getAttribute( "data-y" ) );
prev.z = ref.getAttribute( "data-z" ); prev.z = toNumber( ref.getAttribute( "data-z" ) );
prev.relative = {}; prev.relative = {};
} else { } else {
window.console.error( window.console.error(
@@ -3650,7 +3650,7 @@
y: el.getAttribute( "data-y" ), y: el.getAttribute( "data-y" ),
z: el.getAttribute( "data-z" ) z: el.getAttribute( "data-z" )
} ); } );
var step = computeRelativePositions( el, prev, root ); var step = computeRelativePositions( el, prev );
// Apply relative position (if non-zero) // Apply relative position (if non-zero)
el.setAttribute( "data-x", step.x ); el.setAttribute( "data-x", step.x );

View File

@@ -77,7 +77,7 @@
} }
}; };
var computeRelativePositions = function( el, prev, root ) { var computeRelativePositions = function( el, prev ) {
var data = el.dataset; var data = el.dataset;
if ( !prev ) { if ( !prev ) {
@@ -88,14 +88,14 @@
if ( data.relTo ) { if ( data.relTo ) {
var ref = root.getElementById( data.relTo ); var ref = document.getElementById( data.relTo );
if ( ref ) { if ( ref ) {
// Test, if it is a previous step that already has some assigned position data // Test, if it is a previous step that already has some assigned position data
if ( el.compareDocumentPosition( ref ) & Node.DOCUMENT_POSITION_PRECEDING ) { if ( el.compareDocumentPosition( ref ) & Node.DOCUMENT_POSITION_PRECEDING ) {
prev.x = ref.getAttribute( "data-x" ); prev.x = toNumber( ref.getAttribute( "data-x" ) );
prev.y = ref.getAttribute( "data-y" ); prev.y = toNumber( ref.getAttribute( "data-y" ) );
prev.z = ref.getAttribute( "data-z" ); prev.z = toNumber( ref.getAttribute( "data-z" ) );
prev.relative = {}; prev.relative = {};
} else { } else {
window.console.error( window.console.error(
@@ -161,7 +161,7 @@
y: el.getAttribute( "data-y" ), y: el.getAttribute( "data-y" ),
z: el.getAttribute( "data-z" ) z: el.getAttribute( "data-z" )
} ); } );
var step = computeRelativePositions( el, prev, root ); var step = computeRelativePositions( el, prev );
// Apply relative position (if non-zero) // Apply relative position (if non-zero)
el.setAttribute( "data-x", step.x ); el.setAttribute( "data-x", step.x );