When using primitiveUnits="objectBoundingBox"
with a SVG filter and animating a child outside the bounding box, the representation of the filter jumps when the animation is done. In the example below this is shown by the gap between the two boxes (one is a clone of the other).
Is there a way to prevent this and enforce overflow:none
?
(There is no jump, as the animation is inifinite. To test, remove the id #animate
: The two boxes will then be next to one another.)
#container {
filter: url(#offset);
width: 120px;
height: 80px;
border: 1px solid #000;
overflow: hidden;
}
#animate {
animation: move_in 3s linear reverse infinite;
}
@keyframes move_in {
100% {
transform: translateX(-50%);
}
}
svg {
display: none:
}
<div id="container">
<div id="animate" >Test</div>
<div>Test 2</div>
</div>
<svg xmlns="http://www.w3.org/2000/svg">
<filter id="offset" primitiveUnits="objectBoundingBox" width="200%" height="100%" x="0" y="0" color-interpolation-filters="sRGB">
<feOffset result="SourceGraphicOffset" in="SourceGraphic" dx="1" dy="0" />
<feMerge>
<feMergeNode in="SourceGraphic" />
<feMergeNode in="SourceGraphicOffset" />
</feMerge>
</filter>
</svg>
EDIT: Added two screenshots depicting snippet (as some browsers seem to displaying it differently).