Align Bars in middle of view #2046
Replies: 2 comments 3 replies
|
There is currently no official built-in way to customize the scrolling behavior to achieve a centered scrolling. Adding a built-in way to scroll could be tricky as people might have custom needs (e.g. what should happen on scrolling or when using the horizontal layout). I could add some events which you can tap into to customize stuff but I have to think of a good design though to allow proper customization of the scrolling behaviors. I think it should allow to fully customize the scrolling or just do stuff before/after scrolling. #2049 added to track it. Technically alphaTab calls internally the // patch internal scroll function with custom logic (untested example)
api.internalScrollToCursor = ((originalInternalScrollToCursor) => {
return function(barBounds) {
const scrollElement = this.uiFacade.getScrollContainer();
const scrollViewHeight = scrollElement.height;
const cursorBar = barBoundings.realBounds.h;
this.settings.player.scrollOffsetY = - (scrollViewHeight / 2) + (cursorBar / 2);
originalInternalScrollToCursor.apply(this, arguments);
};
})(api.internalScrollToCursor); |
|
Not exactly the same but somewhat related. I will open a separate Topic as well, Landscape or Horizontal Playback Mode - Cursor and Auto-Scroll. Have not found a way to anchor Cursor in fixed position, like for example Songsterr does. Currently, auto-scroll moves but so does the Cursor. The Cursor moves mid measure, before the auto-scroll sort of pauses and then jerks back. Is there a way to replicate this (the way Songsterr does) for the Horizontal or Landscape mode? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Is there a better builtin way to align the being played bar in middle of view. I am using this way:
const scrollViewHeight = api.settings.player.scrollElement.clientHeight;
const cursorBar = document.querySelector('.at-cursor-bar').offsetHeight; // Bar height can change during the song so its approx
api.settings.player.scrollOffsetY = - (scrollViewHeight / 2) + (cursorBar / 2);
api.updateSettings();
All reactions