aloisdeniel / aloisdeniel/react-motion-waypoint

Don't use var

Đang mở
#2 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
3
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Example form the interpolate method:

```typescript
interpolate(scroll: number, to:Waypoint) {
var totalDelta = to.scroll - this.scroll;
var amount = totalDelta == 0 ? 0 : Math.max(0.0, Math.min(1.0,(scroll - this.scroll) / totalDelta));
var result : any = {};
for (let key in this.style) {
const fromValue = this.style[key];
var toValue = to.style[key];
if(toValue == undefined) {
toValue = fromValue;
}
var valueDelta = toValue - fromValue;
var current = (fromValue == toValue) ? fromValue : (fromValue + amount * valueDelta);
result[key] = spring(current);
}
return result;
}
```

Don't use var. A quick reminder on the best practice about this topic:
- Always declare you variable as **const** first (immutable).
- Switch **const** to **let** if a mutation is needed.
- Never use **var** to ensure you will never have context problems (or just for an exception).

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.