From 7a9a50d0c82a23247058fe79418514fcb8d2cc6e Mon Sep 17 00:00:00 2001 From: tamaz bagdavadze Date: Mon, 4 Jan 2016 11:54:46 -0800 Subject: [PATCH 1/5] added angle --- keyboardanimation/jscss/Kjs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboardanimation/jscss/Kjs.js b/keyboardanimation/jscss/Kjs.js index 49287ec..7390b77 100644 --- a/keyboardanimation/jscss/Kjs.js +++ b/keyboardanimation/jscss/Kjs.js @@ -156,7 +156,7 @@ if(Math.floor(Math.random()*100)%2){ $(".animation").animate({ opacity: 0.15, bottom: "+="+heightofwindow, - left: "+="+ (Math.floor(Math.random() * (500 - 100)) + 100), + left: "+="+ (Math.floor(Math.random() * (windowWidth/2 - 100)) + 100), }, 2000, function() { From a70b2e06aa545babba3909267fe82d8ca78176bb Mon Sep 17 00:00:00 2001 From: tamaz bagdavadze Date: Mon, 4 Jan 2016 12:04:07 -0800 Subject: [PATCH 2/5] added angle --- keyboardanimation/jscss/Kjs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboardanimation/jscss/Kjs.js b/keyboardanimation/jscss/Kjs.js index 7390b77..63d34dc 100644 --- a/keyboardanimation/jscss/Kjs.js +++ b/keyboardanimation/jscss/Kjs.js @@ -156,7 +156,7 @@ if(Math.floor(Math.random()*100)%2){ $(".animation").animate({ opacity: 0.15, bottom: "+="+heightofwindow, - left: "+="+ (Math.floor(Math.random() * (windowWidth/2 - 100)) + 100), + left: "+="+ (Math.floor(Math.random() * windowWidth)), }, 2000, function() { @@ -167,7 +167,7 @@ if(Math.floor(Math.random()*100)%2){ $(".animation").animate({ opacity: 0.15, bottom: "+="+heightofwindow, - right: "+="+ (Math.floor(Math.random() * (windowWidth/2 - 100)) + 100), + right: "+="+ (Math.floor(Math.random() * windowWidth)), }, 2000, function() { From 1d3a7802146961881cc9fa519823d2e2fca34d5a Mon Sep 17 00:00:00 2001 From: tamaz bagdavadze Date: Mon, 4 Jan 2016 12:11:16 -0800 Subject: [PATCH 3/5] refactored --- keyboardanimation/jscss/Kjs.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/keyboardanimation/jscss/Kjs.js b/keyboardanimation/jscss/Kjs.js index 63d34dc..cfbb335 100644 --- a/keyboardanimation/jscss/Kjs.js +++ b/keyboardanimation/jscss/Kjs.js @@ -151,24 +151,29 @@ $( "body" ).keydown(function(event) { $("#"+id).css("width","20%"); + +var animateObj = { + opacity: 0.15, + bottom: "+="+heightofwindow + }; + + if(Math.floor(Math.random()*100)%2){ - $(".animation").animate({ - opacity: 0.15, - bottom: "+="+heightofwindow, - left: "+="+ (Math.floor(Math.random() * windowWidth)), - }, + animateObj.left = "+="+ (Math.floor(Math.random() * windowWidth)), + + $(".animation").animate( + animateObj, 2000, function() { $(this).remove(); }); }else{ - $(".animation").animate({ - opacity: 0.15, - bottom: "+="+heightofwindow, - right: "+="+ (Math.floor(Math.random() * windowWidth)), - }, + animateObj.right = "+="+ (Math.floor(Math.random() * windowWidth)), + + $(".animation").animate( + animateObj, 2000, function() { $(this).remove(); From cf45924511f83fd29004630723ccdf8babe3ca7f Mon Sep 17 00:00:00 2001 From: tamaz bagdavadze Date: Mon, 4 Jan 2016 12:26:42 -0800 Subject: [PATCH 4/5] fixed key start place --- keyboardanimation/jscss/Kjs.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/keyboardanimation/jscss/Kjs.js b/keyboardanimation/jscss/Kjs.js index cfbb335..f31a56c 100644 --- a/keyboardanimation/jscss/Kjs.js +++ b/keyboardanimation/jscss/Kjs.js @@ -154,26 +154,27 @@ $( "body" ).keydown(function(event) { var animateObj = { opacity: 0.15, - bottom: "+="+heightofwindow + bottom: "+="+heightofwindow, + marginLeft : Math.floor(Math.random() * (windowWidth-100))+"px" }; -if(Math.floor(Math.random()*100)%2){ - animateObj.left = "+="+ (Math.floor(Math.random() * windowWidth)), +if(Math.floor(Math.random()*100)%2){ $(".animation").animate( animateObj, + + 2000, function() { $(this).remove(); }); }else{ - animateObj.right = "+="+ (Math.floor(Math.random() * windowWidth)), - $(".animation").animate( animateObj, + 2000, function() { $(this).remove(); From 8f7990f100ee3a40f83d0f35cb69a2f0a349e3f9 Mon Sep 17 00:00:00 2001 From: tamaz bagdavadze Date: Mon, 4 Jan 2016 12:27:39 -0800 Subject: [PATCH 5/5] refactored --- keyboardanimation/jscss/Kjs.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/keyboardanimation/jscss/Kjs.js b/keyboardanimation/jscss/Kjs.js index f31a56c..7a72f7f 100644 --- a/keyboardanimation/jscss/Kjs.js +++ b/keyboardanimation/jscss/Kjs.js @@ -158,29 +158,12 @@ var animateObj = { marginLeft : Math.floor(Math.random() * (windowWidth-100))+"px" }; - - -if(Math.floor(Math.random()*100)%2){ - $(".animation").animate( animateObj, - - 2000, function() { $(this).remove(); }); -}else{ - - $(".animation").animate( - animateObj, - - 2000, - function() { - $(this).remove(); - }); - -} id++;