-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a bug where line-ending arrows would flip around or vanish #1263
Conversation
Math.abs(xAtYMin) is not the right way to fix the -Infinity issue - it results in the line going off the edge of the graph when the graph has a nonsquare range like [[-10,1],[-10,10]].
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (68ae088) and published it to npm. You Example: yarn add @khanacademy/perseus@PR1263 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR1263 |
Size Change: +474 B (+0.06%) Total Size: 836 kB
ℹ️ View Unchanged
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1263 +/- ##
==========================================
+ Coverage 69.08% 69.90% +0.82%
==========================================
Files 472 476 +4
Lines 101103 101283 +180
Branches 7216 10856 +3640
==========================================
+ Hits 69843 70802 +959
+ Misses 31082 30481 -601
+ Partials 178 0 -178
... and 144 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels much more clear now and needs less complex calculations (the clock analogy). Thanks!
* @param initialPoint - A point that the ray passes through. Must be different from initialPoint. | ||
* @param throughPoint - The starting point of the ray. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This re-arrangement of comments feels like the descriptions now directly conflict with the parameter name.
@param throughPoint - The starting point of the ray
So it's not a through point but a starting point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
@@ -148,10 +148,10 @@ const Line = (props: LineProps) => { | |||
if (extend) { | |||
const trimmedRange = trimRange(range, graphDimensionsInPixels); | |||
startExtend = extend.start | |||
? getIntersectionOfRayWithBox(start, end, trimmedRange) | |||
? getIntersectionOfRayWithBox(end, start, trimmedRange) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related to this PR, but Nisha recently changed the locked line component to simply use point1
and point2
for lines. This feels like it might be applicable for the MovableLine
component(s) as well as for line and ray they don't really have a start/end but rather two points that the line/ray intersect. 🤔
For a future PR if you agree.
default: | ||
return [xMax, yAtXMax]; | ||
return [0, 0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this basically stating that we'll never hit this default
? If so, could you comment on that as I might be confused for a bit if I arrived at this line of code without having read this PR or surrounding code.
// 6 o'clock to 8:59 | ||
case yDiff < 0 && xDiff <= 0: | ||
return xAtYMin < xMin ? [xMin, yAtXMin] : [xAtYMin, yMin]; | ||
// does the ray intersect the left or right edge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's obvious to others, but this is:
// does the ray intersect the left or right edge? | |
// does the ray intersect the left or right edge within the y graph range? |
right?
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @khanacademy/math-input@19.1.0 ### Minor Changes - [#1259](#1259) [`c07644f63`](c07644f) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Update all Perseus peer dependencies to match webapp exactly (commit: 2bd290251a8) - @khanacademy/wonder-blocks-clickable v4.2.1 - @khanacademy/wonder-blocks-core v6.4.0 - @khanacademy/wonder-blocks-popover v3.2.2 - @khanacademy/wonder-blocks-timing v5.0.0 - @khanacademy/wonder-blocks-tokens v1.3.0 - @khanacademy/wonder-stuff-core v1.5.2 - aphrodite v1.2.5 - katex v0.11.1 - react v16.14.0 - react-router v5.2.1 - react-router-dom v5.3.0 ## @khanacademy/perseus@22.5.0 ### Minor Changes - [#1259](#1259) [`c07644f63`](c07644f) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Update all Perseus peer dependencies to match webapp exactly (commit: 2bd290251a8) - @khanacademy/wonder-blocks-banner v3.0.42 - @khanacademy/wonder-blocks-button v6.3.1 - @khanacademy/wonder-blocks-clickable v4.2.1 - @khanacademy/wonder-blocks-core v6.4.0 - @khanacademy/wonder-blocks-data v13.0.7 - @khanacademy/wonder-blocks-dropdown v5.3.0 - @khanacademy/wonder-blocks-form v4.5.1 - @khanacademy/wonder-blocks-icon v4.1.0 - @khanacademy/wonder-blocks-layout v2.0.32 - @khanacademy/wonder-blocks-link v6.1.1 - @khanacademy/wonder-blocks-pill v2.2.1 - @khanacademy/wonder-blocks-popover v3.2.2 - @khanacademy/wonder-blocks-progress-spinner v2.1.1 - @khanacademy/wonder-blocks-switch v1.1.16 - @khanacademy/wonder-blocks-tokens v1.3.0 - @khanacademy/wonder-blocks-tooltip v2.3.1 - @khanacademy/wonder-blocks-typography v2.1.11 - @khanacademy/wonder-stuff-core v1.5.2 - @popperjs/core v^2.10.2 - classnames v1.1.4 - create-react-class v15.6.3 - katex v0.11.1 - prop-types v15.6.1 - react-popper v^2.2.5 - [#1261](#1261) [`f92c52412`](f92c524) Thanks [@Myranae](https://github.com/Myranae)! - Fix bug where arrow keys did not move all line segments ### Patch Changes - [#1256](#1256) [`9e2f404bb`](9e2f404) Thanks [@benchristel](https://github.com/benchristel)! - Update the styling of interactive circle graphs rendered with Mafs - [#1263](#1263) [`1f03243ba`](1f03243) Thanks [@benchristel](https://github.com/benchristel)! - Fix a bug in Mafs linear graphs where the arrows on the ends of the lines would sometimes disappear or flip around - [#1260](#1260) [`896a159a6`](896a159) Thanks [@nishasy](https://github.com/nishasy)! - Rename "start point" and "end point" to "point 1" and "point 2" respectively in Interactive Graph locked line settings - [#1250](#1250) [`3806759ea`](3806759) Thanks [@benchristel](https://github.com/benchristel)! - Internal: Refactor MovableLine component - Updated dependencies \[[`c07644f63`](c07644f), [`c07644f63`](c07644f)]: - @khanacademy/perseus-linter@0.4.0 - @khanacademy/math-input@19.1.0 - @khanacademy/pure-markdown@0.3.4 ## @khanacademy/perseus-editor@6.3.0 ### Minor Changes - [#1265](#1265) [`ef684516c`](ef68451) Thanks [@nishasy](https://github.com/nishasy)! - LockedLineSettings summary now uses a line swatch instead of a color swatch - [#1259](#1259) [`c07644f63`](c07644f) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Update all Perseus peer dependencies to match webapp exactly (commit: 2bd290251a8) - @khanacademy/wonder-blocks-accordion v1.3.1 - @khanacademy/wonder-blocks-button v6.3.1 - @khanacademy/wonder-blocks-banner v3.0.42 - @khanacademy/wonder-blocks-clickable v4.2.1 - @khanacademy/wonder-blocks-core v6.4.0 - @khanacademy/wonder-blocks-dropdown v5.3.0 - @khanacademy/wonder-blocks-form v4.5.1 - @khanacademy/wonder-blocks-icon-button v5.2.1 - @khanacademy/wonder-blocks-switch v1.1.16 - @khanacademy/wonder-blocks-tooltip v2.3.1 - @khanacademy/wonder-blocks-tokens v1.3.0 - @khanacademy/wonder-blocks-typography v2.1.11 - @khanacademy/wonder-stuff-core v1.5.2 - classnames v1.1.4 - create-react-class v15.6.3 - prop-types v15.6.1 ### Patch Changes - [#1260](#1260) [`896a159a6`](896a159) Thanks [@nishasy](https://github.com/nishasy)! - Rename "start point" and "end point" to "point 1" and "point 2" respectively in Interactive Graph locked line settings - [#1262](#1262) [`88c48a784`](88c48a7) Thanks [@nishasy](https://github.com/nishasy)! - Locked line coordinates update on input change instead of on input blur - [#1254](#1254) [`e4b893c76`](e4b893c) Thanks [@nishasy](https://github.com/nishasy)! - Locked line summary reflects line kind - Updated dependencies \[[`9e2f404bb`](9e2f404), [`1f03243ba`](1f03243), [`896a159a6`](896a159), [`3806759ea`](3806759), [`c07644f63`](c07644f), [`c07644f63`](c07644f), [`f92c52412`](f92c524)]: - @khanacademy/perseus@22.5.0 - @khanacademy/math-input@19.1.0 ## @khanacademy/perseus-error@0.3.0 ### Minor Changes - [#1259](#1259) [`c07644f63`](c07644f) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Update all Perseus peer dependencies to match webapp exactly (commit: 2bd290251a8) - @khanacademy/wonder-stuff-core v1.5.2 ## @khanacademy/perseus-linter@0.4.0 ### Minor Changes - [#1259](#1259) [`c07644f63`](c07644f) Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Update all Perseus peer dependencies to match webapp exactly (commit: 2bd290251a8) - prop-types v15.6.1 ### Patch Changes - Updated dependencies \[[`c07644f63`](c07644f)]: - @khanacademy/perseus-error@0.3.0 ## @khanacademy/pure-markdown@0.3.4 ### Patch Changes - Updated dependencies \[[`c07644f63`](c07644f)]: - @khanacademy/perseus-error@0.3.0 ## @khanacademy/perseus-dev-ui@1.5.7 ### Patch Changes - Updated dependencies \[[`c07644f63`](c07644f), [`c07644f63`](c07644f)]: - @khanacademy/perseus-linter@0.4.0 - @khanacademy/math-input@19.1.0 - @khanacademy/pure-markdown@0.3.4
The bug happened when
-0
was passed as a coordinate (yes,-0
is a distinctvalue in floating point, because the sign bit is stored separately from the
mantissa).
This PR patches the bug by handling horizontal and vertical lines as a special
case, and then refactors to a design where the special-casing is no longer
necessary. It's probably easiest to read the PR one commit at a time.
Issue: LEMS-1955
Test plan:
yarn dev
localhost:5173