소스 검색

ColorPicker: while watch hue and value with computed

kingwl 8 년 전
부모
커밋
94e6288286
1개의 변경된 파일6개의 추가작업 그리고 11개의 파일을 삭제
  1. 6 11
      packages/color-picker/src/components/sv-panel.vue

+ 6 - 11
packages/color-picker/src/components/sv-panel.vue

@@ -27,18 +27,13 @@
       }
     },
 
-    watch: {
-      'color.value'() {
-        this.update();
-      },
-      /*
-       * FIXME: trigger update twice
-       * when saturation is zero, modify hue will not change value.
-       * panel also not to be updated. so i subscribe the hue change to update panel too.
-       * but if hue changed, update will be call twice.
-       */
-      'color._hue'() {
+    computed: {
+      // while watch hue and value with computed to call update once
+      colorValue() {
+        const hue = this.color.get('hue');
+        const value = this.color.get('value');
         this.update();
+        return { hue, value };
       }
     },