Skip to content

Commit

Permalink
"goto is back, bye bye ugly stepTo"
Browse files Browse the repository at this point in the history
  • Loading branch information
bartaz committed Mar 14, 2012
1 parent c4d6ab3 commit 1a21865
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ VERSION HISTORY
- `present` class appears on currently visible step - it's different from `active` class as `present` class
is added when transition finishes (step is entered)
- `past` class is added to already visited steps (when the step is left)

* and good news, `goto()` API method is back! it seems that `goto` **was** a future reserved word but isn't anymore,
so we can use this short and pretty name instead of camelCassy `stepTo` - and yes, that means API changed again...

### 0.4.1 ([browse](http://github.com/bartaz/impress.js/tree/0.4.1), [zip](http://github.com/bartaz/impress.js/zipball/0.4.1), [tar](http://github.com/bartaz/impress.js/tarball/0.4.1))

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ <h1>impress.js<sup>*</sup></h1>
`api.init()` - initializes the presentation,
`api.next()` - moves to next step of the presentation,
`api.prev()` - moves to previous step of the presentation
`api.stepTo( stepElement ) - moves the presentation to given step element (the DOM element of the step).
`api.goto( stepElement ) - moves the presentation to given step element (the DOM element of the step).
You can also simply call `impress()` again to get the API, so `impress().next()` is also allowed.
Don't worry, it wont initialize the presentation again.
Expand Down
20 changes: 10 additions & 10 deletions js/impress.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
if (!impressSupported) {
return {
init: empty,
stepTo: empty,
goto: empty,
prev: empty,
next: empty
};
Expand Down Expand Up @@ -356,7 +356,7 @@
triggerEvent(root, "impress-init", { api: roots[ "impress-root-" + rootId ] });
};

var stepTo = function ( el, force ) {
var goto = function ( el, force ) {
if ( !initialized ||
!(el && el.id && stepsData["impress-" + el.id]) || // element is not a step
(el === activeStep && !force) ) {
Expand Down Expand Up @@ -446,14 +446,14 @@
var prev = steps.indexOf( activeStep ) - 1;
prev = prev >= 0 ? steps[ prev ] : steps[ steps.length-1 ];

return stepTo(prev);
return goto(prev);
};

var next = function () {
var next = steps.indexOf( activeStep ) + 1;
next = next < steps.length ? steps[ next ] : steps[ 0 ];

return stepTo(next);
return goto(next);
};

root.addEventListener("impress-init", function(){
Expand Down Expand Up @@ -489,19 +489,19 @@
}, false);

window.addEventListener("hashchange", function () {
stepTo( getElementFromUrl() );
goto( getElementFromUrl() );
}, false);

// START
// by selecting step defined in url or first step of the presentation
stepTo(getElementFromUrl() || steps[0]);
goto(getElementFromUrl() || steps[0]);
}, false);

body.classList.add("impress-disabled");

return (roots[ "impress-root-" + rootId ] = {
init: init,
stepTo: stepTo,
goto: goto,
next: next,
prev: prev
});
Expand Down Expand Up @@ -583,7 +583,7 @@
}
}

if ( api.stepTo(target) ) {
if ( api.goto(target) ) {
event.stopImmediatePropagation();
event.preventDefault();
}
Expand All @@ -598,7 +598,7 @@
target = target.parentNode;
}

if ( api.stepTo(target) ) {
if ( api.goto(target) ) {
event.preventDefault();
}
}, false);
Expand All @@ -625,7 +625,7 @@
// rescale presentation when window is resized
window.addEventListener("resize", throttle(function () {
// force going to active step again, to trigger rescaling
api.stepTo( document.querySelector(".active"), true );
api.goto( document.querySelector(".active"), true );
}, 250), false);

}, false);
Expand Down

0 comments on commit 1a21865

Please sign in to comment.