"goto is back, bye bye ugly stepTo"
This commit is contained in:
@@ -39,7 +39,8 @@ VERSION HISTORY
|
|||||||
- `present` class appears on currently visible step - it's different from `active` class as `present` class
|
- `present` class appears on currently visible step - it's different from `active` class as `present` class
|
||||||
is added when transition finishes (step is entered)
|
is added when transition finishes (step is entered)
|
||||||
- `past` class is added to already visited steps (when the step is left)
|
- `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))
|
### 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))
|
||||||
|
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ if ("ontouchstart" in document.documentElement) {
|
|||||||
`api.init()` - initializes the presentation,
|
`api.init()` - initializes the presentation,
|
||||||
`api.next()` - moves to next step of the presentation,
|
`api.next()` - moves to next step of the presentation,
|
||||||
`api.prev()` - moves to previous 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.
|
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.
|
Don't worry, it wont initialize the presentation again.
|
||||||
|
|||||||
@@ -184,7 +184,7 @@
|
|||||||
if (!impressSupported) {
|
if (!impressSupported) {
|
||||||
return {
|
return {
|
||||||
init: empty,
|
init: empty,
|
||||||
stepTo: empty,
|
goto: empty,
|
||||||
prev: empty,
|
prev: empty,
|
||||||
next: empty
|
next: empty
|
||||||
};
|
};
|
||||||
@@ -356,7 +356,7 @@
|
|||||||
triggerEvent(root, "impress-init", { api: roots[ "impress-root-" + rootId ] });
|
triggerEvent(root, "impress-init", { api: roots[ "impress-root-" + rootId ] });
|
||||||
};
|
};
|
||||||
|
|
||||||
var stepTo = function ( el, force ) {
|
var goto = function ( el, force ) {
|
||||||
if ( !initialized ||
|
if ( !initialized ||
|
||||||
!(el && el.id && stepsData["impress-" + el.id]) || // element is not a step
|
!(el && el.id && stepsData["impress-" + el.id]) || // element is not a step
|
||||||
(el === activeStep && !force) ) {
|
(el === activeStep && !force) ) {
|
||||||
@@ -446,14 +446,14 @@
|
|||||||
var prev = steps.indexOf( activeStep ) - 1;
|
var prev = steps.indexOf( activeStep ) - 1;
|
||||||
prev = prev >= 0 ? steps[ prev ] : steps[ steps.length-1 ];
|
prev = prev >= 0 ? steps[ prev ] : steps[ steps.length-1 ];
|
||||||
|
|
||||||
return stepTo(prev);
|
return goto(prev);
|
||||||
};
|
};
|
||||||
|
|
||||||
var next = function () {
|
var next = function () {
|
||||||
var next = steps.indexOf( activeStep ) + 1;
|
var next = steps.indexOf( activeStep ) + 1;
|
||||||
next = next < steps.length ? steps[ next ] : steps[ 0 ];
|
next = next < steps.length ? steps[ next ] : steps[ 0 ];
|
||||||
|
|
||||||
return stepTo(next);
|
return goto(next);
|
||||||
};
|
};
|
||||||
|
|
||||||
root.addEventListener("impress-init", function(){
|
root.addEventListener("impress-init", function(){
|
||||||
@@ -489,19 +489,19 @@
|
|||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
window.addEventListener("hashchange", function () {
|
window.addEventListener("hashchange", function () {
|
||||||
stepTo( getElementFromUrl() );
|
goto( getElementFromUrl() );
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
// START
|
// START
|
||||||
// by selecting step defined in url or first step of the presentation
|
// by selecting step defined in url or first step of the presentation
|
||||||
stepTo(getElementFromUrl() || steps[0]);
|
goto(getElementFromUrl() || steps[0]);
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
body.classList.add("impress-disabled");
|
body.classList.add("impress-disabled");
|
||||||
|
|
||||||
return (roots[ "impress-root-" + rootId ] = {
|
return (roots[ "impress-root-" + rootId ] = {
|
||||||
init: init,
|
init: init,
|
||||||
stepTo: stepTo,
|
goto: goto,
|
||||||
next: next,
|
next: next,
|
||||||
prev: prev
|
prev: prev
|
||||||
});
|
});
|
||||||
@@ -583,7 +583,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( api.stepTo(target) ) {
|
if ( api.goto(target) ) {
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -598,7 +598,7 @@
|
|||||||
target = target.parentNode;
|
target = target.parentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( api.stepTo(target) ) {
|
if ( api.goto(target) ) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
@@ -625,7 +625,7 @@
|
|||||||
// rescale presentation when window is resized
|
// rescale presentation when window is resized
|
||||||
window.addEventListener("resize", throttle(function () {
|
window.addEventListener("resize", throttle(function () {
|
||||||
// force going to active step again, to trigger rescaling
|
// force going to active step again, to trigger rescaling
|
||||||
api.stepTo( document.querySelector(".active"), true );
|
api.goto( document.querySelector(".active"), true );
|
||||||
}, 250), false);
|
}, 250), false);
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user