We were basing Followers on the local offset of the Leader, which worked in demos where the Leader happened to base its position on the screen's (0,0). However, when a Leader is positioned in a Scrollable, the Leader's origin changes relative to the screen, which resulted in bad Follower positions.
This PR uses LeaderLink.offset, which is the Leader's global offset, instead of LeaderLink.leader.offset, which is local.
Maybe we should also define LeaderLink.leader.globalOffset and get rid of LeaderLink.offset.
This PR makes the Follower widget as large as possible, even when its child is smaller. This is because I discovered that hit testing will only be attempted when the cursor is over the area that Flutter thinks the Follower occupies. So the follower content can be small, but the Follower widget needs to take up all possible area where the Leader might reside. This change also required that we pass the childRenderObject to the boundary and aligner, instead of the Follower, because the Follower's size no longer reflects the size of its content.
This PR also adds a few tests, though there are many situations that remain untested.
Follow within Scrollables (Resolves #17)
We were basing
Follower
s on the local offset of theLeader
, which worked in demos where theLeader
happened to base its position on the screen's (0,0). However, when aLeader
is positioned in aScrollable
, theLeader
's origin changes relative to the screen, which resulted in badFollower
positions.This PR uses
LeaderLink.offset
, which is theLeader
's global offset, instead ofLeaderLink.leader.offset
, which is local.Maybe we should also define
LeaderLink.leader.globalOffset
and get rid ofLeaderLink.offset
.This PR makes the
Follower
widget as large as possible, even when itschild
is smaller. This is because I discovered that hit testing will only be attempted when the cursor is over the area that Flutter thinks theFollower
occupies. So the follower content can be small, but theFollower
widget needs to take up all possible area where theLeader
might reside. This change also required that we pass thechild
RenderObject
to the boundary and aligner, instead of theFollower
, because theFollower
's size no longer reflects the size of its content.This PR also adds a few tests, though there are many situations that remain untested.