-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from bemusic/display-test
Note area display
- Loading branch information
Showing
9 changed files
with
282 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
import R from 'ramda' | ||
|
||
export class NoteArea { | ||
constructor(notes) { | ||
this._notes = R.sortBy(position, notes) | ||
} | ||
getVisibleNotes(lower, upper, height) { | ||
return this._notes.filter(note => | ||
note.end ? | ||
!(note.position > upper || note.end.position < lower) : | ||
!(note.position > upper || note.position < lower)) | ||
.map(note => { | ||
if (!note.end) { | ||
return { key: note.id, y: y(lower, upper, note.position, height), | ||
column: note.column, } | ||
} else { | ||
let head = y(lower, upper, note.position, height) | ||
let tail = y(lower, upper, note.end.position, height) | ||
return { key: note.id, y: Math.min(head, tail), | ||
height: Math.abs(head - tail), | ||
column: note.column, } | ||
} | ||
}) | ||
} | ||
} | ||
|
||
export default NoteArea | ||
|
||
function y(lower, upper, position, height) { | ||
return height - (position - lower) / (upper - lower) * height | ||
} | ||
|
||
function position(event) { | ||
return event.position | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters