Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creation of the multistep (substeps) functionnality #215

Closed
wants to merge 2 commits into from

Conversation

briceparent
Copy link

This is the same as #190 , which I closed because the base commit was including irrelevant changes in the indentation.

Added the substeps / Multistep functionnality that allows to create changes in a single step. Better explained in the example file, between the "positioning-rotating-scaling" step and the "imagination" step.
It works in both ways (from start to end and from end to start) to enable the users to rewind the presentation.

As everything in impress.js, it doesn't require javascript skills, only HTML+CSS. Hope you'll enjoy it!

…single step (see example to see it working)

As the rest of impress, this part only needs html+css skills. There is no need to add any javascript to use it.
We may now use :
document.addEventListener("impress:substepenter", myfunction);
document.addEventListener("impress:substepleave", myfunction);
and, to get the name of the substep :
var substep=event.target.getAttribute("data-active-substep");
@briceparent
Copy link
Author

There is a way to try this event handler :
Just add the following code right after the .fallback-message div :

<script>
document.addEventListener("impress:substepenter", function (event) {
    var substep=event.target.getAttribute("data-active-substep");
    document.getElementById('events_debugger').innerHTML = 'Entering substep '+substep+'<br />'+document.getElementById('events_debugger').innerHTML;
});
document.addEventListener("impress:substepleave", function (event) {
    var substep=event.target.getAttribute("data-active-substep");
    document.getElementById('events_debugger').innerHTML = 'Leaving substep '+substep+'<br />'+document.getElementById('events_debugger').innerHTML;
});
document.addEventListener("impress:stepenter", function (event) {
    var step = event.target.id;
    document.getElementById('events_debugger').innerHTML = 'Entering step '+step+'<br />'+document.getElementById('events_debugger').innerHTML;
});
document.addEventListener("impress:stepleave", function (event) {
    var step = event.target.id;
    document.getElementById('events_debugger').innerHTML = 'Leaving step '+step+'<br />'+document.getElementById('events_debugger').innerHTML;
});
</script>
<div id="events_debugger"></div>

