Skip to content

Commit

Permalink
Remove redundant 'equal to' comparison in ViewPort.ValidateView met…
Browse files Browse the repository at this point in the history
…hods. (gdamore#557)

The 'equal to' comparisons in the `ViewPort.ValidateViewX()` and `ViewPort.ValidateViewY()` methods are not required as the `ViewPort`s corresponding `view` attributes will be set equal to the right operand if the conditional resolves as true. The current behaviour results in the `view` attributes being set unnecessarily if it already equals the limit.
  • Loading branch information
chrBrd committed Sep 11, 2022
1 parent a8322bf commit eef35d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions views/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (v *ViewPort) MakeVisible(x, y int) {
// ValidateViewY ensures that the Y offset of the view port is limited so that
// it cannot scroll away from the content.
func (v *ViewPort) ValidateViewY() {
if v.viewy >= v.limy-v.height {
if v.viewy > v.limy-v.height {
v.viewy = (v.limy - v.height)
}
if v.viewy < 0 {
Expand All @@ -157,7 +157,7 @@ func (v *ViewPort) ValidateViewY() {
// ValidateViewX ensures that the X offset of the view port is limited so that
// it cannot scroll away from the content.
func (v *ViewPort) ValidateViewX() {
if v.viewx >= v.limx-v.width {
if v.viewx > v.limx-v.width {
v.viewx = (v.limx - v.width)
}
if v.viewx < 0 {
Expand Down

0 comments on commit eef35d4

Please sign in to comment.