Vision system.gui.transform not working as intended for anchored component


I have a Container that I use to “fly in” on a button click. The Container start just off screen on either left or right side and then animates moving into the page to sit when a docked window would sit against the left or right window edge. This relies on the component to be anchored.
Everything works fine flying it in from left to right, with the Container anchoring set to top, left, bottom. However when I try to use the same script (modified only to move it left instead of right) with a Container from the right side flying in to the left, it’s very unhappy and the new x position that it’s set to is wildy out of whack… See below.

This is the script I’m using:

# when the 'show' parameter is modified e.g. the user adds new tags, fly the tag browser container in and out with animation
if event.propertyName == 'show':
	duration = 500 #animation duration in ms
	obj = event.source
	obj.visible = 1 
	size = obj.getSize()
	pos = obj.getLocation()
	print "pos = ", pos
	print "size = ", size
	new_size = size
	new_pos = pos
	accel = system.gui.ACCL_FAST_TO_SLOW
	if == 1:
		new_pos.x = pos.x - size.width # change this "-" to a "+" for container on right side
		new_pos.x = pos.x + size.width # change this "+" to a "-" for container on right side
	print "new_pos = ", new_pos
	# use in the callback function of the animation function to hide the tag browser when it's off screen / should be hidden	
	def setVisible():
		obj.visible =
	system.gui.transform(obj, new_pos.x, None, None, None, duration, setVisible, 60, accel)

Fly-in from left of page to right (working):

original size:  java.awt.Dimension[width=311,height=714]
original pos (offscreen):  java.awt.Point[x=-311,y=-1]
# fly into page from left to left sidebar
pos =  java.awt.Point[x=-311,y=-1]
size =  java.awt.Dimension[width=311,height=714]
new_pos =  java.awt.Point[x=0,y=-1]
# fly out of page moving left
pos =  java.awt.Point[x=-79,y=-1]
size =  java.awt.Dimension[width=311,height=714]
new_pos =  java.awt.Point[x=-390,y=-1]

Fly-in from right side of page to left (not working as intended, top right bottom anchoring):

# note: the lines in the script are modified to:
if == 1:
		new_pos.x = pos.x + size.width
		new_pos.x = pos.x - size.width
original size:  java.awt.Dimension[width=311,height=714]
original pos (offscreen):  java.awt.Point[x=2540,y=-1]
# fly into page from right to left sidebar
pos =  java.awt.Point[x=2540,y=-1]
size =  java.awt.Dimension[width=311,height=714]
new_pos =  java.awt.Point[x=2229,y=-1] # <=== new pos is correct
# fly back out of page moving right
pos =  java.awt.Point[x=3403,y=-1] #<=== new pos from above was not correctly written to component pos???
size =  java.awt.Dimension[width=311,height=714]
new_pos =  java.awt.Point[x=3714,y=-1]

It looks like the new_pos value is correct in its calculation, but when it’s set to the x position of the component, something happens to it, and the new component position is moved to the right instead of to the left (i.e. to position 3403 instead of 2229). Does this have something to do with the layout? How can I get this to behave as intended?

To note: it works properly in the Designer, below, but not in any client

Designer from left:

Designer from right:

Have you tried playing around with the coordSpace argument?

I just tried both, system.gui.COORD_SCREEN and system.gui.COORD_DESIGNER, with no luck :frowning:

Hardcode the new_pos.x value for showing and not showing with the ones from the designer. Then use coordSpace = 1
No need to mess around with the size/pos during runtime.

I’d much rather use the dynamic size/pos so that I can simply copy and paste for other components (or create a script library to use, which is what I should do). It’s far simpler to maintain as well and means I don’t need to worry about it if I change the container size in the future.

For the record though, this does work if I hardcode pos x and y and use the Designer space.

You can upload the project. I want to do the same thing. thanks

You already have the script I’m using, you should be able to use this on your own component with some tweaks.