Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
release: v0.15.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepbox8646 committed Apr 26, 2024
1 parent fbe5661 commit 7d29215
Show file tree
Hide file tree
Showing 18 changed files with 93 additions and 26 deletions.
6 changes: 3 additions & 3 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"private": true,
"dependencies": {
"canvaskit-wasm": "0.39.1",
"newcar": "workspace:0.15.0",
"@newcar/mod-markdown": "workspace:0.1.4",
"@newcar/mod-geometry": "workspace:0.1.4"
"newcar": "workspace:0.15.1",
"@newcar/mod-markdown": "workspace:0.1.5",
"@newcar/mod-geometry": "workspace:0.1.5"
}
}
9 changes: 9 additions & 0 deletions mods/mod-geometry/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @newcar/mod-geometry

## 0.1.5

### Patch Changes

- Updated dependencies
- @newcar/basic@0.15.1
- @newcar/core@0.15.1
- @newcar/utils@0.15.1

## 0.1.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-geometry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/mod-geometry",
"version": "0.1.4",
"version": "0.1.5",
"description": "",
"scripts": {
"publish": "npm publish",
Expand Down
9 changes: 9 additions & 0 deletions mods/mod-markdown/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @newcar/mod-markdown

## 0.1.5

### Patch Changes

- Updated dependencies
- @newcar/basic@0.15.1
- @newcar/core@0.15.1
- @newcar/utils@0.15.1

## 0.1.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-markdown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/mod-markdown",
"version": "0.1.4",
"version": "0.1.5",
"description": "",
"scripts": {
"publish": "npm publish",
Expand Down
9 changes: 9 additions & 0 deletions mods/mod-math/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @newcar/mod-math

## 0.3.9

### Patch Changes

- Updated dependencies
- @newcar/basic@0.15.1
- @newcar/core@0.15.1
- @newcar/utils@0.15.1

## 0.3.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion mods/mod-math/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/mod-math",
"version": "0.3.8",
"version": "0.3.9",
"description": "",
"scripts": {
"publish": "npm publish",
Expand Down
9 changes: 9 additions & 0 deletions packages/basic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @newcar/basic

## 0.15.1

### Patch Changes

- perfect `changeProperty` and `changeStyle`
- Updated dependencies
- @newcar/core@0.15.1
- @newcar/utils@0.15.1

## 0.15.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/basic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/basic",
"version": "0.15.0",
"version": "0.15.1",
"description": "The basic objects, animations and interpolators of newcar.",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @newcar/core

## 0.15.1

### Patch Changes

- perfect `changeProperty` and `changeStyle`
- Updated dependencies
- @newcar/utils@0.15.1

## 0.15.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/core",
"version": "0.15.0",
"version": "0.15.1",
"description": "The core of newcar.",
"scripts": {
"publish": "npm publish",
Expand Down
30 changes: 15 additions & 15 deletions packages/core/src/apiChangeStyle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Widget } from './widget'
import type { Widget, WidgetStyle } from './widget'
import type { Animation } from './animation'
import { defineAnimation } from './animation'
import type { MaybeArray, PickNumberKeys } from './types'
Expand All @@ -9,17 +9,17 @@ import type { MaybeArray, PickNumberKeys } from './types'
type EasingFunction = (progress: number) => number

/**
* Creates an animation that changes one or more properties of a widget over time.
* Creates an animation that changes one or more style properties of a widget over time.
* The `from` and `to` values are either provided directly or through `params` when calling `Widget.animate`.
* Additionally, an easing function can be provided either directly or through `params` to adjust the animation progress.
* @param propertyName The name of the property or array of properties to change.
* @param defaultFrom Optional default starting value or array of starting values for the property/properties.
* @param defaultTo Optional default ending value or array of ending values for the property/properties.
* @param propertyName The name of the style property or array of style properties to change.
* @param defaultFrom Optional default starting value or array of starting values for the style property/properties.
* @param defaultTo Optional default ending value or array of ending values for the style property/properties.
* @param by Optional easing function to adjust the animation progress, can be overridden by params.by.
* @returns An Animation object.
*/
export function changeProperty<T extends Widget>(
propertyName: MaybeArray<PickNumberKeys<T>>,
export function changeStyle<T extends Widget>(
propertyName: MaybeArray<PickNumberKeys<WidgetStyle>>,
defaultFrom?: MaybeArray<number>,
defaultTo?: MaybeArray<number>,
by?: EasingFunction,
Expand All @@ -34,8 +34,8 @@ export function changeProperty<T extends Widget>(
const easingFunction = params.by ? params.by : by
const adjustedProcess = easingFunction ? easingFunction(process) : process

let from = params.from !== undefined ? params.from : (defaultFrom !== undefined ? defaultFrom : Array.isArray(propertyName) ? propertyName.map(prop => widget[prop]) : widget[propertyName]);
let to = params.to !== undefined ? params.to : (defaultTo !== undefined ? defaultTo : Array.isArray(propertyName) ? propertyName.map(prop => widget[prop]) : widget[propertyName]);
let from = params.from !== undefined ? params.from : (defaultFrom !== undefined ? defaultFrom : Array.isArray(propertyName) ? propertyName.map(prop => widget.style[prop]) : widget.style[propertyName]);
let to = params.to !== undefined ? params.to : (defaultTo !== undefined ? defaultTo : Array.isArray(propertyName) ? propertyName.map(prop => widget.style[prop]) : widget.style[propertyName]);

if (!Array.isArray(from))
from = [from]
Expand All @@ -44,23 +44,23 @@ export function changeProperty<T extends Widget>(
to = [to]

const applyChange = (
prop: PickNumberKeys<T>,
prop: PickNumberKeys<WidgetStyle>,
start: number,
end: number,
) => {
const valueChange = (end - start) * adjustedProcess
;(widget[prop] as any) = start + valueChange
;(widget.style[prop as keyof WidgetStyle] as any) = start + valueChange
}

if (Array.isArray(propertyName)) {
propertyName.forEach((prop, index) => {
const startValue = from[index] !== undefined ? from[index] : widget[prop]
const endValue = to[index] !== undefined ? to[index] : widget[prop]
const startValue = from[index] !== undefined ? from[index] : widget.style[prop]
const endValue = to[index] !== undefined ? to[index] : widget.style[prop]
applyChange(prop, startValue, endValue)
})
} else {
const startValue = from[0] !== undefined ? from[0] : widget[propertyName]
const endValue = to[0] !== undefined ? to[0] : widget[propertyName]
const startValue = from[0] !== undefined ? from[0] : widget.style[propertyName]
const endValue = to[0] !== undefined ? to[0] : widget.style[propertyName]
applyChange(propertyName, startValue, endValue)
}
},
Expand Down
11 changes: 11 additions & 0 deletions packages/newcar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# newcar

## 0.15.1

### Patch Changes

- perfect `changeProperty` and `changeStyle`
- Updated dependencies
- @newcar/basic@0.15.1
- @newcar/core@0.15.1
- @newcar/recorder@0.15.1
- @newcar/utils@0.15.1

## 0.15.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/newcar/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "newcar",
"version": "0.15.0",
"version": "0.15.1",
"author": "BugDuck Team",
"type": "module",
"description": "A Highly configurable universal advanced engine, Born for creating animation rapidly.",
Expand Down
6 changes: 6 additions & 0 deletions packages/recorder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @newcar/recorder

## 0.15.1

### Patch Changes

- perfect `changeProperty` and `changeStyle`

## 0.15.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/recorder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/recorder",
"version": "0.15.0",
"version": "0.15.1",
"description": "The utils of newcar",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @newcar/utils

## 0.15.1

### Patch Changes

- perfect `changeProperty` and `changeStyle`

## 0.15.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newcar/utils",
"version": "0.15.0",
"version": "0.15.1",
"description": "The utils of newcar",
"author": "BugDuck Team",
"license": "Apache-2.0",
Expand Down

0 comments on commit 7d29215

Please sign in to comment.