@ray-js/graffiti 1.1.4 → 1.1.6-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -150,12 +150,8 @@ Component({
150
150
  },
151
151
  drawData: {
152
152
  // 初始绘制数据
153
- type: null,
154
- observer(newValue) {
155
- if (newValue && this.render) {
156
- this.render.drawData(newValue);
157
- }
158
- }
153
+ type: Array,
154
+ value: []
159
155
  }
160
156
  },
161
157
  data: {
@@ -178,7 +174,8 @@ Component({
178
174
  pixelGap,
179
175
  mode,
180
176
  scale,
181
- isDragging
177
+ isDragging,
178
+ drawData
182
179
  } = this.data;
183
180
  width = getDeviceRealPx(width);
184
181
  height = getDeviceRealPx(height);
@@ -219,11 +216,9 @@ Component({
219
216
  penColor: this.data.penColor,
220
217
  scale: scale,
221
218
  isDragging: isDragging,
222
- boxRect: rect
219
+ boxRect: rect,
220
+ drawData: drawData
223
221
  });
224
- if (this.data.drawData) {
225
- this.render.drawData(this.data.drawData);
226
- }
227
222
  }
228
223
  },
229
224
  methods: {
@@ -17,6 +17,7 @@ export default Render({
17
17
  scale,
18
18
  isDragging,
19
19
  boxRect,
20
+ drawData,
20
21
  }) {
21
22
  this.scale = scale || 1;
22
23
  this.isDragging = isDragging || false;
@@ -75,6 +76,9 @@ export default Render({
75
76
  // 初始化画布, 绘制像素点
76
77
  this.createPixel(pixelColor);
77
78
 
79
+ // 初始化传入的绘制数据
80
+ this.initDrawData(Array.isArray(drawData) ? drawData : []);
81
+
78
82
  this.updateScale(scale);
79
83
 
80
84
  canvas.addEventListener('touchstart', this.handleTouchstart, false);
@@ -274,8 +278,7 @@ export default Render({
274
278
  this.callMethod('genImageData', { base64, gridData: this.gridData });
275
279
  },
276
280
 
277
- drawData(list) {
278
- console.log('render drawData', list);
281
+ initDrawData(list) {
279
282
  for (const item of list) {
280
283
  this.fillPixel(item.x, item.y, item.color);
281
284
  }
package/lib/props.js CHANGED
@@ -17,6 +17,7 @@ export const defaultProps = {
17
17
  clearTrigger: 0,
18
18
  scale: 1,
19
19
  isDragging: false,
20
+ drawData: [],
20
21
  onStrokeChange: () => null,
21
22
  onSaveData: () => null
22
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/graffiti",
3
- "version": "1.1.4",
3
+ "version": "1.1.6-beta.1",
4
4
  "description": "画布涂鸦组件",
5
5
  "main": "lib/index",
6
6
  "files": [