I’m working a project that has 4 rollover images side by side. I need to animate multiple rollover states depending on the button clicked. I included a graphic to help better explain what I’m talking about. Let me first apologize if this sounds confusing. I’m trying to explain it the best I can.
The script needs to work like this
If the number is higher all numbers to the right of the clicked number barrel rolls down. If this is the case numbers need to roll in sequence down.
If the number is lower all numbers to the right of the clicked number barrel rolls up. If this is the case numbers need to roll in sequence up.
I’m not a Javascript programmer, but I need something that something that has the proper logic like the code below.
Basically, if the number clicked is lower than the others the numbers to the right should barrel roll down in numerical sequence. If the number clicked is higher than the others the numbers to the right should barrel roll up in numerical sequence.
If 1 is clicked 2,3 & 4 should roll down. If 4 is clicked 3,2 & 1 should roll up. If 2 is clicked 3 & 4 should roll down etc, etc.
Ok, that’s as close as I got to a pure css solution, I’d keep most of that but add a little js to add a class to the parent specifying which one is rolled over.
Thanks for your input Mark. This is so very close.
After review my criteria has changed a little bit. These animations need to now be triggered by id. So Say for instance when 1 is clicked on the keyboard that triggers the animation for #1. 2,3 and so on.
Here’s the fiddle that explains the barrel roll control as far as how they need to roll up and down.
That being said I’m going to try to explain how these elements are supposed to work. When an element is selected that is to the left of another element that element should animate up. If an element is selected that is to the right of the current selected element they should roll down.
I’ve put together the following graphics for further clarification. Each barrel roll image looks like this. 2 selected states with one in active state in the center to accommodate for animations whether they animate up or down.
I can’t really help with the JS but maybe if you can clarify a little more what you need then it may aid a solution.
" when 1 is clicked on the keyboard" ? Do you mean when the number 1 key on the keyboard is pressed as you can’t click a keyboard as such? Or do you mean you have a Number 1 drawn on the screen and outside of the barrels which is clicked with the mouse?
Or are you still clicking the barrels?
What is the default state of the barrels? Are they all blank?
Are the barrels reset to start each time you click a number or do they stay from where they just finished?
In the second image on your drawing (The Number 4 item) you show the other barrels rolling down but it seems that the numbers 2 and 3 would already be in the finished position assuming that the first part of the image was the starting point for the next image? Also assuming that all but the clicked images reveal the middle part of the number?