Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-libs
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
劳工
zeroing-libs
Commits
68b6b767
Commit
68b6b767
authored
Aug 19, 2021
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
21a697ca
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
slider.json
slider.json
+8
-0
No files found.
slider.json
0 → 100644
View file @
68b6b767
{
"id"
:
"slider"
,
"script"
:
"
\n
//进度条背景
\n
//yun.duiba.com.cn/aurora/assets/21c385e9b5ad77889d790a71b35e8a6e1c189b0b.png
\n\n
//滑块按钮
\n
//yun.duiba.com.cn/aurora/assets/3af4e1925b2c030862dba3eef6424efa2a407bd8.png
\n\n
//进度条
\n
//yun.duiba.com.cn/aurora/assets/3e619a51b0b193cb627ed981c62a8eef0473bc9d.png
\n\n\n
const slide = new engine.Image()
\n
slide.source = props.slideSource
\n\n
const bg = new engine.Image()
\n
bg.source = props.bgSource
\n\n
const bar = new engine.Image()
\n
bar.source = props.barSource
\n\n
const mask = new engine.Rect()
\n\n\n
setTimeout(() => {
\n\n\t
//遮罩
\n\t
mask.width = bar.width
\n\t
mask.height = bar.height
\n\t
mask.borderRadius = props.borderRadius
\n\t
target.addChild(mask)
\n\n\t
//进度条
\n\t
bar.mask = mask
\n\t
target.addChild(bg)
\n\t
target.addChild(bar)
\n\t
bar.x = -bar.width
\n\n\t
//滑块
\n\t
slide.x = -slide.width / 2
\n\t
slide.y = -(slide.height - bg.height) / 2
\n\t
target.addChild(slide)
\n\t
target.height = bar.height
\n\t
target.width = bg.width
\n
})
\n\n\n
target.addEventListener(engine.MouseEvent.MOUSE_MOVE, function (e) {
\n\t
if (e.localX < 0) {
\n\t\t
slide.x = -slide.width / 2
\n\t\t
bar.x = - bar.width
\n\t
} else if (e.localX > bg.width) {
\n\t\t
slide.x = bg.width - slide.width / 2
\n\t\t
bar.x = bg.width - bar.width
\n\t
} else {
\n\t\t
slide.x = e.localX + -slide.width / 2
\n\t\t
bar.x = e.localX - bar.width
\n\t
}
\n\t
const per = (slide.x + slide.width / 2) / bg.width
\n\t
//抛出滑动比例
\n\t
engine.globalEvent.dispatchEvent(
\"
slidePer
\"
, per)
\n
}, this)"
,
"props"
:
{
"slideSource"
:
{
"type"
:
"string"
,
"enum"
:
[],
"alias"
:
"滑块图片"
},
"bgSource"
:
{
"type"
:
"string"
,
"enum"
:
[],
"alias"
:
"背景图片"
},
"barSource"
:
{
"type"
:
"string"
,
"enum"
:
[],
"alias"
:
"进度图片"
},
"borderRadius"
:
{
"type"
:
"number"
,
"enum"
:
[],
"alias"
:
"遮罩的圆角"
}},
"isPrefab"
:
true
,
"name"
:
"滑杆节点"
,
"output"
:
[
"success"
,
"failed"
],
"version"
:
"0.1.1"
,
"remark"
:
"滑杆"
}
\ 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