Advertisement
Fhernd

app.js

Sep 20th, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Calculadora = {
  2.     init: function(){
  3.         this.aplicarEfectoTeclas();
  4.     },
  5.     aplicarEfectoTeclas: function(){
  6.         var teclas = document.getElementsByClassName('tecla');
  7.  
  8.         for(var i = 0; i <teclas.length; ++i) {
  9.             teclas[i].onmousedown = this.presionarTecla;
  10.             teclas[i].onmouseup = this.soltarTecla;
  11.         }
  12.     },
  13.     presionarTecla: function(event){
  14.         var tecla = event.target;
  15.  
  16.         console.log(tecla);
  17.  
  18.         tecla.style.width = (tecla.style.width - 5) + "px";
  19.         tecla.style.height = (tecla.style.height - 5) + "px";
  20.     },
  21.     soltarTecla: function(event){
  22.         var tecla = event.target;
  23.  
  24.         tecla.style.width = (tecla.style.width + 5) + "px";
  25.         tecla.style.height = (tecla.style.height + 5) + "px";
  26.     }
  27. };
  28.  
  29. Calculadora.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement