# Khan/khan-exercises

```fix #11155; fix #11159; fix #11178
close #11149; close #11167```
1 parent 1770356 commit 64c5817391863fdb446eb783a8f85111287acde5 beneater committed Jan 13, 2012
Showing with 18 additions and 14 deletions.
1. +4 −4 exercises/telling_time_2.html
2. +14 −10 utils/interactive.js
8 exercises/telling_time_2.html
 @@ -2,7 +2,7 @@ - Setting time + Telling time 2 @@ -12,9 +12,9 @@
- randRange( 1, 12 ) - 15 - randRange( 0, (60 / MINUTE_INCREMENT) - 1 ) * MINUTE_INCREMENT + randRange( 1, 12 ) + 15 + randRange( 0, (60 / MINUTE_INCREMENT) - 1 ) * MINUTE_INCREMENT
MINUTE === 0 MINUTE > 5 ? MINUTE : "0" + MINUTE
24 utils/interactive.js
 @@ -321,6 +321,18 @@ jQuery.extend( KhanUtil, { mouseY = Math.round(mouseY / (graph.scale[1] * movablePoint.snapY)) * (graph.scale[1] * movablePoint.snapY); } + // coord{X|Y} are the scaled coordinate values + var coordX = mouseX / graph.scale[0] + graph.range[0][0]; + var coordY = graph.range[1][1] - mouseY / graph.scale[1]; + + // snap coordinates to grid + if ( movablePoint.snapX !== 0 ) { + coordX = Math.round( coordX / movablePoint.snapX ) * movablePoint.snapX; + } + if ( movablePoint.snapY !== 0 ) { + coordY = Math.round( coordY / movablePoint.snapY ) * movablePoint.snapY; + } + // snap to points around circle if ( movablePoint.constraints.fixedDistance.snapPoints ) { @@ -351,18 +363,10 @@ jQuery.extend( KhanUtil, { // convert back to coordinates relative to graphie canvas mouseX = mouseXrel + centerX; mouseY = - mouseYrel + centerY; + coordX = KhanUtil.roundTo( 5, mouseX / graph.scale[0] + graph.range[0][0] ); + coordY = KhanUtil.roundTo( 5, graph.range[1][1] - mouseY / graph.scale[1] ); } - // coord{X|Y} are the scaled coordinate values - var coordX = mouseX / graph.scale[0] + graph.range[0][0]; - var coordY = graph.range[1][1] - mouseY / graph.scale[1]; - // snap coordinates to grid - if ( movablePoint.snapX !== 0 ) { - coordX = Math.round( coordX / movablePoint.snapX ) * movablePoint.snapX; - } - if ( movablePoint.snapY !== 0 ) { - coordY = Math.round( coordY / movablePoint.snapY ) * movablePoint.snapY; - } // apply any constraints on movement var coord = movablePoint.applyConstraint([ coordX, coordY ]); coordX = coord[0];