Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions spotlight/src/main/java/com/takusemba/spotlight/SpotlightView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,14 @@ internal class SpotlightView @JvmOverloads constructor(
removeAllViews()
addView(target.overlay, MATCH_PARENT, MATCH_PARENT)
this.target = target.apply {
// adjust anchor in case where custom container is set.
val location = IntArray(2)
getLocationInWindow(location)
val offset = PointF(location[0].toFloat(), location[1].toFloat())
anchor.offset(-offset.x, -offset.y)
if (!this.isAnchorAdjusted) {
// adjust anchor in case where custom container is set.
val location = IntArray(2)
getLocationInWindow(location)
val offset = PointF(location[0].toFloat(), location[1].toFloat())
anchor.offset(-offset.x, -offset.y)
this.isAnchorAdjusted = true
}
}
this.shapeAnimator?.removeAllListeners()
this.shapeAnimator?.removeAllUpdateListeners()
Expand Down
4 changes: 4 additions & 0 deletions spotlight/src/main/java/com/takusemba/spotlight/Target.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class Target(
val overlay: View?,
val listener: OnTargetListener?
) {
/**
* This variable is to prevent multiple times anchor adjustment.
*/
var isAnchorAdjusted: Boolean = false

/**
* [Builder] to build a [Target].
Expand Down