Skip to content

Commit 61cb7a6

Browse files
committed
impr: browser tab's ticker text hover logic
1 parent 635893d commit 61cb7a6

File tree

3 files changed

+51
-17
lines changed

3 files changed

+51
-17
lines changed

src/assets/styles/Components.sass

+4
Original file line numberDiff line numberDiff line change
@@ -644,3 +644,7 @@
644644
.base-accordion
645645
& > .content
646646
@extend .no-padding, .main-bottom-section
647+
648+
.base-ticker-container
649+
.ticker
650+
will-change: transform

src/components/containers/BaseTickerContainer.vue

+33-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div
3-
class="white-space-no-wrap"
3+
class="white-space-no-wrap base-ticker-container"
44
@mouseenter="handleMouseEnter"
55
@mouseleave="handleMouseLeave"
66
>
@@ -18,6 +18,12 @@
1818
<script>
1919
export default {
2020
name: 'BaseTickerContainer',
21+
props: {
22+
isEnabled: {
23+
type: Boolean,
24+
default: true
25+
}
26+
},
2127
data () {
2228
return {
2329
content: null,
@@ -65,16 +71,18 @@ export default {
6571
} = this.$refs
6672
6773
this.ticker = ticker
74+
6875
this.content = content
6976
7077
this.setContentPaddingRight(
7178
this.gapWidth
7279
)
7380
7481
if (this.isTickable) {
75-
this.ticker.appendChild(
76-
this.contentClone
77-
)
82+
this.ticker
83+
.appendChild(
84+
this.contentClone
85+
)
7886
} else {
7987
this.setContentPaddingRight(
8088
0
@@ -83,27 +91,38 @@ export default {
8391
},
8492
methods: {
8593
handleMouseEnter () {
86-
if (this.isTickable) {
87-
this.speed = (
88-
this.speedPixels / 60
89-
)
94+
if (!this.isEnabled) { return }
9095
91-
this.animate()
92-
}
96+
this.activate()
9397
},
9498
handleMouseLeave () {
99+
if (!this.isEnabled) { return }
100+
101+
this.deactivate()
102+
},
103+
handleRequestAnimationFrame () {
104+
this.animate()
105+
},
106+
activate () {
107+
if (!this.isTickable) { return }
108+
109+
this.speed = (
110+
this.speedPixels / 60
111+
)
112+
113+
this.animate()
114+
},
115+
deactivate () {
95116
cancelAnimationFrame(
96117
this.animationFrame
97118
)
98119
99120
this.progress = 0
121+
100122
this.speed = 0
101123
102124
this.transformTicker()
103125
},
104-
handleRequestAnimationFrame () {
105-
this.animate()
106-
},
107126
animate () {
108127
this.progress -= this.speed
109128
@@ -135,7 +154,4 @@ export default {
135154
}
136155
</script>
137156
138-
<style lang="sass" scoped>
139-
.ticker
140-
will-change: transform
141-
</style>
157+
<style lang="sass" scoped></style>

src/components/layout/TheBrowserTabs/BrowserTab.vue

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
:is-invertable="!isActive"
99
@click="handleClick"
1010
@auxclick.stop="handleAuxClick"
11+
@mouseenter="handleMouseEnter"
12+
@mouseleave="handleMouseLeave"
1113
>
1214
<BaseIcon
1315
class="main-right-extrasmall-icon main-left-small-icon"
@@ -17,11 +19,13 @@
1719
/>
1820

1921
<BaseTickerContainer
22+
ref="ticker"
2023
:key="key"
2124
class="tab-name text-overflow-hidden"
2225
:class="{
2326
active: isActive
2427
}"
28+
:is-enabled="false"
2529
>
2630
{{ tabTitle }}
2731
</BaseTickerContainer>
@@ -154,6 +158,16 @@ export default {
154158
this.callTabClose()
155159
}
156160
},
161+
handleMouseEnter () {
162+
this.$refs
163+
.ticker
164+
.activate()
165+
},
166+
handleMouseLeave () {
167+
this.$refs
168+
.ticker
169+
.deactivate()
170+
},
157171
callTabClose () {
158172
window
159173
.mainProcess

0 commit comments

Comments
 (0)