Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
admin-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
admin-fe
Commits
cbc5c182
Commit
cbc5c182
authored
7 years ago
by
dongsuo
Committed by
花裤衩
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
'代码格式化'
parent
5069a4d1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/BackToTop/index.vue
+83
-84
83 additions, 84 deletions
src/components/BackToTop/index.vue
src/views/components/backToTop.vue
+18
-21
18 additions, 21 deletions
src/views/components/backToTop.vue
with
101 additions
and
105 deletions
src/components/BackToTop/index.vue
+
83
−
84
View file @
cbc5c182
...
...
@@ -10,102 +10,101 @@
</div>
</transition>
</
template
>
<
script
>
export
default
{
name
:
'
BackToTop
'
,
props
:
{
visibilityHeight
:
{
type
:
Number
,
default
:
400
},
backPosition
:
{
type
:
Number
,
default
:
0
export
default
{
name
:
'
BackToTop
'
,
props
:
{
visibilityHeight
:
{
type
:
Number
,
default
:
400
},
backPosition
:
{
type
:
Number
,
default
:
0
},
customStyle
:
{
type
:
Object
,
default
:
{
right
:
'
50px
'
,
bottom
:
'
50px
'
,
width
:
'
40px
'
,
height
:
'
40px
'
,
'
border-radius
'
:
'
4px
'
,
'
line-height
'
:
'
45px
'
,
background
:
'
#e7eaf1
'
}
},
transitionName
:
{
type
:
String
,
default
:
'
fade
'
}
},
customStyle
:
{
type
:
Object
,
default
:
{
right
:
'
50px
'
,
bottom
:
'
50px
'
,
width
:
'
40px
'
,
height
:
'
40px
'
,
'
border-radius
'
:
'
4px
'
,
'
line-height
'
:
'
40px
'
,
background
:
'
#e7eaf1
'
data
()
{
return
{
visible
:
false
,
interval
:
null
}
},
transitionName
:
{
type
:
String
,
default
:
'
fade
'
}
},
data
()
{
return
{
visible
:
false
,
interval
:
null
}
},
mounted
()
{
window
.
addEventListener
(
'
scroll
'
,
this
.
handleScroll
);
},
beforeDestroy
()
{
window
.
removeEventListener
(
'
scroll
'
,
this
.
handleScroll
);
if
(
this
.
interval
)
{
clearInterval
(
this
.
interval
);
}
},
methods
:
{
handleScroll
()
{
this
.
visible
=
window
.
pageYOffset
>
this
.
visibilityHeight
;
mounted
()
{
window
.
addEventListener
(
'
scroll
'
,
this
.
handleScroll
);
},
backToTop
()
{
const
start
=
window
.
pageYOffset
;
let
i
=
0
;
this
.
interval
=
setInterval
(()
=>
{
const
next
=
Math
.
floor
(
this
.
easeInOutQuad
(
10
*
i
,
start
,
-
start
,
500
));
if
(
next
<=
this
.
backPosition
)
{
window
.
scrollTo
(
0
,
this
.
backPosition
);
clearInterval
(
this
.
interval
)
}
else
{
window
.
scrollTo
(
0
,
next
);
}
i
++
;
},
16.7
)
beforeDestroy
()
{
window
.
removeEventListener
(
'
scroll
'
,
this
.
handleScroll
);
if
(
this
.
interval
)
{
clearInterval
(
this
.
interval
);
}
},
easeInOutQuad
(
t
,
b
,
c
,
d
)
{
if
((
t
/=
d
/
2
)
<
1
)
return
c
/
2
*
t
*
t
+
b
;
return
-
c
/
2
*
(
--
t
*
(
t
-
2
)
-
1
)
+
b
;
methods
:
{
handleScroll
()
{
this
.
visible
=
window
.
pageYOffset
>
this
.
visibilityHeight
;
},
backToTop
()
{
const
start
=
window
.
pageYOffset
;
let
i
=
0
;
this
.
interval
=
setInterval
(()
=>
{
const
next
=
Math
.
floor
(
this
.
easeInOutQuad
(
10
*
i
,
start
,
-
start
,
500
));
if
(
next
<=
this
.
backPosition
)
{
window
.
scrollTo
(
0
,
this
.
backPosition
);
clearInterval
(
this
.
interval
)
}
else
{
window
.
scrollTo
(
0
,
next
);
}
i
++
;
},
16.7
)
},
easeInOutQuad
(
t
,
b
,
c
,
d
)
{
if
((
t
/=
d
/
2
)
<
1
)
return
c
/
2
*
t
*
t
+
b
;
return
-
c
/
2
*
(
--
t
*
(
t
-
2
)
-
1
)
+
b
;
}
}
}
}
</
script
>
<
style
scoped
>
.back-to-top
{
position
:
fixed
;
display
:
inline-block
;
text-align
:
center
;
cursor
:
pointer
;
}
.back-to-top
{
position
:
fixed
;
display
:
inline-block
;
text-align
:
center
;
cursor
:
pointer
;
}
.back-to-top
:hover
{
background
:
#d5dbe7
;
}
.back-to-top
:hover
{
background
:
#d5dbe7
;
}
.fade-enter-active
,
.fade-leave-active
{
transition
:
opacity
.5s
;
}
.fade-enter-active
,
.fade-leave-active
{
transition
:
opacity
.5s
;
}
.fade-enter
,
.fade-leave-to
{
opacity
:
0
}
.fade-enter
,
.fade-leave-to
{
opacity
:
0
}
.back-to-top
.Icon
{
fill
:
#9aaabf
;
background
:
none
;
}
.back-to-top
.Icon
{
fill
:
#9aaabf
;
background
:
none
;
}
</
style
>
This diff is collapsed.
Click to expand it.
src/views/components/backToTop.vue
+
18
−
21
View file @
cbc5c182
<
template
>
<div
class=
"components-container"
>
<code>
页面滚动到指定位置会在右下角出现返回顶部按钮
</code>
<code>
可自定义按钮的样式、show/hide临界点、返回的位置
如需文字提示,可在外部使用Element的el-tooltip元素
</code>
<code>
可自定义按钮的样式、show/hide临界点、返回的位置 如需文字提示,可在外部使用Element的el-tooltip元素
</code>
<div>
我是占位
</div>
<div>
我是占位
</div>
<div>
我是占位
</div>
...
...
@@ -130,29 +129,27 @@
<!--可自定义按钮的样式、show/hide临界点、返回的位置 -->
<!--如需文字提示,可在外部添加element的
<el-tooltip></el-tooltip>
元素 -->
<el-tooltip
placement=
"top"
content=
"文字提示"
>
<back-to-top
transitionName=
"fade"
:customStyle=
"myBackToTopStyle"
:visibilityHeight=
"300"
:backPosition=
"50"
></back-to-top>
<back-to-top
transitionName=
"fade"
:customStyle=
"myBackToTopStyle"
:visibilityHeight=
"300"
:backPosition=
"50"
></back-to-top>
</el-tooltip>
</div>
</
template
>
<
script
>
import
BackToTop
from
'
components/BackToTop
'
;
export
default
{
components
:
{
BackToTop
},
data
()
{
return
{
myBackToTopStyle
:
{
right
:
'
50px
'
,
bottom
:
'
50px
'
,
width
:
'
40px
'
,
height
:
'
40px
'
,
'
border-radius
'
:
'
4px
'
,
'
line-height
'
:
'
40px
'
,
// 请保持与高度一致以垂直居中
background
:
'
#e7eaf1
'
// 按钮的背景颜色
import
BackToTop
from
'
components/BackToTop
'
;
export
default
{
components
:
{
BackToTop
},
data
()
{
return
{
myBackToTopStyle
:
{
right
:
'
50px
'
,
bottom
:
'
50px
'
,
width
:
'
40px
'
,
height
:
'
40px
'
,
'
border-radius
'
:
'
4px
'
,
'
line-height
'
:
'
45px
'
,
// 请保持与高度一致以垂直居中
background
:
'
#e7eaf1
'
// 按钮的背景颜色
}
}
}
}
}
</
script
>
<
style
scoped
>
</
style
>
</
script
>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment