Fix for rotate from 0deg

This patch causes rotate to use numerical interpolation when either from or to angle is 0deg.

The axis of rotation used will be the axis that has a non-zero angle. If both from and to axis are both zero, then the default (0, 0, 1) axis is used.

Patch by soonm@google.com

BUG=516577

Review URL: https://codereview.chromium.org/1322843002

git-svn-id: svn://svn.chromium.org/blink/trunk@201583 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7c8fbb19
......@@ -104,7 +104,7 @@ assertInterpolation({
from: '0deg 1 0 0',
to: '10deg 0 1 0',
}, [
{at: -1, is: '10deg 0 -1 0'},
{at: -1, is: '-10deg 0 1 0'},
{at: 0, is: '0deg 1 0 0'},
{at: 0.25, is: '2.5deg 0 1 0'},
{at: 0.75, is: '7.5deg 0 1 0'},
......@@ -125,4 +125,29 @@ assertInterpolation({
{at: 2, is: '90deg 0.71 0 -0.71'},
]);
assertInterpolation({
property: 'rotate',
from: '0deg 0 1 0',
to: '450deg 1 0 0',
}, [
{at: -1, is: '-450deg 1 0 0'},
{at: 0, is: '0deg 0 1 0'},
{at: 0.25, is: '112.5deg 1 0 0'},
{at: 0.75, is: '337.5deg 1 0 0'},
{at: 1, is: '450deg 1 0 0'},
{at: 2, is: '900deg 1 0 0'},
]);
assertInterpolation({
property: 'rotate',
from: '450deg 1 0 0',
to: '0deg 0 1 0',
}, [
{at: -1, is: '900deg 1 0 0'},
{at: 0, is: '450deg 1 0 0'},
{at: 0.25, is: '337.5deg 1 0 0'},
{at: 0.75, is: '112.5deg 1 0 0'},
{at: 1, is: '0deg 0 1 0'},
{at: 2, is: '-450deg 1 0 0'},
]);
</script>
<!DOCTYPE html>
<style>
div {
position: absolute;
width: 100px;
height: 100px;
rotate: 225deg 1 0 0;
}
#target {
border-color: green;
border-style: dotted dashed solid double;
}
</style>
<div id="target"></div>
<script>
</script>
<!DOCTYPE html>
<style>
div {
position: absolute;
width: 100px;
height: 100px;
}
#target {
border-color: green;
border-style: dotted dashed solid double;
}
</style>
<div id="target"></div>
<script>
var keyframes = [{ rotate: '0deg 0 1 0' }, { rotate: '450deg 1 0 0'}]
var animation = target.animate(keyframes, { duration: 2000 });
animation.pause();
animation.currentTime = 1000;
</script>
......@@ -45,8 +45,8 @@ bool RotateTransformOperation::shareSameAxis(const RotateTransformOperation* fro
if (!from && !to)
return true;
bool fromZero = !from || from->axis().isZero();
bool toZero = !to || to->axis().isZero();
bool fromZero = !from || from->axis().isZero() || fabs(from->angle()) < angleEpsilon;
bool toZero = !to || to->axis().isZero() || fabs(to->angle()) < angleEpsilon;
if (fromZero && toZero)
return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment