javascript - Coding a volume bar -
i'm trying code progress bar in js.
i have bar coded have problems math work correctly. when user clicks on bar i'm grabbing pixel position click on...this working correctly. bar 80px wide , if click in middle clicked value returns @ 40...if click right @ end of bar 80.
so thought needed divide click position total width of bar , times total volume...which 100...
so clicking in middle of bar : 40 / 80 = 0.5. correct...the user has clicked halfway 0.5 makes sense....but if times 100 gives me 50 obviously...which isn't right...if scenario user has clicked full volume 80 / 80 = 1 * 100 = 100
what calculation need make working?
why isn't 50 correct? said volume out of 100. 50 50% of 100, 50% of progress bar, halfway. makes perfect sense me.
Comments
Post a Comment