Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(MdButton): Ripple for firefox #1468

Merged
merged 5 commits into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion src/components/MdButton/MdButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

export default new MdComponent({
name: 'MdButton',
data () {
return {
rippleActive: false
}
},
components: {
MdButtonContent
},
Expand All @@ -23,11 +28,22 @@
disabled: Boolean,
to: null
},
computed: {
rippleWorks () {
return this.mdRipple && !this.disabled
}
},
render (createElement) {
const buttonContent = createElement('md-button-content', {
attrs: {
mdRipple: this.mdRipple,
disabled: this.disabled
},
props: {
mdRippleActive: this.rippleActive
},
on: {
'update:mdRippleActive': active => this.rippleActive = active,
}
}, this.$slots.default)
let buttonAttrs = {
Expand All @@ -45,7 +61,33 @@
disabled: this.disabled,
type: !this.href && (this.type || 'button')
},
on: this.$listeners
on: {
...this.$listeners,
touchstart: event => {
if (!this.rippleWorks) {
return false
}

this.rippleActive = event
this.$listeners.touchstart && this.$listeners.touchstart(event)
},
touchmove: event => {
if (!this.rippleWorks) {
return false
}

this.rippleActive = event
this.$listeners.touchmove && this.$listeners.touchmove(event)
},
mousedown: event => {
if (!this.rippleWorks) {
return false
}

this.rippleActive = event
this.$listeners.mousedown && this.$listeners.mousedown(event)
}
}
}
let tag = 'button'

Expand Down
3 changes: 2 additions & 1 deletion src/components/MdButton/MdButtonContent.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<md-ripple :md-disabled="!mdRipple || disabled">
<md-ripple :md-disabled="!mdRipple || disabled" :md-event-trigger="false" :md-active="mdRippleActive" @update:mdActive="active => $emit('update:mdRippleActive', active)">
<div class="md-button-content">
<slot />
</div>
Expand All @@ -16,6 +16,7 @@
},
props: {
mdRipple: Boolean,
mdRippleActive: [Boolean, Event],
disabled: Boolean
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/components/MdRipple/MdRipple.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<div
:class="['md-ripple', rippleClasses]"
@touchstart.passive.stop="touchStartCheck"
@touchmove.passive.stop="touchMoveCheck"
@mousedown.passive.stop="startRipple">
@touchstart.passive="event => mdEventTrigger && touchStartCheck(event)"
@touchmove.passive="event => mdEventTrigger && touchMoveCheck(event)"
@mousedown.passive="event => mdEventTrigger && startRipple(event)">
<slot />
<md-wave v-for="ripple in ripples" :key="ripple.uuid" :class="['md-ripple-wave', waveClasses]" :style="ripple.waveStyles" @md-end="clearWave(ripple.uuid)" v-if="!isDisabled" />
</div>
Expand All @@ -23,7 +23,11 @@
props: {
mdActive: null,
mdDisabled: Boolean,
mdCentered: Boolean
mdCentered: Boolean,
mdEventTrigger: {
type: Boolean,
default: true
}
},
data: () => ({
ripples: [],
Expand Down