css transition updated with ajax call

css transition updated with ajax call

I would like to ask help regarding a CSS transition which works, but is not working when I update the page through a ajax recall. I try to explain: I defined a compass CSS object and a arrow of this compass which should be oriented in the compass as the wind does (wind direction is updated every second). I created a CSS object and the arrow moves to the initial position slowly with the transition effect. Than every seconds there is an update of the wind data and I use a Ajax call to update the page. Consider that the windDirUpdater function is returning the updated wind direction (json['now']). The arrow updates the position but without transition. Can anybody help me please?

I add part of the code which i am using now to define the CSS object and the ajax recall I do Thanks Fabio 

 ruzzi.f@gmail.com


  • <style>

    1. .compass {

    2. display: block;

    3. width: 80px;

    4. height: 80px;

    5. border-radius: 100%;

    6. box-shadow: 0 0 10px rgba(0, 0, 0, 0.85);

    7. position: relative;

    8. color: #555;

    9. text-shadow: 1px 1px 1px white;

    10. margin: 0 auto;

    11.  }

    12.  .compass:before {

    13. font-weight: bold;

    14. position: absolute;

    15. text-align: center;

    16. width: 100%;

    17. content: "";

    18. font-size: 14px;

    19. top: -2px;

    20.  }

    21.  .compass .direction {

    22. height: 100%;

    23. width: 100%;

    24. display: block;

    25. background: #f2f6f5;

    26. background: -moz-linear-gradient(top, #f2f6f5 0%, #cbd5d6 100%);

    27. background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f2f6f5), color-stop(100%, #cbd5d6));

    28. background: -webkit-linear-gradient(top, #f2f6f5 0%, #cbd5d6 100%);

    29. background: -o-linear-gradient(top, #f2f6f5 0%, #cbd5d6 100%);

    30. border-radius: 100%;

    31.  }

    32.  .compass .direction p {

    33. text-align: center;

    34. margin: 0;

    35. padding: 0;

    36. position: absolute;

    37. top: 50%;

    38. left: 0;

    39. width: 100%;

    40. height: 100%;

    41. line-height: 80px;

    42. display: block;

    43. margin-top: -45px;

    44. font-size: 28px;

    45. font-weight: bold;

    46.  }

    47.  .compass .direction p span {

    48. display: block;

    49. line-height: normal;

    50. margin-top: -24px;

    51. font-size: 11px;

    52. text-transform: uppercase;

    53. font-weight: normal;

    54.  }

    55.  .compass .arrow {

    56. width: 100%;

    57. height: 100%;

    58. display: block;

    59. position: absolute;

    60. top: 0;

    61.  }

    62.  .compass .arrow:after {

    63. content: "";

    64. width: 0;

    65. height: 0;

    66. border-left: 5px solid transparent;

    67. border-right: 5px solid transparent;

    68. border-bottom: 10px solid red;

    69. position: absolute;

    70. top: -6px;

    71. left: 50%;

    72. margin-left: -5px;

    73. z-index: 99;

    74.  }

    75.  .compass .arrow.nne {

    76. transform: rotate(22.5deg);
    77. transition: transform 3s;

    78.  }

    79.  .compass .arrow.ne {

    80. transform: rotate(45deg);
    81. transition: transform 3s;

    82.  }

    83.  .compass .arrow.ene {

    84. transform: rotate(67.5deg);
    85. transition: transform 3s;

    86.  }

    87.  .compass .arrow.e {

    88. transform: rotate(90deg);
    89. transition: transform 3s;

    90.  }


    91. </style>

    92. <table style="width:98%;margin:0 auto">

    93. <tr>

    94. <td>

    95. <div class="compass" id="nowDirDiv">


    96. <div class="arrow <?php echo strtolower(($direction['now']))?>"></div>

    97. </div>

    98. <?php echo lang("ora",'c')?>

    99. </td>

    100. </tr>


    101. <script> 

    102. windDirupdater();

    103. setInterval(function(){ windDirupdater(); }, (5*1000));

    104. function windDirupdater(){

    105. $.ajax({

    106. url : "homepage/blocks/windDir/windDirUpdater.php",

    107. dataType : 'json',

    108. success : function (json) {

    109. html = '<div class="arrow '+json['now']+'"></div>';
    110. $("#nowDirDiv").html(html);

    111. }

    112. })

    113. }

    114. </script>