Advertisement
Hisabeel

How to put shake effect on image?

Sep 28th, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 3.83 KB | None | 0 0
  1. Passo 1: Coloque o seguinte código antes <head> e </ head>
  2.     <style>
  3.     .shakeimage{
  4.     position:relative}
  5.     </style>
  6.  
  7.     <script language=”JavaScript1.2”>
  8.     //configure shake degree (where larger # equals greater shake)
  9.     var rector=3
  10.     var stopit=0
  11.     var a=1
  12.     function init(which){
  13.     stopit=0
  14.     shake=which
  15.     shake.style.left=0
  16.     shake.style.top=0}
  17.     function rattleimage(){
  18.     if ((!document.all&&!document.getElementById)||stopit==1) return
  19.     if (a==1){
  20.     shake.style.top=parseInt(shake.style.top)+rector+”px”}
  21.     else if (a==2){
  22.     shake.style.left=parseInt(shake.style.left)+rector+”px”}
  23.     else if (a==3){
  24.     shake.style.top=parseInt(shake.style.top)-rector+”px”}
  25.     else{
  26.     shake.style.left=parseInt(shake.style.left)-rector+”px”} if (a<4)
  27.     a++
  28.     else
  29.     a=1
  30.     setTimeout(“rattleimage(),50)}
  31.     function stoprattle(which){
  32.     stopit=1
  33.     which.style.left=0
  34.     which.style.top=0}
  35.     </script>
  36.  
  37. Passo 2: coloque o seguinte código dentro da tag <img> de todas as imagens que deseja que o efeito seja aplicado:
  38.     class=”shakeimage” onMouseover=”init(this);rattleimage()” onMouseout=”stoprattle(this);top.focus()” onClick=”top.focus()
  39.  
  40. Aqui está um exemplo:
  41.     <img src=”IMAGE URL” class=”shakeimage” onMouseover=”init(this);rattleimage()” onMouseout=”stoprattle(this);top.focus()”onClick=”top.focus()>
  42.  
  43. Substitua "IMAGE URL" pela URL da imagem:
  44.     <img src”{image:sidebar}” class=”shakeimage” onMouseover=”init(this);rattleimage()” onMouseout=”stoprattle(this);top.focus()”onClick=”top.focus()>
  45.  
  46.     <img src”http://static.tumblr.com/9wzbixa/ZpJlwjen8/banner.png” class=”shakeimage” onMouseover=”init(this);rattleimage()” onMouseout=”stoprattle(this);top.focus()”onClick=”top.focus()>
  47.  
  48.  
  49.  
  50. Tutorial original por Jada (http://neudest.tumblr.com/)
  51.  
  52.  
  53. x ----------------------------------------------------------------------------------------------------------------------------------- x
  54.  
  55.  
  56. Step 1: Put the following code before <head> and </head>
  57.     <style>
  58.     .shakeimage{
  59.     position:relative}
  60.     </style>
  61.  
  62.     <script language=”JavaScript1.2”>
  63.     //configure shake degree (where larger # equals greater shake)
  64.     var rector=3
  65.     var stopit=0
  66.     var a=1
  67.     function init(which){
  68.     stopit=0
  69.     shake=which
  70.     shake.style.left=0
  71.     shake.style.top=0}
  72.     function rattleimage(){
  73.     if ((!document.all&&!document.getElementById)||stopit==1) return
  74.     if (a==1){
  75.     shake.style.top=parseInt(shake.style.top)+rector+”px”}
  76.     else if (a==2){
  77.     shake.style.left=parseInt(shake.style.left)+rector+”px”}
  78.     else if (a==3){
  79.     shake.style.top=parseInt(shake.style.top)-rector+”px”}
  80.     else{
  81.     shake.style.left=parseInt(shake.style.left)-rector+”px”} if (a<4)
  82.     a++
  83.     else
  84.     a=1
  85.     setTimeout(“rattleimage(),50)}
  86.     function stoprattle(which){
  87.     stopit=1
  88.     which.style.left=0
  89.     which.style.top=0}
  90.     </script>
  91.  
  92. Step 2: Put the following code inside the <img> tag of all the images you want the effect to be applied on:
  93.     class=”shakeimage” onMouseover=”init(this);rattleimage()” onMouseout=”stoprattle(this);top.focus()” onClick=”top.focus()
  94.  
  95. Here’s an example:
  96.     <img src=”IMAGE URL” class=”shakeimage” onMouseover=”init(this);rattleimage()” onMouseout=”stoprattle(this);top.focus()”onClick=”top.focus()>
  97.  
  98. Replace “IMAGE URL” with the url of the image:
  99.     <img src”{image:sidebar}” class=”shakeimage” onMouseover=”init(this);rattleimage()” onMouseout=”stoprattle(this);top.focus()”onClick=”top.focus()>
  100.  
  101.     <img src”http://static.tumblr.com/9wzbixa/ZpJlwjen8/banner.png” class=”shakeimage” onMouseover=”init(this);rattleimage()” onMouseout=”stoprattle(this);top.focus()”onClick=”top.focus()>
  102.  
  103.  
  104.  
  105. Original tutorial by Jada (http://neudest.tumblr.com/)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement