forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add play slider to screengrid (apache#4647)
* Improved granularity parsing * Add unit tests * Explicit cast to int * Screengrid play slider * Clean code * Refactor common code
- Loading branch information
1 parent
46661e1
commit 1dcde53
Showing
5 changed files
with
121 additions
and
31 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
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,18 @@ | ||
import parseIsoDuration from 'parse-iso-duration'; | ||
|
||
|
||
export const getPlaySliderParams = function (timestamps, timeGrain) { | ||
let start = Math.min(...timestamps); | ||
let end = Math.max(...timestamps); | ||
|
||
// lock start and end to the closest steps | ||
const step = parseIsoDuration(timeGrain); | ||
start -= start % step; | ||
end += step - end % step; | ||
|
||
const values = timeGrain != null ? [start, start + step] : [start, end]; | ||
const disabled = timestamps.every(timestamp => timestamp === null); | ||
|
||
return { start, end, step, values, disabled }; | ||
}; | ||
|
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