Skip to content

Commit 269e20c

Browse files
authored
Merge pull request #45 from keshav1720/add-scroll
Add scroll test case and matrixScroll
2 parents 33d059a + 8ae26c5 commit 269e20c

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

src/index.pug

+8-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ html(lang='en')
1515
include ../node_modules/reset-css/reset.css
1616
include ./demo.css
1717
body
18-
include ../test/svg-composition.pug
18+
// - include ../test/svg-composition.pug
19+
include ../test/scroll.pug
1920
//.super(style="height: 200px; width: 200px;")
2021
//div(style="margin-top: 40px; margin-left: 40px")
2122
//div(style="margin-top: 40px")
@@ -27,12 +28,12 @@ html(lang='en')
2728
.referentiel
2829
.pointer
2930
//div(style="margin-top: 14px")
30-
div(style="position: relative; top: 40px; left: 40px")
31-
p Hello World
32-
div
33-
div(style="position: absolute; top: 40px; left: 50px;")
34-
.referentiel
35-
.pointer
31+
// - div(style="position: relative; top: 40px; left: 40px")
32+
// - p Hello World
33+
// - div
34+
// - div(style="position: absolute; top: 40px; left: 50px;")
35+
// - .referentiel
36+
// - .pointer
3637
//div(style="position: absolute; top: 40px; left: 50px;")
3738
.referentiel
3839
.pointer

src/referentiel.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class Referentiel {
107107
this.matrixTransformOrigin(),
108108
this.matrixTransform(),
109109
Referentiel.inv(this.matrixTransformOrigin()),
110-
this.matrixBorder()
110+
this.matrixBorder(),
111+
this.matrixScroll()
111112
);
112113
}
113114

@@ -168,6 +169,17 @@ class Referentiel {
168169
];
169170
}
170171

172+
matrixScroll(): Matrix {
173+
if (!(this.reference instanceof HTMLElement)) return Referentiel.identity();
174+
const left = this.reference.scrollLeft;
175+
const top = this.reference.scrollTop;
176+
return [
177+
[1, 0, -left],
178+
[0, 1, -top],
179+
[0, 0, 1],
180+
];
181+
}
182+
171183
parent(element: Node): Node | null {
172184
if (
173185
element.parentNode != null &&

test/pug_loader.js

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ describe("Pug", function () {
9494
"absolute_tricky",
9595
"absolute_stacked",
9696
"absolute_transformations",
97+
"scroll"
9798
];
9899
results = [];
99100
for (j = 0, len = ref.length; j < len; j++) {

test/scroll.pug

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
div(style="overflow:auto; width: 200px; height: 200px;")
2+
.referentiel(style="width: 5000px; height: 5000px;")
3+
script.
4+
document.scripts[document.scripts.length - 1].parentElement.parentElement.scrollTop = 50
5+
document.scripts[document.scripts.length - 1].parentElement.parentElement.scrollLeft = 30
6+
.assert(data-assert="0,0:30,50")
7+
.assert(data-assert="10,10:40,60")
8+

0 commit comments

Comments
 (0)