Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VueElementTemplate
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
JIRA
JIRA
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
黄瑜
VueElementTemplate
Commits
705b9cce
Commit
705b9cce
authored
Dec 05, 2017
by
Pan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add(tags-view): moveToCurrentTag
parent
c84964d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
5 deletions
+37
-5
index.vue
src/components/ScrollPane/index.vue
+23
-3
TagsView.vue
src/views/layout/components/TagsView.vue
+14
-2
No files found.
src/components/ScrollPane/index.vue
View file @
705b9cce
...
...
@@ -7,6 +7,8 @@
</
template
>
<
script
>
const
padding
=
15
// tag's padding
export
default
{
name
:
'scrollPane'
,
data
()
{
...
...
@@ -21,19 +23,37 @@ export default {
const
$containerWidth
=
$container
.
offsetWidth
const
$wrapper
=
this
.
$refs
.
scrollWrapper
const
$wrapperWidth
=
$wrapper
.
offsetWidth
if
(
e
.
wheelDelta
>
0
)
{
this
.
left
=
Math
.
min
(
0
,
this
.
left
+
e
.
wheelDelta
)
}
else
{
if
(
$containerWidth
-
100
<
$wrapperWidth
)
{
if
(
this
.
left
<
-
(
$wrapperWidth
-
$containerWidth
+
100
))
{
if
(
$containerWidth
-
padding
<
$wrapperWidth
)
{
if
(
this
.
left
<
-
(
$wrapperWidth
-
$containerWidth
+
padding
))
{
this
.
left
=
this
.
left
}
else
{
this
.
left
=
Math
.
max
(
this
.
left
+
e
.
wheelDelta
,
$containerWidth
-
$wrapperWidth
-
100
)
this
.
left
=
Math
.
max
(
this
.
left
+
e
.
wheelDelta
,
$containerWidth
-
$wrapperWidth
-
padding
)
}
}
else
{
this
.
left
=
0
}
}
},
moveToTarget
(
$target
)
{
const
$container
=
this
.
$refs
.
scrollContainer
const
$containerWidth
=
$container
.
offsetWidth
const
$targetLeft
=
$target
.
offsetLeft
const
$targetWidth
=
$target
.
offsetWidth
if
(
$targetLeft
<
-
this
.
left
)
{
// tag in the left
this
.
left
=
-
$targetLeft
+
padding
}
else
if
(
$targetLeft
+
padding
>
-
this
.
left
&&
$targetLeft
+
$targetWidth
<
-
this
.
left
+
$containerWidth
-
padding
)
{
// tag in the current view
// eslint-disable-line
}
else
{
// tag in the right
this
.
left
=
-
(
$targetLeft
-
(
$containerWidth
-
$targetWidth
)
+
padding
)
}
}
}
}
...
...
src/views/layout/components/TagsView.vue
View file @
705b9cce
<
template
>
<scroll-pane
class=
'tags-view-container'
>
<router-link
class=
"tags-view-item"
:class=
"isActive(tag)?'active':''"
v-for=
"tag in Array.from(visitedViews)"
:to=
"tag.path"
:key=
"tag.path"
>
<scroll-pane
class=
'tags-view-container'
ref=
'scrollPane'
>
<router-link
ref=
'tag'
class=
"tags-view-item"
:class=
"isActive(tag)?'active':''"
v-for=
"tag in Array.from(visitedViews)"
:to=
"tag.path"
:key=
"tag.path"
>
{{
$t
(
'route.'
+
tag
.
title
)
}}
<span
class=
'el-icon-close'
@
click=
'closeViewTags(tag,$event)'
></span>
</router-link>
...
...
@@ -49,12 +49,24 @@ export default {
},
isActive
(
route
)
{
return
route
.
path
===
this
.
$route
.
path
||
route
.
name
===
this
.
$route
.
name
},
moveToCurrentTag
()
{
const
tags
=
this
.
$refs
.
tag
this
.
$nextTick
(()
=>
{
for
(
const
tag
of
tags
)
{
if
(
tag
.
to
===
this
.
$route
.
path
)
{
this
.
$refs
.
scrollPane
.
moveToTarget
(
tag
.
$el
)
break
}
}
})
}
},
watch
:
{
$route
()
{
this
.
addViewTags
()
this
.
moveToCurrentTag
()
}
}
}
...
...
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