Skip to content

Commit

Permalink
more precise selection playback
Browse files Browse the repository at this point in the history
  • Loading branch information
maboa committed Sep 8, 2022
1 parent a908459 commit 9fb1b83
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion js/hyperaudio-lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,18 +268,27 @@ class HyperaudioLite {
fNode = fNode.previousElementSibling;
}

// if the selection starts with a space we want the next element
if(selection.toString().charAt(0) == " ") {
aNode = aNode.nextElementSibling;
}

let aNodeTime = parseInt(aNode.getAttribute('data-m'), 10);
let aNodeDuration = parseInt(aNode.getAttribute('data-d'), 10);
let fNodeTime;
let fNodeDuration;

if (fNode != null && fNode.getAttribute('data-m') != null) {
// if the selection ends in a space then we want the previous element
// if the selection ends in a space we want the previous element
if(selection.toString().slice(-1) == " ") {
fNode = fNode.previousElementSibling;
}

fNodeTime = parseInt(fNode.getAttribute('data-m'), 10);
fNodeDuration = parseInt(fNode.getAttribute('data-d'), 10);

// if the selection starts with a space we want the next element

}

// 1 decimal place will do
Expand Down

0 comments on commit 9fb1b83

Please sign in to comment.