I've been Working on a breadcrumbs directory feature recently that requires an element to rotate based on the cursor x position within the breadcrumbs container element. Long story short, I need the arrow in the lower '#pointer-box' to always point at the cursor when it's within the '#target-box'.
I'm looking for two separate formulas that will a.) set the initial left-most position of the arrow when the '#target-box' cursor x position is at 0, and b.) keep the arrow's left-most and right-most rotation properties proportional at any browser width or on window resize.
Any help is greatly appreciated.
Here's the live demo. http://jsfiddle.net/HeFqh/
Thank you
Update
With help from Tats_innit I was able to get the arrow pointing at the cursor when it's inside the '#target-box'. Now I have two specific issues to solve.
a.) When the window is resized the arrow and cursor are no longer aligned.
b.) The 'var y' on 'mousemove' is not deducting the top offset
var y = e.pageY - this.offsetTop
The updated live demo. http://jsfiddle.net/HeFqh/11/
Thank you
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…