How to solve the problem fixative block when scrolling?

There block1, which is fixed when you scroll the page, it works correctly until, until you click the switch, and does not appear block2. After appeared block2, block1, which is triggered early and it turns out that block1 is jumping.
https://jsfiddle.net/g9snennj/2/
June 8th 19 at 16:49

Find more questions by tags CSSHTMLjQuery