I get a problem when I am trying change zoom in rtl mode with "zoomToLevel()"
I am trying on change the zoom to show specific date in the same offset(specific date that always in the view in specific place in the scheduler).
In "LTR" It works fine but in "RTL" I lose the date.
Explain:
I use the "zoomToLevel()" with the zoomDate and zoomPosition properties.
In the zoom date I put the date that I want to save in the view and the offset I calculate like this:
calculateOfsset(scheduler) {
// Get date X.
const x = scheduler.getCoordinateFromDate(this.timeRangeDate);
// Calculate new click offset 0-1.
let clickOffset: number = x / scheduler.timelineScroller.scrollWidth;
if (this.direction === 'rtl') {
clickOffset = 1 - clickOffset;
}
// Calculate offset in px.
this.clickClientOffset = clickOffset * scheduler.timelineScroller.scrollWidth;
}
Reproduce:
1) I add some time range that need be always in the same place after zoom.
2) on first load you start as "LTR" mode.
3) Click on the "ZOOM+/ZOOM-" You will see that the time range stay in the same place.
4) I add button that change the scheduler direction(Click).
5) Play again with the "ZOOM+/ZOOM-" you will see that it is broken.
צילום מסך 2023-03-20 150237.png (36.24 KiB) Viewed 833 times
How can I solve this issue?
Re: [ANGULAR] Zoom To Level In RTL
Posted: Mon Mar 20, 2023 6:32 pm
by mats
Please share the code showing how you call zoomToLevel and we'll take a look.
Re: [ANGULAR] Zoom To Level In RTL
Posted: Mon Mar 20, 2023 6:45 pm
by tomerPlanit
The code is attached in the original post..
Adding the link here:
We checked this bug deeply and found that it works as expected if we don't use your custom offset calculation method.
Could you please tell us what exactly you want to achieve using that offset? We need to understand the logic of this code to know expected result and confirm a bug in our code or fix that method algorithm.
But, we confirmed that timeline doesn't keep center as it should when we do zoomIn/zoomOut many times, I've opened another ticket for that case https://github.com/bryntum/support/issues/6436
Re: [ANGULAR] Zoom To Level In RTL
Posted: Wed Mar 22, 2023 3:46 pm
by tomerPlanit
Hi Alex,
I want to achieve, that on any my zoom action specific date must be fixed in specific place(offset) of the scheduler view time line.
Like you can see in the demo that I created in "LTR"(The time range always stay in the same offset of the view).
Re: [ANGULAR] Zoom To Level In RTL
Posted: Wed Mar 22, 2023 4:09 pm
by alex.l
Ok, but what it calculates?
I missed one important thing in your template.
Officially we do not support RTL now, we have it ready 95% but it's not officially released, so it is not documented yet.
To enable rtl mode you need to set rtl: true in the Scheduler config (not with CSS, please remove that), or at runtime. Since it's not documented yet, our wrappers and typings won't support this property, so the way to enable it, as example inside your schedulerPaint method:
// Init scheduler data when finish pain the scheduler.
schedulerPaint(event: object) {
// If it is first paint.
if (event['firstPaint'] === true) {
this.scheduler = event['source'];
this.scheduler.on('selectionchange', this.resourceSelectionChange.bind(this));
// @ts-ignore
this.scheduler.rtl = true;
this.calculateOfsset(this.scheduler);
}
}
But, there is a bug with infiniteScroll and changing direction at runtime, and timeline position will jump and needs to be centered again after switch. I've opened another ticket for that https://github.com/bryntum/support/issues/6439
Regarding to your initial bug, please adjust your solution according to last notes and try to reproduce the problem again.
Re: [ANGULAR] Zoom To Level In RTL
Posted: Thu Mar 23, 2023 11:39 am
by tomerPlanit
Hi Alex,
After apply the scheduler rtl as you explained the problem is still happened, and the date jumps any scheduler direction change as you show above.
The thing that I calculate is the new fixed date position because the time line changed and it is not must be the same time line width(So I need to calculate the new date position for be in the same offset in the view time line).
You can see the result in "ltr" mode that works perfect.
Add new demo after change that you ask for.
Re: [ANGULAR] Zoom To Level In RTL
Posted: Thu Mar 23, 2023 9:05 pm
by alex.l
I am still not sure what that code should do, it just makes no sense to me.
You get offset before zooming and repositioning. After that you set zoomDate to center it by this date, and add offset value for position before re-positioning to date.
I guess you want to center timeline by timeRange startDate position?
This code works great to me.