master
chenjiajian 2023-03-20 18:36:12 +08:00
parent 480d22d60c
commit 61bc97df63
1 changed files with 7 additions and 2 deletions

View File

@ -18,6 +18,7 @@ class Scroll extends Component {
distance: 0 distance: 0
} }
dragging = false dragging = false
hovering = false
static styles = [ static styles = [
css` css`
:host { :host {
@ -85,10 +86,12 @@ class Scroll extends Component {
} }
onmouseenter() { onmouseenter() {
this.hovering = true
this.$refs.vertical.style.opacity = 0.3 this.$refs.vertical.style.opacity = 0.3
this.$refs.horizon.style.opacity = 0.3 this.$refs.horizon.style.opacity = 0.3
} }
onmouseleave() { onmouseleave() {
this.hovering = false
if (!this.dragging) { if (!this.dragging) {
this.$refs.vertical.style.opacity = 0 this.$refs.vertical.style.opacity = 0
this.$refs.horizon.style.opacity = 0 this.$refs.horizon.style.opacity = 0
@ -131,8 +134,10 @@ class Scroll extends Component {
this.onmouseup = bind(document, 'mouseup', () => { this.onmouseup = bind(document, 'mouseup', () => {
this.dragging = false this.dragging = false
this.$refs.vertical.style.opacity = 0 if (!this.hovering) {
this.$refs.horizon.style.opacity = 0 this.$refs.vertical.style.opacity = 0
this.$refs.horizon.style.opacity = 0
}
unbind(document, 'mousemove', onmousemove) unbind(document, 'mousemove', onmousemove)
}) })
} }