Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Fixes to data-rel-to
Browse files Browse the repository at this point in the history
Fixes 80ffff0
  • Loading branch information
Henrik Ingo committed May 8, 2018
1 parent 6707950 commit 194ae3b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
6 changes: 3 additions & 3 deletions examples/classic-slides/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
powerpoint slide show. The "slide" class is entirely optional and indeed you wouldn't use it for
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 />
Classic Slides</h1>
<h2>Henrik Ingo</h2>
Expand All @@ -114,7 +114,7 @@ <h3>2015</h3>
</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>
<ul>
<li><a href="#step-1">A title slide</a></li>
Expand Down Expand Up @@ -151,7 +151,7 @@ <h1>A slide with text</h1>
</div>
</div>

<div class="step slide">
<div class="step slide" data-rel-to="title" data-y="2000">
<h1>Bullet points</h1>
<ul>
<li>A slide with bullet points. This is the first point.</li>
Expand Down
1 change: 1 addition & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ul><br />
<li><a href="2D-navigation/">2D-navigation</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="cube/">cube</a></li>
<li><a href="markdown/">markdown</a></li>
Expand Down
12 changes: 6 additions & 6 deletions js/impress.js
Original file line number Diff line number Diff line change
Expand Up @@ -3566,7 +3566,7 @@
}
};

var computeRelativePositions = function( el, prev, root ) {
var computeRelativePositions = function( el, prev ) {
var data = el.dataset;

if ( !prev ) {
Expand All @@ -3577,14 +3577,14 @@

if ( data.relTo ) {

var ref = root.getElementById( data.relTo );
var ref = document.getElementById( data.relTo );
if ( ref ) {

// Test, if it is a previous step that already has some assigned position data
if ( el.compareDocumentPosition( ref ) & Node.DOCUMENT_POSITION_PRECEDING ) {
prev.x = ref.getAttribute( "data-x" );
prev.y = ref.getAttribute( "data-y" );
prev.z = ref.getAttribute( "data-z" );
prev.x = toNumber( ref.getAttribute( "data-x" ) );
prev.y = toNumber( ref.getAttribute( "data-y" ) );
prev.z = toNumber( ref.getAttribute( "data-z" ) );
prev.relative = {};
} else {
window.console.error(
Expand Down Expand Up @@ -3650,7 +3650,7 @@
y: el.getAttribute( "data-y" ),
z: el.getAttribute( "data-z" )
} );
var step = computeRelativePositions( el, prev, root );
var step = computeRelativePositions( el, prev );

// Apply relative position (if non-zero)
el.setAttribute( "data-x", step.x );
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/rel/rel.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
}
};

var computeRelativePositions = function( el, prev, root ) {
var computeRelativePositions = function( el, prev ) {
var data = el.dataset;

if ( !prev ) {
Expand All @@ -88,14 +88,14 @@

if ( data.relTo ) {

var ref = root.getElementById( data.relTo );
var ref = document.getElementById( data.relTo );
if ( ref ) {

// Test, if it is a previous step that already has some assigned position data
if ( el.compareDocumentPosition( ref ) & Node.DOCUMENT_POSITION_PRECEDING ) {
prev.x = ref.getAttribute( "data-x" );
prev.y = ref.getAttribute( "data-y" );
prev.z = ref.getAttribute( "data-z" );
prev.x = toNumber( ref.getAttribute( "data-x" ) );
prev.y = toNumber( ref.getAttribute( "data-y" ) );
prev.z = toNumber( ref.getAttribute( "data-z" ) );
prev.relative = {};
} else {
window.console.error(
Expand Down Expand Up @@ -161,7 +161,7 @@
y: el.getAttribute( "data-y" ),
z: el.getAttribute( "data-z" )
} );
var step = computeRelativePositions( el, prev, root );
var step = computeRelativePositions( el, prev );

// Apply relative position (if non-zero)
el.setAttribute( "data-x", step.x );
Expand Down

0 comments on commit 194ae3b

Please sign in to comment.