How to use the tinycolor2.equals function in tinycolor2

To help you get started, we’ve selected a few tinycolor2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ecomfe / veui / packages / veui / src / components / ColorPicker / ColorPicker.vue View on Github external
hsva () {
      let prevHsva = this.previousHsva
      let hsva = tinycolor(this.color).toHsv()

      // fix
      if (prevHsva.h % 360 === hsva.h % 360) {
        // 因为色相是 360度循环的,360 被 tinycolor 转换成了 0,直接用的话会导致滑块跳变,所以这个特殊处理下
        hsva.h = prevHsva.h
      }
      if (tinycolor.equals(hsva, prevHsva)) {
        // 连续纯黑色情况下(SaturationBrightnessField底部区域),
        // 传出再传入的 hsv 不一样,导致信息丢失,这里恢复一下,不然取色圈会跳变
        // hsv(40, 0.001, 0.001) -> rgb(0, 0, 0) -> hsv(0, 0, 0)
        hsva.h = prevHsva.h
        hsva.s = prevHsva.s
      }
      if (hsva.s === 0 && prevHsva.s !== 0) {
        hsva.h = prevHsva.h
      }
      if (hsva.h === undefined) {
        hsva.h = prevHsva.h
      }

      if (!this.uiProps.alpha) {
        hsva.a = 1
      }
github elrumordelaluz / coloreact / src / components / ColorPicker.js View on Github external
componentWillReceiveProps(nextProps) {
    if (!tinycolor.equals(nextProps.color, this.state.color)) {
      const c = tinycolor(nextProps.color).toHsv()
      this.setState({
        color: this.toPercentage(c),
      })
    }
  }
github HiDeoo / YaTA / src / libs / ChatterColor.ts View on Github external
private static equals(color1: MaybeColor, color2: MaybeColor) {
    if (_.isNil(color1) || _.isNil(color2)) {
      return false
    }

    return tinycolor.equals(color1, color2)
  }
github elastic / kibana / x-pack / plugins / canvas / public / components / color_palette / color_palette.tsx View on Github external
{color => {
          const match = tinycolor.equals(color, value);
          const icon = match ? (
            
          ) : null;

          return (
             !match && onChange(color)}
              className="canvasColorPalette__dot"
            >
              {icon}
            
          );
        }}
github elastic / kibana / x-pack / plugins / canvas / public / components / color_picker / color_picker.tsx View on Github external
    const match = colors.filter(color => tinycolor.equals(value, color));
    canRemove = match.length > 0;
github ecomfe / veui / packages / veui / demo / cases / ColorPicker.vue View on Github external
handlePaletteColorAdd () {
      if (tinycolor.equals(this.color, this.colors[this.colors.length - 1])) {
        return
      }
      this.colors.push(this.color)
    }
  }