Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JM_4-1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
JM_4-1
Commits
15656e9d
Commit
15656e9d
authored
Oct 08, 2021
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 滚动条算法
parent
9796ee64
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14273 additions
and
24 deletions
+14273
-24
package-lock.json
package-lock.json
+14255
-0
Unit.ts
src/app/play/Unit.ts
+18
-24
No files found.
package-lock.json
0 → 100644
View file @
15656e9d
This diff is collapsed.
Click to expand it.
src/app/play/Unit.ts
View file @
15656e9d
...
...
@@ -2130,30 +2130,25 @@ export class ScrollView extends MySprite {
let
maxW
=
0
;
let
maxH
=
0
;
const
contentRect
=
{
left
:
0
,
right
:
0
,
up
:
0
,
down
:
0
};
for
(
let
i
=
0
;
i
<
children
.
length
;
i
++
)
{
if
(
children
[
i
]
==
this
.
content
)
{
continue
;
}
const
box
=
children
[
i
].
getBoundingBox
();
// console.log('box: ', box);
const
boxEdgeX
=
box
.
x
+
box
.
width
;
const
boxEdgeY
=
box
.
y
+
box
.
height
;
// console.log('boxEdgeY: ', boxEdgeY);
if
(
boxEdgeX
>
maxW
)
{
maxW
=
boxEdgeX
;
}
if
(
boxEdgeY
>
maxH
)
{
maxH
=
boxEdgeY
;
}
contentRect
.
left
=
Math
.
min
(
contentRect
.
left
,
box
.
x
);
contentRect
.
right
=
Math
.
max
(
contentRect
.
right
,
box
.
x
+
box
.
width
);
contentRect
.
up
=
Math
.
min
(
contentRect
.
up
,
box
.
y
);
contentRect
.
down
=
Math
.
max
(
contentRect
.
down
,
box
.
y
+
box
.
height
);
}
// console.log('maxW: ', maxW);
// console.log('maxH: ', maxH);
// console.log('this.y: ', this.y);
// console.log(this.getBoundingBox().height);
this
.
content
.
width
=
maxW
;
this
.
content
.
height
=
maxH
;
this
.
content
.
width
=
contentRect
.
right
-
contentRect
.
left
;
this
.
content
.
height
=
contentRect
.
down
-
contentRect
.
up
;
...
...
@@ -2197,12 +2192,11 @@ export class ScrollView extends MySprite {
}
refreshScrollBarPos
()
{
const
rect1
=
this
.
getBoundingBox
();
const
rect2
=
this
.
content
.
getBoundingBox
();
let
rate
=
rect1
.
height
/
rect2
.
height
;
const
scrollRect
=
this
.
getBoundingBox
();
const
contentRect
=
this
.
content
.
getBoundingBox
();
let
rate
=
scrollRect
.
height
/
(
contentRect
.
height
-
scrollRect
.
height
);
this
.
_scrollBar
.
y
=
-
rect2
.
y
*
(
rate
);
this
.
_scrollBar
.
y
=
-
contentRect
.
y
*
(
rate
);
}
...
...
@@ -2248,9 +2242,9 @@ export class ScrollView extends MySprite {
const
rect
=
this
.
getBoundingBox
();
if
(
this
.
scrollSide
==
ScrollView
.
ScrollSideType
.
VERTICAL
)
{
this
.
content
.
y
=
between
(
this
.
touchStartContentPos
.
y
+
offsetY
,
0
,
-
rect
.
y
+
rect
.
height
-
this
.
content
.
height
);
this
.
content
.
y
=
between
(
this
.
touchStartContentPos
.
y
+
offsetY
,
0
,
rect
.
height
-
this
.
content
.
height
);
}
else
{
this
.
content
.
x
=
between
(
this
.
touchStartContentPos
.
x
+
offsetX
,
0
,
-
rect
.
x
+
rect
.
width
-
this
.
content
.
width
);
this
.
content
.
x
=
between
(
this
.
touchStartContentPos
.
x
+
offsetX
,
0
,
rect
.
width
-
this
.
content
.
width
);
}
this
.
refreshScrollBarPos
();
}
...
...
@@ -2267,9 +2261,9 @@ export class ScrollView extends MySprite {
const
rect
=
this
.
getBoundingBox
();
if
(
this
.
scrollSide
==
ScrollView
.
ScrollSideType
.
VERTICAL
)
{
this
.
content
.
y
=
between
(
this
.
content
.
y
+
40
,
0
,
-
rect
.
y
+
rect
.
height
-
this
.
content
.
height
);
this
.
content
.
y
=
between
(
this
.
content
.
y
+
40
,
0
,
rect
.
height
-
this
.
content
.
height
);
}
else
{
this
.
content
.
x
=
between
(
this
.
content
.
x
+
40
,
0
,
-
rect
.
x
+
rect
.
width
-
this
.
content
.
width
);
this
.
content
.
x
=
between
(
this
.
content
.
x
+
40
,
0
,
rect
.
width
-
this
.
content
.
width
);
}
this
.
refreshScrollBarPos
();
...
...
@@ -2283,9 +2277,9 @@ export class ScrollView extends MySprite {
const
rect
=
this
.
getBoundingBox
();
if
(
this
.
scrollSide
==
ScrollView
.
ScrollSideType
.
VERTICAL
)
{
this
.
content
.
y
=
between
(
this
.
content
.
y
-
40
,
0
,
-
rect
.
y
+
rect
.
height
-
this
.
content
.
height
);
this
.
content
.
y
=
between
(
this
.
content
.
y
-
40
,
0
,
rect
.
height
-
this
.
content
.
height
);
}
else
{
this
.
content
.
x
=
between
(
this
.
content
.
x
-
40
,
0
,
-
rect
.
x
+
rect
.
width
-
this
.
content
.
width
);
this
.
content
.
x
=
between
(
this
.
content
.
x
-
40
,
0
,
rect
.
width
-
this
.
content
.
width
);
}
this
.
refreshScrollBarPos
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment