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

v7.9.12

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 obj.show == 1:
		new_pos.x = pos.x - size.width # change this "-" to a "+" for container on right side
	else:
		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 = obj.show
	
	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 obj.show == 1:
		new_pos.x = pos.x + size.width
	else:
		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:
https:/uploads/iatesting/original/2X/5/5d97f1625420e10157c451a44e6c687f9a125e14.mp4

Designer from right:
https:/uploads/iatesting/original/2X/0/080eac4ee0d552ca601df9d47cabaaf3781fe0d3.mp4

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.