ctrlutil.go
func ItemByThumbPosition(position, itemCount, length int) int {
	length -= 2
	if position < 1 {
		return -1
	}
	if itemCount < 1 {
		return -1
	}
	if itemCount == 1 {
		return 0
	}

	newPos := int(float32(itemCount-1)*float32(position-1)/float32(length-1) + 0.9)

	if newPos < 0 {
		newPos = 0
	} else if newPos >= itemCount {
		newPos = itemCount - 1
	}

	return newPos
}
func ItemByThumbPosition(position, itemCount, length int) int {
	length -= 2
	if position < 1 {
		return -1
	}
	if itemCount < 1 {
		return -1
	}
	if itemCount == 1 {
		return 0
	}

	newPos := int(float32(itemCount-1)*float32(position-1)/float32(length-1) + 0.9)

	if newPos < 0 {
		newPos = 0
	} else if newPos >= itemCount {
		newPos = itemCount - 1
	}

	return newPos
}
func ItemByThumbPosition ( position , itemCount , length int ) int { length -= 2 if position < 1 { return - 1 } if itemCount < 1 { return - 1 } if itemCount == 1 { return 0 } newPos := int ( float32 ( itemCount - 1 ) * float32 ( position - 1 ) / float32 ( length - 1 ) + 0.9 ) if newPos < 0 { newPos = 0 } else if newPos >= itemCount { newPos = itemCount - 1 } return newPos }
// ItemByThumbPosition calculates item number by scrollbar
// thumb position. Position - thumb position inside scrollbar,
// itemCount - total number of items, lenght - lenght or heigth
// of scrollbar. Return -1 if it is not possible to calculate:
// e.g, itemCount equals zero
ItemByThumbPosition calculates item number by scrollbar thumb position . Position - thumb position inside scrollbar itemCount - total number of items lenght - lenght or heigth of scrollbar . Return - 1 if it is not possible to calculate : e . g itemCount equals zero