Skip to content

Commit d9c7834

Browse files
authored
Release 1.2.1 (#573)
* Fixed iOS related display issues (#570) * Fixed some scaling issue (#564)
1 parent 7bbdfcd commit d9c7834

File tree

8 files changed

+92
-17
lines changed

8 files changed

+92
-17
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coderline/alphatab",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "alphaTab is a music notation and guitar tablature rendering library",
55
"keywords": [
66
"guitar",

src.csharp/Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<PropertyGroup>
33
<DebugType>portable</DebugType>
44
<DebugSymbols>true</DebugSymbols>
5-
<Version>1.1.0</Version>
6-
<AssemblyVersion>1.1.0.0</AssemblyVersion>
5+
<Version>1.2.1</Version>
6+
<AssemblyVersion>1.2.1.0</AssemblyVersion>
77
<FileVersion>$(AssemblyVersion)</FileVersion>
88
<Authors>Danielku15</Authors>
99
<Company>CoderLine</Company>
1010
<Product>AlphaTab</Product>
1111
<NeutralLanguage>en</NeutralLanguage>
1212
<Description>alphaTab is a cross platform music notation and guitar tablature rendering library.</Description>
13-
<Copyright>Copyright © 2020, Daniel Kuschny and Contributors</Copyright>
13+
<Copyright>Copyright © 2021, Daniel Kuschny and Contributors</Copyright>
1414
<PackageLicenseExpression>MPL-2.0</PackageLicenseExpression>
1515
<PackageProjectUrl>https://www.alphatab.net</PackageProjectUrl>
1616
<RepositoryUrl>https://github.com/CoderLine/alphaTab</RepositoryUrl>

src/Environment.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { Logger } from '@src/Logger';
5454
import { LeftHandTapEffectInfo } from './rendering/effects/LeftHandTapEffectInfo';
5555
import { CapellaImporter } from './importer/CapellaImporter';
5656
import { ResizeObserverPolyfill } from './platform/javascript/ResizeObserverPolyfill';
57+
import { IntersectionObserverPolyfill } from './platform/javascript/IntersectionObserverPolyfill';
5758

5859
export class LayoutEngineFactory {
5960
public readonly vertical: boolean;
@@ -124,6 +125,9 @@ export class Environment {
124125
vertical-align: top;
125126
overflow: visible;
126127
}
128+
.at-surface-svg text {
129+
dominant-baseline: central;
130+
}
127131
.at {
128132
font-family: 'alphaTab';
129133
speak: none;
@@ -456,11 +460,16 @@ export class Environment {
456460
if(!('ResizeObserver' in globalThis)) {
457461
(globalThis as any).ResizeObserver = ResizeObserverPolyfill;
458462
}
463+
// IntersectionObserver API does not on older iOS versions
464+
// so we better add a polyfill for it
465+
if (!('IntersectionObserver' in Environment.globalThis)) {
466+
(Environment.globalThis as any).IntersectionObserver = IntersectionObserverPolyfill;
467+
}
459468
} else {
460469
AlphaTabWebWorker.init();
461470
AlphaSynthWebWorker.init();
462471
}
463472
}
464473
}
465474

466-
Environment.platformInit();
475+
Environment.platformInit();
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* A polyfill of the InsersectionObserver
3+
* @target web
4+
*/
5+
export class IntersectionObserverPolyfill {
6+
private _callback: IntersectionObserverCallback;
7+
private _elements: HTMLElement[] = [];
8+
9+
public constructor(callback: IntersectionObserverCallback) {
10+
let timer: any = null;
11+
const oldCheck = this._check.bind(this);
12+
this._check = () => {
13+
if (!timer) {
14+
timer = setTimeout(() => {
15+
oldCheck();
16+
timer = null;
17+
}, 100);
18+
}
19+
};
20+
21+
this._callback = callback;
22+
23+
window.addEventListener('resize', this._check, true);
24+
document.addEventListener('scroll', this._check, true);
25+
}
26+
27+
public observe(target: HTMLElement) {
28+
if (this._elements.indexOf(target) >= 0) {
29+
return;
30+
}
31+
this._elements.push(target);
32+
this._check();
33+
}
34+
35+
public unobserve(target: HTMLElement) {
36+
this._elements = this._elements.filter(item => {
37+
return item != target;
38+
});
39+
};
40+
41+
private _check() {
42+
const entries: IntersectionObserverEntry[] = [];
43+
this._elements.forEach(element => {
44+
const rect = element.getBoundingClientRect();
45+
const isVisible = (
46+
rect.top + rect.height >= 0 &&
47+
rect.top <= window.innerHeight &&
48+
rect.left + rect.width >= 0 &&
49+
rect.left <= window.innerWidth
50+
);
51+
52+
if (isVisible) {
53+
entries.push({
54+
target: element,
55+
isIntersecting: true
56+
} as any);
57+
}
58+
});
59+
60+
if (entries.length) {
61+
this._callback(entries, this as any);
62+
}
63+
}
64+
}

src/platform/svg/SvgCanvas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export abstract class SvgCanvas implements ICanvas {
2323

2424
public beginRender(width: number, height: number): void {
2525
this.buffer = `<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="${width | 0}px" height="${height | 0
26-
}px" class="at-surface-svg" style="dominant-baseline: central;">\n`;
26+
}px" class="at-surface-svg">\n`;
2727
this._currentPath = '';
2828
this._currentPathIsEmpty = true;
2929
this.textBaseline = TextBaseline.Top;

src/rendering/glyphs/ChordDiagramGlyph.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,24 @@ export class ChordDiagramGlyph extends EffectGlyph {
2323

2424
public doLayout(): void {
2525
super.doLayout();
26+
const scale = this.scale;
2627
let res: RenderingResources = this.renderer.resources;
27-
this._textRow = res.effectFont.size * 1.5;
28-
this._fretRow = res.effectFont.size * 1.5;
28+
this._textRow = res.effectFont.size * 1.5 * scale;
29+
this._fretRow = res.effectFont.size * 1.5 * scale;
2930
if (this._chord.firstFret > 1) {
30-
this._firstFretSpacing = ChordDiagramGlyph.FretSpacing * this.scale;
31+
this._firstFretSpacing = ChordDiagramGlyph.FretSpacing * scale;
3132
} else {
3233
this._firstFretSpacing = 0;
3334
}
3435
this.height =
3536
this._textRow +
3637
this._fretRow +
37-
(ChordDiagramGlyph.Frets - 1) * ChordDiagramGlyph.FretSpacing * this.scale +
38-
2 * ChordDiagramGlyph.Padding;
38+
(ChordDiagramGlyph.Frets - 1) * ChordDiagramGlyph.FretSpacing * scale +
39+
2 * ChordDiagramGlyph.Padding * scale;
3940
this.width =
4041
this._firstFretSpacing +
41-
(this._chord.staff.tuning.length - 1) * ChordDiagramGlyph.StringSpacing * this.scale +
42-
2 * ChordDiagramGlyph.Padding;
42+
(this._chord.staff.tuning.length - 1) * ChordDiagramGlyph.StringSpacing * scale +
43+
2 * ChordDiagramGlyph.Padding * scale;
4344
}
4445

4546
public paint(cx: number, cy: number, canvas: ICanvas): void {
@@ -114,14 +115,14 @@ export class ChordDiagramGlyph extends EffectGlyph {
114115
info[1] = guitarString;
115116
}
116117
}
117-
let y: number = cy + fret * fretSpacing + fretSpacing / 2 + 0.5;
118+
let y: number = cy + fret * fretSpacing + fretSpacing / 2 + 0.5 * this.scale;
118119
let x: number = cx + (this._chord.strings.length - guitarString - 1) * stringSpacing;
119120
canvas.fillCircle(x, y, circleRadius);
120121
}
121122
}
122123

123124
for(const [fret, strings] of barreLookup) {
124-
let y: number = cy + fret * fretSpacing + fretSpacing / 2 + this.scale;
125+
let y: number = cy + fret * fretSpacing + fretSpacing / 2 + 0.5 * this.scale;
125126
let xLeft: number = cx + (this._chord.strings.length - strings[1] - 1) * stringSpacing;
126127
let xRight: number = cx + (this._chord.strings.length - strings[0] - 1) * stringSpacing;
127128
canvas.fillRect(xLeft, y - circleRadius, xRight - xLeft, circleRadius * 2);

src/rendering/glyphs/VoiceContainerGlyph.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export class VoiceContainerGlyph extends GlyphGroup {
2626
}
2727

2828
public scaleToWidth(width: number): void {
29-
let force: number = this.renderer.layoutingInfo.spaceToForce(width);
29+
const scale = this.renderer.scale;
30+
let force: number = this.renderer.layoutingInfo.spaceToForce(width / scale);
3031
this.scaleToForce(force);
3132
}
3233

0 commit comments

Comments
 (0)