Guest User

Untitled

a guest
Jan 10th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. //Oi, Amanda! Como você sabe, tô tentando aprender algumas coisinhas.
  2. /*neste codigo eu tentei utilizar o jQuery pra manipular o css de uma página.
  3. o objetivo era usar a propriedade transform dinamicamente com o js(jquery) para mostrar sections.
  4. Quando o usuario clica em um dos botões do menu, a section se apresenta com o translateX e uma setinha básica que eu fiz no Adobe PS
  5. aparece, só pra indicar que conteudo está sendo mostrado.
  6. Ao clicar denovo, no mesmo ou em outro botão do menu, a section ativa se esconde e a nova section target é transladada para aparecer.
  7. Esse trechinho é só isso mesmo. :x*/
  8. var divActive = null;
  9. $(document).ready(function(){
  10. //Funções dos botões do menu
  11. $("#menu button").click(function mostraDiv(){
  12. $(".seta").css({
  13. transform: "rotate(0deg) scale(0.6)"
  14. });
  15. var target = $(this).attr("id");
  16. if(divActive === null){
  17. $("#"+target+"Section").css("transform", "translateX(1140px)");
  18. $("#"+target+"Seta").fadeIn("slow");
  19. divActive = target;
  20. }
  21.  
  22. else{
  23. $("#"+divActive+"Section").hide("slow");
  24. $("#"+divActive+"Section").css("transform", "translateX(-1140px)");
  25. $("#"+divActive+"Section").show("slow");
  26. $("#"+divActive+"Seta").css({
  27. transform: "rotate(-180deg)"
  28. });
  29. $("#"+divActive+"Seta").fadeOut("slow");
  30. if(divActive !== target){
  31. $("#"+target+"Section").css("transform", "translateX(1140px)");
  32. $("#"+target+"Seta").fadeIn("slow");
  33. divActive = target;
  34. }
  35. else if(divActive === target){
  36. divActive = null;
  37. }
  38. }
  39. });
  40. }
  41.  
  42. //Obrigado pela atenção, Amandaaaa *O*
  43. //PS: Tá tudo errado? T____T
Add Comment
Please, Sign In to add comment