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
b68b29df
Commit
b68b29df
authored
Nov 26, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加ScrollView
parent
ce8afae0
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
99 additions
and
55 deletions
+99
-55
Container.ts
src/2d/display/Container.ts
+9
-1
Shape.ts
src/2d/graphics/Shape.ts
+8
-8
ScrollContainer.ts
src/2d/ui/ScrollContainer.ts
+39
-33
ScrollList.ts
src/2d/ui/ScrollList.ts
+11
-11
index.ts
src/2d/ui/index.ts
+1
-1
ScrollView.ts
src/zeroing/game-warpper/nodes/ScrollView.ts
+29
-0
index.ts
src/zeroing/game-warpper/nodes/index.ts
+2
-1
No files found.
src/2d/display/Container.ts
View file @
b68b29df
...
...
@@ -20,6 +20,14 @@ import {afterConstructor} from "../../zeroing/decorators/after-constructor";
@
applyScript
@
applyEvents
export
default
class
Container
extends
DisplayObject
{
percentWidth
:
number
;
percentHeight
:
number
;
left
:
number
;
top
:
number
;
right
:
number
;
bottom
:
number
;
horizonCenter
:
number
;
verticalCenter
:
number
;
/**
* 为false鼠标事件不再向下传递
...
...
@@ -312,7 +320,7 @@ export default class Container extends DisplayObject {
//自己先算
super
.
updateTransform
();
//考虑是否要加,
//
this._boundsID++;
this
.
_boundsID
++
;
//children遍历计算
for
(
let
i
=
0
,
j
=
this
.
children
.
length
;
i
<
j
;
++
i
)
{
const
child
=
this
.
children
[
i
];
...
...
src/2d/graphics/Shape.ts
View file @
b68b29df
...
...
@@ -653,18 +653,18 @@ export class Shape extends Sprite {
leftX
=
0
;
leftY
=
0
;
}
leftX
-=
20
+
lineWidth
>>
1
;
leftY
-=
20
+
lineWidth
>>
1
;
buttonRightX
+=
20
+
lineWidth
>>
1
;
buttonRightY
+=
20
+
lineWidth
>>
1
;
leftX
-=
/*20 +*/
lineWidth
>>
1
;
leftY
-=
/*20 +*/
lineWidth
>>
1
;
buttonRightX
+=
/*20 +*/
lineWidth
>>
1
;
buttonRightY
+=
/*20 +*/
lineWidth
>>
1
;
let
w
=
buttonRightX
-
leftX
;
let
h
=
buttonRightY
-
leftY
;
s
.
offsetX
=
leftX
;
s
.
offsetY
=
leftY
;
s
.
_localBoundsSelf
.
x
=
leftX
+
10
;
s
.
_localBoundsSelf
.
y
=
leftY
+
10
;
s
.
_localBoundsSelf
.
width
=
w
-
20
;
s
.
_localBoundsSelf
.
height
=
h
-
20
;
s
.
_localBoundsSelf
.
x
=
leftX
/* + 10*/
;
s
.
_localBoundsSelf
.
y
=
leftY
/* + 10*/
;
s
.
_localBoundsSelf
.
width
=
w
/* - 20*/
;
s
.
_localBoundsSelf
.
height
=
h
/* - 20*/
;
let
_canvas
:
any
=
s
.
canvas
;
let
ctx
=
s
.
context
;
_canvas
.
width
=
w
;
...
...
src/2d/ui/Scroll
Page
.ts
→
src/2d/ui/Scroll
Container
.ts
View file @
b68b29df
...
...
@@ -12,7 +12,7 @@ import {Event} from "../events/Event";
* @extends Container
* @since 1.0.0
*/
export
class
Scroll
Page
extends
Container
{
export
class
Scroll
Container
extends
Container
{
/**
* 横向还是纵向 默认为纵向
* @property isVertical
...
...
@@ -30,7 +30,7 @@ export class ScrollPage extends Container {
* @since 1.0.0
* @default 0
*/
private
viewWidth
:
number
=
0
;
//
private viewWidth: number = 0;
/**
* 可见区域的高
* @property viewHeight
...
...
@@ -39,7 +39,7 @@ export class ScrollPage extends Container {
* @since 1.0.0
* @default 0
*/
private
viewHeight
:
number
=
0
;
//
private viewHeight: number = 0;
// private _tweenId: number = 0;
/**
* 整个滚动的最大距离值
...
...
@@ -49,7 +49,7 @@ export class ScrollPage extends Container {
* @since 1.0.0
* @default 1040
*/
public
maxDistance
:
number
=
1040
;
//
public maxDistance: number = 1040;
/**
* @property 滚动距离
* @type {number}
...
...
@@ -78,7 +78,7 @@ export class ScrollPage extends Container {
* @since 1.0.0
* @type {Container}
*/
public
view
:
Container
=
new
Container
();
public
view
Port
:
Container
=
new
Container
();
/**
* 最后鼠标经过的坐标值
* @property lastValue
...
...
@@ -160,27 +160,29 @@ export class ScrollPage extends Container {
* sPage.y=stage.viewRect.y;
*
*/
constructor
(
vW
:
number
,
vH
:
number
,
maxDistance
:
number
,
isVertical
:
boolean
=
true
,
isFull
=
false
)
{
constructor
(
maxDistance
?
:
number
,
isVertical
:
boolean
=
true
,
isFull
=
false
)
{
super
();
let
s
:
Scroll
Page
=
this
;
s
.
_instanceType
=
"Scroll
Page
"
;
s
.
addChild
(
s
.
maskObj
);
s
.
addChild
(
s
.
view
);
let
s
:
Scroll
Container
=
this
;
s
.
_instanceType
=
"Scroll
Container
"
;
s
uper
.
addChild
(
s
.
maskObj
);
s
uper
.
addChild
(
s
.
viewPort
);
if
(
!
isFull
)
{
//不全屏才设置mask
s
.
view
.
mask
=
s
.
maskObj
;
s
.
view
Port
.
mask
=
s
.
maskObj
;
//为了能接收鼠标事件设置isUsedToMask
s
.
maskObj
.
isUsedToMask
=
false
;
}
s
.
maskObj
.
alpha
=
0
;
s
.
maxDistance
=
maxDistance
;
s
.
setViewRect
(
vW
,
vH
,
isVertical
);
if
(
maxDistance
!==
undefined
){
//s.maxDistance = maxDistance;
}
s
.
updateViewRect
(
isVertical
);
// s.addEventListener(MouseEvent.MOUSE_DOWN, s.onMouseEvent.bind(s));
s
.
addEventListener
(
MouseEvent
.
MOUSE_MOVE
,
s
.
onMouseEvent
.
bind
(
s
)
);
s
.
addEventListener
(
MouseEvent
.
MOUSE_UP
,
s
.
onMouseEvent
.
bind
(
s
)
);
s
.
addEventListener
(
MouseEvent
.
MOUSE_OUT
,
s
.
onMouseEvent
.
bind
(
s
)
);
s
.
addEventListener
(
MouseEvent
.
MOUSE_MOVE
,
s
.
onMouseEvent
,
s
);
s
.
addEventListener
(
MouseEvent
.
MOUSE_UP
,
s
.
onMouseEvent
,
s
);
s
.
addEventListener
(
MouseEvent
.
MOUSE_OUT
,
s
.
onMouseEvent
,
s
);
s
.
addEventListener
(
Event
.
ENTER_FRAME
,
function
()
{
let
view
:
any
=
s
.
view
;
let
view
:
any
=
s
.
view
Port
;
if
(
s
.
autoScroll
)
return
;
if
(
!
s
.
isSpringBack
)
{
if
(
view
[
s
.
paramXY
]
>
0
)
{
...
...
@@ -237,7 +239,7 @@ export class ScrollPage extends Container {
}
}
else
{
if
(
s
.
stopTimes
>=
0
)
{
s
.
stopTimes
++
;
//
s.stopTimes++;
if
(
s
.
stopTimes
>=
15
)
{
s
.
speed
=
0
;
if
(
view
[
s
.
paramXY
]
>
0
||
view
[
s
.
paramXY
]
<
s
.
distance
-
s
.
maxDistance
)
{
...
...
@@ -247,7 +249,12 @@ export class ScrollPage extends Container {
}
}
}
})
});
s
.
addEventListener
(
Event
.
RESIZE
,
this
.
updateViewRect
,
s
);
}
get
maxDistance
(){
return
this
.
viewPort
.
height
;
}
/**
...
...
@@ -259,28 +266,27 @@ export class ScrollPage extends Container {
* @public
* @since 1.1.1
*/
public
setViewRect
(
w
:
number
,
h
:
number
,
isVertical
:
boolean
):
void
{
let
s
:
Scroll
Page
=
this
;
public
updateViewRect
(
isVertical
?
:
boolean
):
void
{
let
s
:
Scroll
Container
=
this
;
s
.
maskObj
.
clear
();
s
.
maskObj
.
beginFill
(
"#000000"
);
s
.
maskObj
.
drawRect
(
0
,
0
,
w
,
h
);
s
.
viewWidth
=
w
;
s
.
viewHeight
=
h
;
s
.
maskObj
.
drawRect
(
0
,
0
,
s
.
width
,
s
.
height
);
s
.
maskObj
.
endFill
();
if
(
isVertical
!==
undefined
){
s
.
isVertical
=
isVertical
;
}
if
(
isVertical
)
{
s
.
distance
=
s
.
viewH
eight
;
s
.
distance
=
s
.
h
eight
;
s
.
paramXY
=
"y"
;
}
else
{
s
.
distance
=
s
.
viewW
idth
;
s
.
distance
=
s
.
w
idth
;
s
.
paramXY
=
"x"
;
}
s
.
isVertical
=
isVertical
;
}
private
onMouseEvent
(
e
:
MouseEvent
):
void
{
let
s
=
this
;
let
view
:
any
=
s
.
view
;
let
view
:
any
=
s
.
view
Port
;
// if (s.distance < s.maxDistance) {
if
(
e
.
type
==
MouseEvent
.
MOUSE_MOVE
)
{
if
(
s
.
isMouseDownState
<
1
)
{
...
...
@@ -355,13 +361,13 @@ export class ScrollPage extends Container {
*/
public
scrollTo
(
dis
:
number
,
time
:
number
=
0
):
void
{
let
s
:
any
=
this
;
let
newDis
=
s
.
paramXY
==
"x"
?
s
.
viewWidth
:
s
.
viewH
eight
;
let
newDis
=
s
.
paramXY
==
"x"
?
s
.
width
:
s
.
h
eight
;
if
(
dis
<
0
)
{
dis
=
0
;
}
else
if
(
dis
>
s
.
maxDistance
-
newDis
)
{
dis
=
s
.
maxDistance
-
newDis
;
}
if
(
Math
.
abs
(
s
.
view
[
s
.
paramXY
]
+
dis
)
>
2
)
{
if
(
Math
.
abs
(
s
.
view
Port
[
s
.
paramXY
]
+
dis
)
>
2
)
{
// s.autoScroll = true;
// s.isStop = true;
// s.isMouseDownState = 0;
...
...
@@ -383,9 +389,9 @@ export class ScrollPage extends Container {
public
destroy
():
void
{
let
s
=
this
;
s
.
maskObj
.
destroy
();
s
.
view
.
destroy
();
s
.
view
Port
.
destroy
();
s
.
maskObj
=
null
;
s
.
view
=
null
;
s
.
view
Port
=
null
;
super
.
destroy
();
}
}
src/2d/ui/ScrollList.ts
View file @
b68b29df
import
{
Scroll
Page
}
from
"./ScrollPage
"
;
import
{
Scroll
Container
}
from
"./ScrollContainer
"
;
import
{
DisplayObject
}
from
"../display/DisplayObject"
;
import
{
Event
}
from
"../events/Event"
;
...
...
@@ -21,10 +21,10 @@ export interface IScrollListItem extends DisplayObject {
* 滚动列表
* @class ScrollList
* @public
* @extends Scroll
Page
* @extends Scroll
Container
* @since 1.0.9
*/
export
class
ScrollList
extends
Scroll
Page
{
export
class
ScrollList
extends
Scroll
Container
{
private
_items
:
Array
<
IScrollListItem
>
=
null
;
private
_itemW
:
number
;
private
_itemH
:
number
;
...
...
@@ -102,8 +102,8 @@ export class ScrollList extends ScrollPage {
private
flushData
()
{
let
s
:
any
=
this
;
if
(
s
.
_isInit
>
0
)
{
if
(
s
.
view
.
_UI
.
UM
)
{
let
id
:
number
=
(
Math
.
abs
(
Math
.
floor
(
s
.
view
[
s
.
paramXY
]
/
s
.
_itemRow
))
-
1
)
*
s
.
_cols
;
if
(
s
.
view
Port
.
_UI
.
UM
)
{
let
id
:
number
=
(
Math
.
abs
(
Math
.
floor
(
s
.
view
Port
[
s
.
paramXY
]
/
s
.
_itemRow
))
-
1
)
*
s
.
_cols
;
id
=
id
<
0
?
0
:
id
;
if
(
id
!=
s
.
_lastFirstId
)
{
s
.
_lastFirstId
=
id
;
...
...
@@ -151,8 +151,8 @@ export class ScrollList extends ScrollPage {
* @public
* @since 1.1.1
*/
public
set
ViewRect
(
w
:
number
,
h
:
number
,
isVertical
:
boolean
):
void
{
super
.
set
ViewRect
(
w
,
h
,
isVertical
);
public
update
ViewRect
(
w
:
number
,
h
:
number
,
isVertical
:
boolean
):
void
{
super
.
update
ViewRect
(
w
,
h
,
isVertical
);
let
s
=
this
;
if
(
s
.
_itemRow
&&
s
.
_itemCol
)
{
s
.
_updateViewRect
();
...
...
@@ -178,11 +178,11 @@ export class ScrollList extends ScrollPage {
item
.
id
=
-
1
;
item
.
data
=
null
;
s
.
_items
.
push
(
item
);
s
.
view
.
addChild
(
item
);
s
.
view
Port
.
addChild
(
item
);
}
}
else
{
for
(
let
i
=
0
;
i
<
s
.
_itemCount
-
newCount
;
i
++
)
{
s
.
view
.
removeChild
(
s
.
_items
.
pop
());
s
.
view
Port
.
removeChild
(
s
.
_items
.
pop
());
}
}
s
.
_itemCount
=
newCount
;
...
...
@@ -199,14 +199,14 @@ export class ScrollList extends ScrollPage {
public
setLoading
(
downLoading
:
DisplayObject
):
void
{
let
s
:
any
=
this
;
if
(
s
.
downL
)
{
s
.
view
.
removeChild
(
s
.
downL
);
s
.
view
Port
.
removeChild
(
s
.
downL
);
let
wh
=
s
.
downL
.
getWH
();
s
.
maxDistance
-=
(
s
.
paramXY
==
"x"
?
wh
.
width
:
wh
.
height
);
s
.
downL
=
null
;
}
if
(
downLoading
)
{
s
.
downL
=
downLoading
;
s
.
view
.
addChild
(
downLoading
);
s
.
view
Port
.
addChild
(
downLoading
);
s
.
downL
[
s
.
paramXY
]
=
Math
.
max
(
s
.
distance
,
s
.
maxDistance
);
let
wh
=
s
.
downL
.
getWH
();
s
.
maxDistance
+=
(
s
.
paramXY
==
"x"
?
wh
.
width
:
wh
.
height
);
...
...
src/2d/ui/index.ts
View file @
b68b29df
...
...
@@ -3,5 +3,5 @@
// export {BitmapNumbers} from "./BitmapNumbers";
export
{
ScrollList
}
from
"./ScrollList"
;
export
{
Scroll
Page
}
from
"./ScrollPage
"
;
export
{
Scroll
Container
}
from
"./ScrollContainer
"
;
export
{
Button
}
from
"./Button"
;
\ No newline at end of file
src/zeroing/game-warpper/nodes/ScrollView.ts
0 → 100644
View file @
b68b29df
/**
* Created by rockyl on 2019-11-24.
*/
import
{
ScrollContainer
}
from
"../../../2d/ui"
;
const
proxyMethods
=
[
'onChildrenChange'
,
'addChild'
,
'addChildAt'
,
'swapChildren'
,
'getChildIndex'
,
'setChildIndex'
,
'getChildAt'
,
'getChildByName'
,
'removeChild'
,
'removeChildAt'
,
'removeChildren'
,
];
export
class
ScrollView
extends
ScrollContainer
{
constructor
()
{
super
();
for
(
let
item
of
proxyMethods
){
this
[
item
]
=
this
.
viewPort
[
item
].
bind
(
this
.
viewPort
);
}
}
}
src/zeroing/game-warpper/nodes/index.ts
View file @
b68b29df
...
...
@@ -5,3 +5,4 @@
export
*
from
'./shapes'
export
*
from
'./Image'
export
*
from
'./Label'
export
*
from
'./ScrollView'
\ No newline at end of file
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