Skip to content
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

Programs with different start/ends seem to be grid aligned #63

Open
MiddleMan5 opened this issue Mar 12, 2024 · 2 comments
Open

Programs with different start/ends seem to be grid aligned #63

MiddleMan5 opened this issue Mar 12, 2024 · 2 comments
Labels
Improvement Improvement of app features

Comments

@MiddleMan5
Copy link

Planby 1.1.7
Following demo here with custom data: https://codesandbox.io/s/planby-epg-demo-ts-lp66v5

Items appear to be aligned to some kind of grid with no obvious way to change grid resolution.

image

@MiddleMan5
Copy link
Author

Super lazy note to author, and more for reference, but I solved my problem by intercepting the calculated program positions and re-writing my own width and horizontal placement function.

I found that the one of original getPositionX helper functions rounds the time values unnecessarily and also contains some unnecessary branches.

Effectively I replaced all of the getPositionX code with the code below:

const MS_PER_HOUR = 1000 * 60 * 60;

export const getPositionX = (
    since: Date,
    till: Date,
    startDate: Date,
    endDate: Date,
    hourWidth: number
) => {
    // Constrain the start and end of the rendered blocks to the start and end times displayed
    const renderStartTimeMs = Math.max(since.getTime(), startDate.getTime());
    const renderEndTimeMs = Math.min(till.getTime(), endDate.getTime());
    const diffMs = Math.max(0, renderEndTimeMs - renderStartTimeMs);
    return (diffMs * hourWidth) / MS_PER_HOUR;
};

Is the rounding expected behavior currently?

@karolkozer
Copy link
Owner

Hi @MiddleMan5

Thank you for reporting this behavior with the element in the layout.
I will check this functions and your suggestion regarding it.

@karolkozer karolkozer added the Improvement Improvement of app features label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Improvement of app features
Projects
None yet
Development

No branches or pull requests

2 participants