What the best way, change only the registration steps and not every page

Asked

Viewed 746 times

5

I have a page where the user chooses to login (if already have registration) or register, if he chooses to register by clicking the button cadastre-se I would like the element to exit to the left and the first step of the registration to come to the right like a slide system.

In my Home html I have the steps call each one through a include and I leave one down the other following the hierarchy, do not know if for what I want this is the best option.

Like I could use display:none and applying display:block in the next element. But I would like to make the effect slide someone can give me a light and examples.


Follow an example in a simple way that I poderia but I want to replace it with the slide effect:

Example jsfiddle

Vlw

  • Friend, do an example in jsFiddler for us to help you. You want every step div of this step to have a right slide effect, that’s it?

  • https://jsfiddle.net/1r3vwf30/embedded/result/ I made a simple example of the way I could do, but I would like instead of just disappearing it to slide left and that place to Etapa2 that will slide right. @Rboschini tried some things like .hide() and .show() but it didn’t work very well nor the .animate({width: '0'} ) ...

  • @Erick, take a look at Antaimate from jquery: http://api.jquery.com/animate/

  • I left an example in Fiddler for you.

2 answers

1

You can use CSS to do this. Using CSS Transition and negative margin hides the element. Then you add a class that resets the margin to zero, with Javascript.

CSS

#slideleft {
  width: 200px;
  height: 200px;
  transition: margin-left .5s;
  margin-left: -200px;
  background: #ccf;
}

.abrir {
  margin-left: 0px !important;
}

Javascript:

button.addEventListener('click', function() {
  slide.classList.toggle('abrir');
});

jsFiddle: http://jsfiddle.net/20b36dnv/

  • I tried to reverse leaving the box already open and when clicking the button it slide but n worked, na vdd so invert o margin-left: in css, what can it be? This in your example in jsfiddle.

  • @Erick thus http://jsfiddle.net/20b36dnv/1/?

1


Buddy, I made an example for you. See if it helps

http://jsfiddle.net/qo7557p5/

I created html with the steps.

<div id="wizardSignin" data-step="1" active>
 <h1> Step 1 </h1>
 <input type="text">
</div>

<div id="wizardSignin" data-step="2">
 <h1> Step 2 </h1>
 <input type="checkbox">
</div>

<div id="wizardSignin" data-step="3">
 <h1> Step 3 </h1>
 <select>
   <option>Option 1</option>
 </select>
</div>

 <input type="button" id="nextButton" value="next">

In Js, display control and apply slide effect as you specified.

$(document).ready(function(){
    $('div[data-step]').hide();
  $('div[data-step=1]').show();

  $('#nextButton').on('click',function(){
        var idx  = $('#wizardSignin[active]').attr('data-step');
        $('#wizardSignin[active]').removeAttr('active').hide();

      if(idx<3){
        idx++;
      }else{
        idx=1;
      }

      $('#wizardSignin[data-step="'+idx+'"]').attr('active','');
      $('#wizardSignin[data-step="'+idx+'"]').effect('slide');


  });

});

See if this helps.

  • Look that’s right, trying to apply my need here I’m not getting by clicking the button it disappears with the first element but n shows the second but maybe I’m missing something here your example was nice thank you.

  • Remember that this example uses data-tag, don’t forget to put the data-step in your Ivs.

  • Edit your Iddler and put here that I help you, but adapt before the one you’ve sent, so we can codate together.

  • I found out what I had wrong and now it worked, I just need to know if you’ll see me since the system is more robust than I mentioned... But at last it was useful to me and it worked very thank you.

  • it is possible to slide the first element to the left and the next to come from the right?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.