From 507c143461b61a5ee9bae33e0e1f13a384ac21c1 Mon Sep 17 00:00:00 2001 From: bordun Date: Thu, 9 Jul 2020 16:22:42 +0200 Subject: [PATCH] button: make tap button pulse --- src/client/widgets/basics/button.js | 17 +++++++++++++++-- src/scss/widgets/basics.scss | 18 +++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/client/widgets/basics/button.js b/src/client/widgets/basics/button.js index 77546625..eadf5825 100644 --- a/src/client/widgets/basics/button.js +++ b/src/client/widgets/basics/button.js @@ -49,8 +49,7 @@ class Button extends Widget { this.state = 0 this.active = false - - if (this.getProp('led')) this.container.classList.add('led') + this.pulse = null var tap = this.getProp('mode') === 'tap', push = this.getProp('mode') === 'push' || tap @@ -167,8 +166,22 @@ class Button extends Widget { if (options.send) this.sendValue() if (options.sync) this.changed(options) + // tap mode if (newstate && this.getProp('mode') === 'tap' && !options.tapRelease) { + + // reset value this.setValue(this.getProp('off'), {sync: false, send: false, tapRelease: true}) + + // pulse + clearTimeout(this.pulse) + this.container.classList.remove('pulse') + setTimeout(()=>{ + this.container.classList.add('pulse') + this.pulse = setTimeout(()=>{ + this.container.classList.remove('pulse') + }, 150) + }, 16) + } } diff --git a/src/scss/widgets/basics.scss b/src/scss/widgets/basics.scss index 74a150f2..3215a9c9 100644 --- a/src/scss/widgets/basics.scss +++ b/src/scss/widgets/basics.scss @@ -10,6 +10,12 @@ height: 30rem; } + +@keyframes osc-button-pulse { + 0% {opacity: var(--alpha-fill-on);} + 100% {opacity: var(--alpha-fill-off);} +} + .button-container { --alpha-fill-off: .15; @@ -46,13 +52,23 @@ border: 2rem solid transparent; } - &.on, &.active { + &.on { --alpha-fill:var(--alpha-fill-on); color: var(--color-text-on); } + // &.active { + // + // color: var(--color-text-on); + // + // } + + &.pulse inner:after { + animation: osc-button-pulse .15s 1 forwards; + } + } .switch-container {