I'm sure you have a minimal sketch that demonstrates this. Please share it with us (don't forget to use code tags as described in How to get the best out of this forum).
I'm also sure that you have a schematic diagram or wiring diagram; please share it. If not, please create one (photo of pencil/paper drawing is fine).
And lastly please share a link (URL) of the encoder.
Note:
If this is a hardware problem in the encoder, no library will help you to solve it.