Closed Bug 1340438 Opened 7 years ago Closed 5 years ago

SVG elements shift when performing a rotation with absolute transform-origin

Categories

(Core :: SVG, defect, P3)

51 Branch
defect

Tracking

()

RESOLVED DUPLICATE of bug 1561225

People

(Reporter: paul.lebeau, Unassigned)

References

()

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

Steps to reproduce:

1. Try the following link (or see demo see files below) https://jsfiddle.net/n9v54nro/2/

2. Hover over red rectangle



Actual results:

"Door" jumps downwards by one unit before rotating


Expected results:

"Door" should rotate around transform origin (green dot).  This test case works correctly in Chrome.


===== Demo files =======

  <svg width="500" height="500" viewBox="105 125 20 20" id="svg">
    <g id="ground">
      <!-- ROOM OUTLINE -->
      <path class="o-whole" d="M 108.5,120 v 10" />
      <!-- ROOM FILL -->
      <rect id="g-f-construction-shop" class="f" width="109" height="200"/>
      <!-- DOOR -->
      <path
         id="g-o-construction-shop-stage-one-door-right-top"
         class="door o-door-right-top"
         style="transform-origin:108.5px 130.5px;"
         d="m 108,130.5 h 5.99996"
      />
      <circle cx="108.5" cy="130.5" r="0.2" fill="limegreen"/>
    </g>
  </svg>


var room = document.getElementById('g-f-construction-shop');

room.addEventListener('mouseenter', function animateDoors() {
  var doorElement = document.getElementById('g-o-construction-shop-stage-one-door-right-top');
  doorElement.style.transform = 'rotate(90deg)';
    
  setTimeout(function () {
    doorElement.style.transform = 'rotate(0)';
  }, 750);
});


.o-whole, .door {
  stroke: #000;
  fill: none;
  opacity: 1;
}
  
.f {
  fill: #ff6600;
  opacity: 0.1;
}
  
.o-door-right-top {
  transition: transform 0.75s;
}
OS: Unspecified → Windows 7
Hardware: Unspecified → x86_64
The animation is unnecessary. The difference is between 

doorElement.style.transform = 'rotate(0deg)';

and

doorElement.style.transform = 'none';
https://www.w3.org/TR/css-transforms-1/#svg-transform-functions suggests that rotate potentially messes with the transform-origin so maybe the transform-origin is being overwritten for SVG content somehow? For SVG content the transform-origin default is 0, 0, which is different to html.
it's noteworthy to point out that vertical paths shift horizontally, and vice-versa; thus horizontal paths shift vertically.

from my own experience, vertical paths always shift to the right, and horizontal paths always shift downwards. also, i'm fairly certain that they shift by HALF A UNIT, not a whole unit.
here is an elaborate jsfiddle to demonstrate the direction of shifting: https://jsfiddle.net/tygeonnm/
Component: Untriaged → SVG
Product: Firefox → Core
Priority: -- → P3
@Jet Villegas I'm assuming P3 is the priority level? What are the diff levels?

The cause is a decimal value in the path 130.5 during animation, the problem disappears if it's an integer.

This is essentially a dup of Bug 1561225. Without WebRender, it's easy to fix; but the WebRender is much worse, it seems as if a filter is applied from nowhere.

Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
OS: Windows 7 → Unspecified
Hardware: x86_64 → Unspecified
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.