Skip to content

Optimisations #168

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions src/html-duration-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,21 @@ export default (function () {
*/

const getCursorSelection = (event, hideSeconds) => {
const {
target: {selectionStart, selectionEnd, value},
} = event;
const hourMarker = value.indexOf(':');
const minuteMarker = value.lastIndexOf(':');
let cursorSelection;
// The cursor selection is: hours
if (selectionStart <= hourMarker) {
cursorSelection = 'hours';
} else if (hideSeconds || selectionStart <= minuteMarker) {
// The cursor selection is: minutes
cursorSelection = 'minutes';
} else if (!hideSeconds && selectionStart > minuteMarker) {
// The cursor selection is: seconds
cursorSelection = 'seconds';
}
const content = value.slice(selectionStart, selectionEnd);
return {cursorSelection, hideSeconds, hourMarker, minuteMarker, content};
};
const { selectionStart, selectionEnd, value } = event.target;
const hourMarker = value.indexOf(':');
const minuteMarker = value.lastIndexOf(':');
let cursorSelection;
if (selectionStart <= hourMarker) {
cursorSelection = 'hours';
} else if (hideSeconds || selectionStart <= minuteMarker) {
cursorSelection = 'minutes';
} else {
cursorSelection = 'seconds';
}
const content = value.slice(selectionStart, selectionEnd);
return { cursorSelection, hideSeconds, hourMarker, minuteMarker, content };
};


/**
* Set the 'data-adjustment-factor' attribute for a picker
Expand Down