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>
- .compass {
- display: block;
- width: 80px;
- height: 80px;
- border-radius: 100%;
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.85);
- position: relative;
- color: #555;
- text-shadow: 1px 1px 1px white;
- margin: 0 auto;
- }
- .compass:before {
- font-weight: bold;
- position: absolute;
- text-align: center;
- width: 100%;
- content: "";
- font-size: 14px;
- top: -2px;
- }
- .compass .direction {
- height: 100%;
- width: 100%;
- display: block;
- background: #f2f6f5;
- background: -moz-linear-gradient(top, #f2f6f5 0%, #cbd5d6 100%);
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f2f6f5), color-stop(100%, #cbd5d6));
- background: -webkit-linear-gradient(top, #f2f6f5 0%, #cbd5d6 100%);
- background: -o-linear-gradient(top, #f2f6f5 0%, #cbd5d6 100%);
- border-radius: 100%;
- }
- .compass .direction p {
- text-align: center;
- margin: 0;
- padding: 0;
- position: absolute;
- top: 50%;
- left: 0;
- width: 100%;
- height: 100%;
- line-height: 80px;
- display: block;
- margin-top: -45px;
- font-size: 28px;
- font-weight: bold;
- }
- .compass .direction p span {
- display: block;
- line-height: normal;
- margin-top: -24px;
- font-size: 11px;
- text-transform: uppercase;
- font-weight: normal;
- }
- .compass .arrow {
- width: 100%;
- height: 100%;
- display: block;
- position: absolute;
- top: 0;
- }
- .compass .arrow:after {
- content: "";
- width: 0;
- height: 0;
- border-left: 5px solid transparent;
- border-right: 5px solid transparent;
- border-bottom: 10px solid red;
- position: absolute;
- top: -6px;
- left: 50%;
- margin-left: -5px;
- z-index: 99;
- }
- .compass .arrow.nne {
- transform: rotate(22.5deg);
- transition: transform 3s;
- }
- .compass .arrow.ne {
- transform: rotate(45deg);
- transition: transform 3s;
- }
- .compass .arrow.ene {
- transform: rotate(67.5deg);
- transition: transform 3s;
- }
- .compass .arrow.e {
- transform: rotate(90deg);
- transition: transform 3s;
- }
-
- </style>
- <table style="width:98%;margin:0 auto">
- <tr>
- <td>
- <div class="compass" id="nowDirDiv">
- <div class="arrow <?php echo strtolower(($direction['now']))?>"></div>
- </div>
- <?php echo lang("ora",'c')?>
- </td>
- </tr>
-
- <script>
- windDirupdater();
- setInterval(function(){ windDirupdater(); }, (5*1000));
- function windDirupdater(){
- $.ajax({
- url : "homepage/blocks/windDir/windDirUpdater.php",
- dataType : 'json',
- success : function (json) {
- html = '<div class="arrow '+json['now']+'"></div>';
- $("#nowDirDiv").html(html);
- }
- })
- }
- </script>