Skip to content

Commit

Permalink
feat: <v-clicks fade>
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Oct 4, 2021
1 parent e4c0e67 commit 0c5db01
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
14 changes: 13 additions & 1 deletion packages/client/builtin/VClick.ts
Expand Up @@ -17,8 +17,20 @@ export default defineComponent({
type: Boolean,
default: false,
},
fade: {
type: Boolean,
default: false,
},
},
render() {
return createVNode(VClicks, { every: 99999, at: this.at, hide: this.hide }, { default: this.$slots.default })
return createVNode(
VClicks, {
every: 99999,
at: this.at,
hide: this.hide,
fade: this.fade,
},
{ default: this.$slots.default },
)
},
})
20 changes: 15 additions & 5 deletions packages/client/builtin/VClicks.ts
Expand Up @@ -21,16 +21,26 @@ export default defineComponent({
type: Boolean,
default: false,
},
fade: {
type: Boolean,
default: false,
},
},
render() {
const click = resolveDirective('click')!
const after = resolveDirective('after')!

const applyDirective = (node: VNode, directive: Directive, delta: number) => {
if (this.at != null)
return withDirectives(node, [[directive, +this.at + delta, '', { hide: this.hide }]])
return withDirectives(node, [[directive, null, '', { hide: this.hide }]])
}
const applyDirective = (node: VNode, directive: Directive, delta: number) =>
withDirectives(node, [[
directive,
this.at != null
? +this.at + delta
: null, '',
{
hide: this.hide,
fade: this.fade,
},
]])

let defaults = this.$slots.default?.()

Expand Down
4 changes: 2 additions & 2 deletions packages/client/modules/directives.ts
Expand Up @@ -33,8 +33,8 @@ export default function createDirectives() {
const clicks = dirInject(dir, injectionClicks)
const orderMap = dirInject(dir, injectionOrderMap)

const hide = dir.modifiers.hide
const fade = dir.modifiers.fade
const hide = dir.modifiers.hide !== false && dir.modifiers.hide != null
const fade = dir.modifiers.fade !== false && dir.modifiers.fade != null

const prev = elements?.value?.length || 0

Expand Down

0 comments on commit 0c5db01

Please sign in to comment.