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
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Sean King
admin-fe
Commits
705b9cce
Commit
705b9cce
authored
7 years ago
by
Pan
Browse files
Options
Downloads
Patches
Plain Diff
add(tags-view): moveToCurrentTag
parent
c84964d7
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/ScrollPane/index.vue
+23
-3
23 additions, 3 deletions
src/components/ScrollPane/index.vue
src/views/layout/components/TagsView.vue
+14
-2
14 additions, 2 deletions
src/views/layout/components/TagsView.vue
with
37 additions
and
5 deletions
src/components/ScrollPane/index.vue
+
23
−
3
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
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/views/layout/components/TagsView.vue
+
14
−
2
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
()
}
}
}
...
...
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