and add some substeps (adding data-multistep="class_for_substep1 class_for_substep2 class_for_substep3" to any step, and go browse it. All events will be shown on the top left of the screen.

@briceparent briceparent mentioned this pull request Nov 2, 2012
@@ -378,6 +378,39 @@ a:focus {
}

/*
This step introduces substeps.
At first, it only has one line of text, but after 1 action, it adds one line and changes text color to red, and
after the second action, adds another line another line and changes the color to green.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'another line' is written twice

@briceparent
Copy link
Author

piranna: I'm not sure I really understood what you meant... Anyway, the way i've created it allows to use substeps with only CSS, only JS, or with both of them together.
The example I've inserted in the example is the CSS-only example, but you might just add the data-multistep argument and use the event handlers to execute any JS on the loading or unloading of any substeps. In other words, this multistep implementation works just the same way as the rest of the impress.js script, but inside the div of a step.
If there are use cases in which this implementation fails, please let me know, I'll see what I can do.

@piranna
Copy link

piranna commented Dec 7, 2012

Mainly homogeneity of the API: having a "step" class, it make sense to have a "substep" class inside them, and look for the substeps searching for the substep classes inside a step class instead of define them explicitly as you did with the data-multistep. This will make API cleaner and easier to understand.

@briceparent
Copy link
Author

But the action that is made is to add a class to the step, not to the substeps. We even may have no elements inside the step. Use cases are :

  • Like in the example, we have divs with some css properties which evolve everytime the user presses [space], like making them appear/disappear or the step's background color changes. This is a html+CSS only functionnality and we're not required to only make a div appear, we may do whatever we want inside the step!
  • The step only contains a raphael.js image (like say a bargraph), which when we press [space] is morphed to another image (like the same graph but with other values). This is a html+javascript functionality. There is no need for any element with the class "substep" that would appear in the middle and not be of any use.

To do the same, we might think of setting a number for the value of data-multistep, and adding a class of substep_[num_of_the_substep] to the main step, but i don't see a real improvement here...

I hope i've explained myself well, as english is not my mother language (as you might have noticed...).

@piranna
Copy link

piranna commented Dec 7, 2012

I understand you, but didn't finished to see it. Maybe I should do some experiments before...

@JWorthington
Copy link

What's the status of this commit?
I agree that with @piranna that it would be more parsimonious to use class="substep" on the children, and run through a

steps = $$(".substep", activeStep);
steps.forEach( initStep );

loop during stepenter to build the substeps.
I wish the main impress.js had a hook so we could do this as a plugin, but I don't see any way to put this in that doesn't alter the main code.

@FagnerMartinsBrack
Copy link
Member

FagnerMartinsBrack commented Feb 5, 2016

Hi @briceparent, in an effort to clear up older issues/PRs we are pinging back to know if you are still tracking this request.

To give a little bit of context, recently a decision was made in the project to make the development more active and the first task is to clear up older issues like this one to see if the OP is still interested in keep it going.

@piranna
Copy link

piranna commented Feb 5, 2016

I think this is a basic functionality...
El 5/2/2016 13:16, "Fagner Brack" notifications@github.com escribió:

Hi @briceparent https://github.com/briceparent, in an effort to clear
up older issues/PRs we are pinging back to know if you are still tracking
this request.

To give a little bit of context, recently a decision was made in the
project to make the development more active and the first task is to clear
up older issues like this one to see if the OP is still interested in keep
it going.


Reply to this email directly or view it on GitHub
#215 (comment).

@FagnerMartinsBrack
Copy link
Member

Hi @piranna, this is indeed a basic functionality and we will try to provide it as soon as possible. The initial plans for impress.js is that it becomes a core mechanism for 3D presentation-like use cases, so this feature might be implemented in a slightly different way in the future.

The reason why I ask if the OP is still tracking this issue is to keep open only one issue related to this feature and close the duplicates 👍

@briceparent
Copy link
Author

Hello !
I'm not using Impress anymore (not that I've replaced it with any other lib or technology, I just happen not to have the use for it).
When I opened this, it was just to propose my way of having substeps working like I needed it. I'm not sure if the problem and the solution are still relevant, or if my implementation is the one you need.
Feel free to keep this open and merge it if you feel like so, but don't do it for me as I probably won't find time to help you with it.
Brice

@JWorthington
Copy link

Here's how I solved it. Rather than load up a whole array of substeps on
load, it looks for children of the activeStep with a class of .substep on
next().
Since there's no hook in the next() function, I replaced the whole
function. I don't know how to formulate this as a pull request, so here it
is.

    // `next` API function goes to next substep within activeStep or to

next step (in document order)
var next = function () {
// if this step has substeps, and we're not already on the last one, then
"go to" the first/next substep and short-circuit going to the next step
var substeps = $$(".substep", activeStep);
if (substeps.length != 0) {
// if there is an active substep, deactivate it and activate the next
substep
var activeSubstep = $(".substep.active", activeStep);
if (activeSubstep != null) {
// make this one "past"
activeSubstep.classList.remove("active");
activeSubstep.classList.add("past");
// if this is not the last substep, make the next substep "active"
var activeSubstepIndex = substeps.indexOf(activeSubstep);
if (activeSubstepIndex < substeps.length - 1) {
activeSubstep = substeps[activeSubstepIndex + 1];
activeSubstep.classList.remove("past"); // shouldn't be "past", but just to
be thorough
activeSubstep.classList.add("active");
return true; // exit before calling goto(next)
}
// else it was the last substep, so flow through to the normal next-step
behavior
}
else { // no active substep (yet)
// if not all "past" (i.e., if not any are past), activate the first substep
if ($(".substep.past", activeStep) == null) {
// if none is "active" and none are "past", they must be all future (the
default state), so set the first one active
var activeSubstep = substeps[0];
activeSubstep.classList.add("active");
return true; // exit before calling goto(next)
}
// else all substeps were previously visited, so flow through to the normal
next-step behavior
}
}
var next = steps.indexOf( activeStep ) + 1;
next = next < steps.length ? steps[ next ] : steps[ 0 ];

        return goto(next);
    };

On Fri, Feb 5, 2016 at 7:47 AM Brice PARENT notifications@github.com
wrote:

Hello !
I'm not using Impress anymore (not that I've replaced it with any other
lib or technology, I just happen not to have the use for it).
When I opened this, it was just to propose my way of having substeps
working like I needed it. I'm not sure if the problem and the solution are
still relevant, or if my implementation is the one you need.
Feel free to keep this open and merge it if you feel like so, but don't do
it for me as I probably won't find time to help you with it.

Brice


Reply to this email directly or view it on GitHub
#215 (comment).

@FagnerMartinsBrack
Copy link
Member

Hi @briceparent thanks for the feedback! In this case we will close this issue in order to track this feature using other similar PRs/Issues. Thank you very much for your effort and for the response.

We can reopen it later if you think it is necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants