Skip to content

Commit

Permalink
Implement "transition-duration" for individual steps.
Browse files Browse the repository at this point in the history
Closes gh-6.
  • Loading branch information
FagnerMartinsBrack committed Nov 11, 2014
1 parent 246b58e commit 4976b8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 6 additions & 3 deletions gh-pages/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,11 @@
It will not be rotated or scaled.
Also, you can optionally specify `data-transition-duration="300"` for individual steps.
It defaults to the values specified in the `#impress` element.
-->
<div id="bored" class="step slide" data-x="-1000" data-y="-1500">
<div id="bored" class="step slide" data-x="-1000" data-y="-1500" data-transition-duration="300">
<q>Aren't you just <b>bored</b> with all those slides-based presentations?</q>
</div>

Expand All @@ -182,11 +185,11 @@
Using classic `id`-based links like `#step-2` makes these links usable also in fallback mode.
-->
<div class="step slide" data-x="0" data-y="-1500">
<div class="step slide" data-x="0" data-y="-1500" data-transition-duration="300">
<q>Don't you think that presentations given <strong>in modern browsers</strong> shouldn't <strong>copy the limits</strong> of 'classic' slide decks?</q>
</div>

<div class="step slide" data-x="1000" data-y="-1500">
<div class="step slide" data-x="1000" data-y="-1500" data-transition-duration="300">
<q>Would you like to <strong>impress your audience</strong> with <strong>stunning visualization</strong> of your talk?</q>
</div>

Expand Down
13 changes: 10 additions & 3 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var css = function( element, props ) {
};

// Takes a value given as `numeric` parameter and tries to turn it into a number. If it is not
// possible it returns 0 (or other value given as `fallback`).
//possible it returns 0 (or other value given as `fallback`).
var toNumber = function( numeric, fallback ) {
return isNaN( numeric ) ? ( fallback || 0 ) : Number( numeric );
};
Expand Down Expand Up @@ -407,7 +407,7 @@ var impress = function( argument ) {
// Used to reset timeout for `impress:stepenter` event.
var stepEnterTimeout = null;

// API function that moves to step according to the `argument` parameter (by index, id
// API function that moves to step according to the `argument` parameter (by step index, id
// or element), with a transition `duration` optionally given as second parameter.
var goto = function( argument, duration ) {
var element = getStep( argument );
Expand Down Expand Up @@ -462,7 +462,14 @@ var impress = function( argument ) {
// zooming out we start with scaling down and move and rotation are delayed.
var zoomin = target.scale >= currentState.scale;

duration = toNumber( duration, config.transitionDuration );
// If a duration was specified, use that, otherwise use the step data attribute.
var stepData = element.dataset;
if ( arguments.length > 1 ) {
duration = toNumber( duration, config.transitionDuration );
} else {
duration = toNumber( stepData.transitionDuration, config.transitionDuration );
}

var delay = duration / 2;

// If the same step is re-selected, force computing window scaling, because it is likely
Expand Down

0 comments on commit 4976b8e

Please sign in to comment.