@taole/giftstage 0.1.4 → 0.1.6

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.
package/README.md CHANGED
@@ -194,6 +194,7 @@ Promise<GiftHandle>
194
194
  - `y: number | \`${number}%\``
195
195
  - `width?: number`
196
196
  - `height?: number`
197
+ - `useOriginalSize?: boolean`
197
198
  - `objectFit?: 'contain' | 'fill'`
198
199
  - `loop?: number`
199
200
  - `0` 表示无限循环
@@ -215,8 +216,10 @@ Promise<GiftHandle>
215
216
  - 两个都传:按传入值显示
216
217
  - 只传 `width`:`height` 按礼物原始宽高比自动补全
217
218
  - 只传 `height`:`width` 按礼物原始宽高比自动补全
218
- - 两个都不传:默认使用礼物原始宽高
219
- - 如果两个都不传,且礼物原始宽高大于当前画布,则会按画布尺寸等比缩小后再显示
219
+ - 两个都不传:按当前画布尺寸做等比 `contain`
220
+ - 也就是会在画布内尽可能放大或缩小,并保持礼物原始宽高比
221
+ - 如果 `useOriginalSize: true`,且礼物原始尺寸本身小于画布,则优先使用礼物原始尺寸
222
+ - 如果 `useOriginalSize: true`,但礼物原始尺寸超出画布,则仍会按画布尺寸等比缩小
220
223
 
221
224
  例如:
222
225
 
@@ -230,7 +233,20 @@ await stage.addGift({
230
233
  });
231
234
  ```
232
235
 
233
- 这时会使用该礼物的原始尺寸;如果原始尺寸超出舞台,则自动缩放到舞台内。
236
+ 这时会按舞台尺寸做等比适配,并保持礼物原始宽高比。
237
+
238
+ 如果你希望“小礼物保持原始尺寸,大礼物再缩小”,可以这样:
239
+
240
+ ```ts
241
+ await stage.addGift({
242
+ type: 'svga',
243
+ source: 'https://example.com/demo.svga',
244
+ x: '50%',
245
+ y: '50%',
246
+ useOriginalSize: true,
247
+ loop: 0,
248
+ });
249
+ ```
234
250
 
235
251
  ### 百分比坐标
236
252