I see there is x-axis and y-axis for shifting position by a percentage of div width/height, but it does not seem to be working. Can you see if I'm doing anything wrong in my code?
The x-axis
and y-axis
properties don't seem to be working when clip is enabled. I'll work on fixing that.
I'm using the beta ts-overlay-widget and what I'm trying to do is be able to scale my spine character based on the percentage of the div height
Currently, there's no attribute to achieve that. I'd suggest surrounding the hosting div with another one and adding padding to it. If you prefer not to do that, you can accomplish it with some code, but the first approach is definitely easier.
I'll offer some advice. You're using mode="origin". This means you're in free mode, where the widget simply centers the skeleton within the parent container. Positioning the skeleton in this way can be quite complicated.
If you instead use mode="inside"
(the default mode, so no need to set it) and set fit="none"
, the widget centers the skeleton using the bounds
object. This object is a rectangle with x, y, width, and height properties. The bounds are used to determine the position and scale for the skeleton. Note that bounds use the skeleton's world coordinates/size.
By default, it's sized using the given skin and animation. The widget uses fit="contain"
as default: this ensures the bounds are scaled as large as possible while still being entirely contained within the element container.
From what I understand, your goal is to link the skeleton's scale (scaleX
and scaleY
) to half of the div's width and height (likely the smaller one to avoid stretching). This means you want the bounds to be sized as half of the div's width and height.
Since the div size might change, you should do this continuously. You can implement all of this in the widget's beforeUpdateWorldTransforms
method, ensuring that if the div changes size, it will be correctly rescaled accordingly.
Since the CSS approach is quite straightforward, I don't think we need an additional feature for this. However, I might not have fully understood your goal. Indeed, your last message about scaling bigger for a clipped zoomed-in effect
confused me a bit.
Perhaps you could explain your final goal better or share some images illustrating it? If it proves to be useful, we might consider adding a new feature to support that.