Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
renderingEngine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
王剑峰
renderingEngine
Commits
d364a706
Commit
d364a706
authored
Dec 04, 2019
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
eb2f29c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
28 deletions
+38
-28
RoundedRectangle.ts
src/2d/graphics/shapes/RoundedRectangle.ts
+8
-2
ScrollContainer.ts
src/2d/ui/ScrollContainer.ts
+30
-26
No files found.
src/2d/graphics/shapes/RoundedRectangle.ts
View file @
d364a706
import
{
SHAPES
}
from
'../../const'
;
import
{
SHAPES
}
from
'../../const'
;
import
{
Point
}
from
'../../math'
;
import
{
Point
}
from
'../../math'
;
/**
/**
* The Rounded Rectangle object is an area that has nice rounded corners, as indicated by its
* The Rounded Rectangle object is an area that has nice rounded corners, as indicated by its
...
@@ -40,6 +40,12 @@ export default class RoundedRectangle {
...
@@ -40,6 +40,12 @@ export default class RoundedRectangle {
this
.
width
=
width
;
this
.
width
=
width
;
this
.
height
=
height
;
this
.
height
=
height
;
//计算最大圆角
let
max
=
(
width
<
height
?
width
:
height
)
/
2
;
//小于0取反
radius
=
radius
<
0
?
-
radius
:
radius
;
//大于max取max
radius
=
radius
>
max
?
max
:
radius
;
this
.
radius
=
radius
;
this
.
radius
=
radius
;
...
...
src/2d/ui/ScrollContainer.ts
View file @
d364a706
import
Container
from
"../display/Container"
;
import
Container
from
"../display/Container"
;
import
Graphics
from
"../graphics/Graphics"
;
import
Graphics
from
"../graphics/Graphics"
;
import
{
MouseEvent
}
from
"../events/MouseEvent"
;
import
{
MouseEvent
}
from
"../events/MouseEvent"
;
import
{
Event
}
from
"../events/Event"
;
import
{
Event
}
from
"../events/Event"
;
// import Tween from "../../tweenSimple/Tween";
// import Tween from "../../tweenSimple/Tween";
...
@@ -173,14 +173,20 @@ export class ScrollContainer extends Container {
...
@@ -173,14 +173,20 @@ export class ScrollContainer extends Container {
s
.
maskObj
.
isUsedToMask
=
false
;
s
.
maskObj
.
isUsedToMask
=
false
;
}
}
s
.
maskObj
.
alpha
=
0
;
s
.
maskObj
.
alpha
=
0
;
if
(
maxDistance
!==
undefined
)
{
if
(
maxDistance
!==
undefined
)
{
//s.maxDistance = maxDistance;
//s.maxDistance = maxDistance;
}
}
s
.
updateViewRect
(
isVertical
);
s
.
updateViewRect
(
isVertical
);
// s.addEventListener(MouseEvent.MOUSE_DOWN, s.onMouseEvent.bind(s));
s
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
function
(
e
:
Event
)
{
s
.
stage
.
addEventListener
(
MouseEvent
.
MOUSE_UP
,
s
.
onMouseEvent
,
s
);
})
s
.
addEventListener
(
Event
.
REMOVED_FROM_STAGE
,
function
(
e
:
Event
)
{
s
.
stage
.
removeEventListener
(
MouseEvent
.
MOUSE_UP
,
s
.
onMouseEvent
,
s
);
});
s
.
addEventListener
(
MouseEvent
.
MOUSE_DOWN
,
s
.
onMouseEvent
,
s
);
s
.
addEventListener
(
MouseEvent
.
MOUSE_MOVE
,
s
.
onMouseEvent
,
s
);
s
.
addEventListener
(
MouseEvent
.
MOUSE_MOVE
,
s
.
onMouseEvent
,
s
);
s
.
addEventListener
(
MouseEvent
.
MOUSE_UP
,
s
.
onMouseEvent
,
s
);
//
s.addEventListener(MouseEvent.MOUSE_UP, s.onMouseEvent, s);
s
.
addEventListener
(
MouseEvent
.
MOUSE_OUT
,
s
.
onMouseEvent
,
s
);
//
s.addEventListener(MouseEvent.MOUSE_OUT, s.onMouseEvent, s);
s
.
addEventListener
(
Event
.
ENTER_FRAME
,
function
()
{
s
.
addEventListener
(
Event
.
ENTER_FRAME
,
function
()
{
let
view
:
any
=
s
.
viewPort
;
let
view
:
any
=
s
.
viewPort
;
if
(
s
.
autoScroll
)
return
;
if
(
s
.
autoScroll
)
return
;
...
@@ -253,7 +259,7 @@ export class ScrollContainer extends Container {
...
@@ -253,7 +259,7 @@ export class ScrollContainer extends Container {
s
.
addEventListener
(
Event
.
RESIZE
,
this
.
updateViewRect
,
s
);
s
.
addEventListener
(
Event
.
RESIZE
,
this
.
updateViewRect
,
s
);
}
}
get
maxDistance
(){
get
maxDistance
()
{
return
this
.
viewPort
.
height
;
return
this
.
viewPort
.
height
;
}
}
...
@@ -272,7 +278,7 @@ export class ScrollContainer extends Container {
...
@@ -272,7 +278,7 @@ export class ScrollContainer extends Container {
s
.
maskObj
.
beginFill
(
"#000000"
);
s
.
maskObj
.
beginFill
(
"#000000"
);
s
.
maskObj
.
drawRect
(
0
,
0
,
s
.
width
,
s
.
height
);
s
.
maskObj
.
drawRect
(
0
,
0
,
s
.
width
,
s
.
height
);
s
.
maskObj
.
endFill
();
s
.
maskObj
.
endFill
();
if
(
isVertical
!==
undefined
)
{
if
(
isVertical
!==
undefined
)
{
s
.
isVertical
=
isVertical
;
s
.
isVertical
=
isVertical
;
}
}
if
(
isVertical
)
{
if
(
isVertical
)
{
...
@@ -288,25 +294,23 @@ export class ScrollContainer extends Container {
...
@@ -288,25 +294,23 @@ export class ScrollContainer extends Container {
let
s
=
this
;
let
s
=
this
;
let
view
:
any
=
s
.
viewPort
;
let
view
:
any
=
s
.
viewPort
;
// if (s.distance < s.maxDistance) {
// if (s.distance < s.maxDistance) {
if
(
e
.
type
==
MouseEvent
.
MOUSE_MOVE
)
{
if
(
e
.
type
==
MouseEvent
.
MOUSE_DOWN
)
{
if
(
s
.
isMouseDownState
<
1
)
{
if
(
!
s
.
isStop
)
{
if
(
!
s
.
isStop
)
{
s
.
isStop
=
true
;
s
.
isStop
=
true
;
}
}
if
(
s
.
autoScroll
)
{
if
(
s
.
autoScroll
)
{
s
.
autoScroll
=
false
;
s
.
autoScroll
=
false
;
// Tween.kill(s._tweenId);
// Tween.kill(s._tweenId);
}
}
if
(
s
.
isVertical
)
{
if
(
s
.
isVertical
)
{
s
.
lastValue
=
e
.
localY
;
s
.
lastValue
=
e
.
localY
;
}
else
{
}
else
{
s
.
lastValue
=
e
.
localX
;
s
.
lastValue
=
e
.
localX
;
}
s
.
speed
=
0
;
s
.
isMouseDownState
=
1
;
return
;
}
}
;
s
.
speed
=
0
;
s
.
isMouseDownState
=
1
;
}
else
if
(
e
.
type
==
MouseEvent
.
MOUSE_MOVE
)
{
if
(
s
.
isMouseDownState
==
1
)
{
if
(
s
.
isMouseDownState
==
1
)
{
s
.
dispatchEvent
(
Event
.
ON_SCROLL_START
);
s
.
dispatchEvent
(
Event
.
ON_SCROLL_START
);
}
}
...
...
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