在Firefox中的Svg转换原点问题

时间:2016-08-22 08:05:45

标签: css animation svg

我正在尝试使用CSS动画旋转风车。我给Chrome的原始值很好,但在Firefox中,orgin无法正常工作。

我也试过了trigger MapStatusToStageBeforeOpportunintyCreation on Opportunity (before insert, before update) { Set<ID> acctIDS = new Set<ID>(); Set<ID> propIDS = new Set<ID>(); String tempOppName; for (Opportunity o : Trigger.New){ if(o.AccountId != null){ acctIDS.add(o.AccountID); } } for (Opportunity o : Trigger.New){ if(o.Property_Name__c != null){ propIDS.add(o.Property_Name__c); } } Map<ID, Account> acctMap = new Map<ID, Account>([Select LastName From Account Where ID =: acctIDS]); Map<ID, Property__c> propMap = new Map<ID, Property__c>([Select Property_Code__c From Property__c Where ID =: propIDS]); for (Opportunity o : Trigger.New){ // Mapping the StageName with Application_Status__c before Insert/update if (o.Application_Status__c == 'Denied'){ o.StageName ='Denied'; } else if(o.Application_Status__c == 'Approved'){ o.StageName ='Approved - Conditions Pending'; } else if(o.Application_Status__c == 'Expired'){ o.StageName ='Expired'; } else if(o.Application_Status__c == 'Closed'){ o.StageName ='Closed Won'; } else if(o.Application_Status__c == 'Cancelled'){ o.StageName ='Cancelled'; } else if(o.Application_Status__c == 'DocsSent'){ o.StageName ='Approved - Final'; } else if(o.Application_Status__c == 'Not Submitted'){ o.StageName ='EXCLUDE FROM FILE'; } else if(o.Application_Status__c == 'Pending'){ o.StageName ='Application Submitted'; } else if(o.Application_Status__c == 'Submitted'){ o.StageName ='Application Submitted'; } else if(o.Application_Status__c == 'Unprocessed'){ o.StageName ='Application Submitted'; } else if(o.Application_Status__c == 'Null'){ o.StageName ='Error'; } System.debug('Opp trigger is fired. '); System.debug(o); /*Date appSubmittedDate = o.Application_Submitted__c; String strAppSubmittedDate = appSubmittedDate.month()+'-'+appSubmittedDate.day()+'-'+appSubmittedDate.year(); Property__c prop = [Select Property_Code__c From Property__c Where id =:o.Property_Name__c]; //Property_Name__c is returning id of related Property that's why used it's value to find Property Code. Account acc = [Select LastName From Account Where id =:o.AccountId]; //AccountId is returning id of related Account that's why used it's value to find Account's LastName. //o.Name = strAppSubmittedDate; o.Name =acc.LastName+'-'+prop.Property_Code__c+'-'+strAppSubmittedDate; //o.Name =acc.LastName+'-'+prop.Property_Code__c+'-'+String.valueOf(o.Application_Submitted__c); //*/ for(ID acctID :acctMap.keySet()){ if(o.AccountID == acctID){ tempOppName = acctMap.get(acctID).LastName; } } for(ID propID :propMap.keySet()){ if(o.Property_Name__c == propID){ tempOppName =tempOppName + '-' + propMap.get(propID).Property_Code__c; } } Date appSubmittedDate = o.Application_Submitted__c; String strAppSubmittedDate = appSubmittedDate.month()+'-'+appSubmittedDate.day()+'-'+appSubmittedDate.year(); o.Name = tempOppName + '-' + strAppSubmittedDate; Id trigRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Sun Homes - BDS').getRecordTypeId(); o.RecordTypeId = trigRecordTypeId; } } ,但输出显示该元素相对于屏幕旋转。

这是我的codepen演示:Demo

&#13;
&#13;
transform-origin: center center;
&#13;
.windmill {
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform-origin: 51% 65%;
      -moz-transform-origin: 51% 65%;
    -webkit-animation: clockwise 1s infinite linear;
    -moz-animation: clockwise 1s infinite linear;
    animation: clockwise 1s infinite linear;
}
@-moz-keyframes clockwise {
    0% {
        -moz-transform: rotate(0deg);
    }
    100% {
        -moz-transform: rotate(360deg);
    }
}
@keyframes clockwise {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

让它适用于chrome和firefox。

我使用了SMIL动画并相应地更新了插图画家的坐标。

<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" width="221.148" height="166.612" viewBox="0 0 221.148 166.612">
  <g id="arrow-1" class="windmill">
    
       <animateTransform attributeName="transform"
            type="rotate"
            from="0 45.241 45.728"
            to="360 45.241 45.728"
            begin="0s"
            dur="0.85s"
            repeatCount="indefinite"
        />
   
    <path id="square-1" fill="none" d="M.206 29.478L60.98.508l29.3 61.465-60.775 28.97z"/>
    <path fill="#3F3939" d="M40.704 31.057c5.67 11.896 4.262 14.858 4.262 14.858s-3.188-.77-8.858-12.667c-5.67-11.896-5.737-17.953-5.737-17.953s4.664 3.867 10.334 15.762zM59.514 51.14c-12.967-2.353-14.547-5.226-14.547-5.226s2.49-2.137 15.456.213c12.967 2.35 17.922 5.834 17.922 5.834s-5.863 1.527-18.83-.82zM35.644 58.245c6.108-11.677 9.322-12.328 9.322-12.328s1.3 3.013-4.81 14.69C34.048 72.28 29.243 75.97 29.243 75.97s.29-6.05 6.4-17.727z"/>
  </g>
  <g id="arrow-2" class="windmill">
    
      <animateTransform attributeName="transform"
            type="rotate"
            from="0 113 60"
            to="360 113 60"
            begin="0s"
            dur="0.85s"
            repeatCount="indefinite"
        />
  
    <path id="square-2" fill="none" d="M130.09 15.666l29.064 60.727-61.418 29.394L68.672 45.06z"/>
    <path fill="#3F3939" d="M128.57 56.168c-11.887 5.688-14.852 4.285-14.852 4.285s.767-3.19 12.654-8.878c11.887-5.688 17.943-5.765 17.943-5.765s-3.858 4.67-15.745 10.358z"/>
    <path fill="#3F3939" d="M108.52 75.01c2.33-12.972 5.2-14.557 5.2-14.557s2.14 2.485-.188 15.456c-2.33 12.97-5.807 17.93-5.807 17.93s-1.534-5.86.794-18.83zM101.375 51.15c11.688 6.09 12.343 9.303 12.343 9.303s-3.01 1.305-14.696-4.787c-11.686-6.09-15.383-10.89-15.383-10.89s6.048.283 17.735 6.374z"/>
  </g>
  <g id="arrow-3" class="windmill">
    <animateTransform attributeName="transform"
            type="rotate"
            from="0 175 45"
            to="360 175 45"
            begin="0s"
            dur="0.85s"
            repeatCount="indefinite"
        />
    <path id="square-3" fill="none" d="M192.09-.004l29.064 60.727-61.417 29.395-29.064-60.727z"/>
    <path fill="#3F3939" d="M190.57 40.5c-11.887 5.69-14.852 4.286-14.852 4.286s.767-3.19 12.654-8.878c11.887-5.688 17.943-5.765 17.943-5.765s-3.858 4.67-15.745 10.358z"/>
    <path fill="#3F3939" d="M170.52 59.342c2.33-12.97 5.2-14.556 5.2-14.556s2.14 2.485-.188 15.456c-2.328 12.97-5.807 17.93-5.807 17.93s-1.534-5.858.794-18.83zM163.375 35.483c11.688 6.09 12.343 9.303 12.343 9.303s-3.01 1.305-14.696-4.787c-11.686-6.09-15.383-10.89-15.383-10.89s6.048.282 17.735 6.373z"/>
  </g>
  <path fill="#FFF" d="M42.682 46.192l-1.34 118.978h3.57V46.192z"/>
  <path fill="#8CC4C8" d="M47.143 46.192h-2.23V165.17h3.57z"/>
  <path fill="#608B94" d="M41.343 45.448c0-1.97 1.6-3.568 3.57-3.568v-1.637c-2.875 0-5.206 2.33-5.206 5.205 0 2.876 2.33 5.207 5.205 5.207v-1.637c-1.97 0-3.57-1.6-3.57-3.57z"/>
  <path fill="#80ADB8" d="M44.912 40.243v1.637c1.973 0 3.57 1.598 3.57 3.568 0 1.972-1.597 3.57-3.57 3.57v1.637c2.875 0 5.206-2.33 5.206-5.207 0-2.875-2.33-5.205-5.206-5.205z"/>
  <path fill="#8CC4C8" d="M44.912 49.018c1.973 0 3.57-1.6 3.57-3.57h-7.14c0 1.97 1.6 3.57 3.57 3.57z"/>
  <path fill="#FFF" d="M44.912 41.88c-1.97 0-3.57 1.597-3.57 3.567h7.14c0-1.97-1.597-3.568-3.57-3.568z"/>
  <path fill="#4F9599" d="M37.81 162.82h13.835v3.792H37.81z"/>
  <path fill="#FFF" d="M173 46.192l-1.338 118.978h3.57V46.192z"/>
  <path fill="#8CC4C8" d="M177.462 46.192h-2.23V165.17h3.57z"/>
  <path fill="#608B94" d="M171.662 45.448c0-1.97 1.6-3.568 3.57-3.568v-1.637c-2.875 0-5.206 2.33-5.206 5.205 0 2.876 2.33 5.207 5.205 5.207v-1.637c-1.97 0-3.568-1.6-3.568-3.57z"/>
  <path fill="#80ADB8" d="M175.23 40.243v1.637c1.974 0 3.57 1.598 3.57 3.568 0 1.972-1.597 3.57-3.57 3.57v1.637c2.876 0 5.207-2.33 5.207-5.207 0-2.875-2.33-5.205-5.206-5.205z"/>
  <path fill="#8CC4C8" d="M175.23 49.018c1.974 0 3.57-1.6 3.57-3.57h-7.14c.002 1.97 1.6 3.57 3.57 3.57z"/>
  <path fill="#FFF" d="M175.23 41.88c-1.97 0-3.568 1.597-3.568 3.567h7.14c0-1.97-1.598-3.568-3.57-3.568z"/>
  <path fill="#4F9599" d="M168.13 162.82h13.834v3.792H168.13z"/>
  <g>
    <path fill="#FFF" d="M111.74 61.184l-1.15 102.293h3.068V61.184z"/>
    <path fill="#8CC4C8" d="M115.576 61.184h-1.918v102.293h3.07z"/>
    <path fill="#608B94" d="M110.59 60.545c0-1.695 1.374-3.07 3.068-3.07V56.07c-2.47 0-4.475 2.003-4.475 4.476 0 2.472 2.004 4.475 4.475 4.475v-1.405c-1.694 0-3.068-1.375-3.068-3.07z"/>
    <path fill="#80ADB8" d="M113.658 56.07v1.406c1.696 0 3.07 1.374 3.07 3.07 0 1.693-1.374 3.067-3.07 3.067v1.406c2.473 0 4.477-2.004 4.477-4.476 0-2.47-2.004-4.475-4.477-4.475z"/>
    <path fill="#8CC4C8" d="M113.658 63.614c1.696 0 3.07-1.374 3.07-3.068h-6.14c.002 1.694 1.376 3.068 3.07 3.068z"/>
    <path fill="#FFF" d="M113.658 57.476c-1.694 0-3.068 1.374-3.068 3.07h6.14c0-1.696-1.376-3.07-3.072-3.07z"/>
    <path fill="#4F9599" d="M107.552 161.458h11.894v3.26h-11.894z"/>
  </g>
</svg>