Changeset - 078e6e7ec206
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 20 months ago 2023-06-03 23:02:34
drewp@bigasterisk.com
shorter sliders send fewer events
2 files changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
light9/fade/Light9EffectFader.ts
Show inline comments
 
@@ -74,25 +74,25 @@ class EffectFader {
 
}
 

	
 
@customElement("light9-effect-fader")
 
export class Light9EffectFader extends LitElement {
 
  static styles = [
 
    css`
 
      :host {
 
        display: inline-block;
 
        border: 2px gray outset;
 
        background: #272727;
 
      }
 
      light9-fader {
 
        margin: 4px;
 
        margin: 0px;
 
        width: 100%;
 
      }
 
    `,
 
  ];
 
  render() {
 
    if (this.conf === undefined || this.conf.value === undefined) {
 
      return html`...`;
 
    }
 
    return html`
 
      <div><resource-display .uri=${this.uri}></resource-display>
 
      <light9-fader .value=${this.conf.value} @change=${this.onSliderInput}></light9-fader>
 
      <div>${this.conf.value.toPrecision(3)}</div>
light9/fade/Light9Fader.ts
Show inline comments
 
@@ -8,42 +8,42 @@ const log = debug("fade");
 
class Drag {
 
  constructor(public startDragPxY: number, public startDragValue: number) {}
 
}
 

	
 
@customElement("light9-fader")
 
export class Light9Fader extends LitElement {
 
  static styles = [
 
    css`
 
      :host {
 
        display: inline-block;
 
        border: 2px gray inset;
 
        background: #000;
 
        height: 130px;
 
        height: 80px;
 
      }
 
      #handle {
 
        background: gray;
 
        border: 5px gray outset;
 
        position: relative;
 
        left: 0;
 
        right: -25px;
 
      }
 
    `,
 
  ];
 

	
 
  @property() value: number = 0;
 

	
 
  @query("#handle") handleEl!: HTMLElement;
 

	
 
  troughHeight = 130 - 2 - 2 - 5 - 5;
 
  handleHeight = 20;
 
  troughHeight = 80 - 2 - 2 - 5 - 5;
 
  handleHeight = 10;
 

	
 
  drag?: Drag;
 
  unmutedValue: number = 1;
 

	
 
  render() {
 
    return html` <div id="handle"><hr /></div> `;
 
  }
 

	
 
  protected update(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
 
    super.update(changedProperties);
 
    if (changedProperties.has("value")) {
 
      
 
@@ -85,25 +85,25 @@ export class Light9Fader extends LitElem
 
      } else if (ev.buttons == 2) {
 
        // RMB in trough
 
        this.onRmb();
 
      }
 
    });
 

	
 
    this.addEventListener("contextmenu", (event) => {
 
      event.preventDefault();
 
    });
 

	
 
    this.addEventListener("wheel", (ev: WheelEvent) => {
 
      ev.preventDefault();
 
      this.value += ev.deltaY / 120 * -.05;
 
      this.value += ev.deltaY / this.troughHeight * -.05;
 
      this.valueChangedFromUi()
 
    });
 

	
 
    const maybeDrag = (ev: MouseEvent) => {
 
      if (ev.buttons != 1) return;
 
      if (this.drag === undefined) return;
 
      ev.stopPropagation();
 
      this.onMouseDrag(ev.clientY - this.drag.startDragPxY!);
 
    };
 
    hand.addEventListener("mousemove", maybeDrag);
 
    this.addEventListener("mousemove", maybeDrag);
 
    window.addEventListener("mousemove", maybeDrag);
0 comments (0 inline, 0 general)