github.com/jmigpin/editor@v1.6.0/util/uiutil/mousefilter/misc.go (about)

     1  package mousefilter
     2  
     3  import "image"
     4  
     5  func DetectMove(press, p image.Point) bool {
     6  	r := image.Rectangle{press, press}
     7  	// padding to detect intention to move/drag
     8  	v := 3
     9  	r = r.Inset(-v) // negative inset (outset)
    10  	return !p.In(r)
    11  }
    12  
    13  func DetectMovePad(p, press, ref image.Point) image.Point {
    14  	u := ref.Sub(p)
    15  	v := 3 + 2 // matches value in DetectMove()+2
    16  	if u.X > v || u.X < -v {
    17  		u.X = 0
    18  	}
    19  	if u.Y > v || u.Y < -v {
    20  		u.Y = 0
    21  	}
    22  	return u
    23  }