Skip to content

Commit

Permalink
fix: fix spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
Maizify committed Nov 2, 2022
1 parent 95864fa commit 9966f63
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 52 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ English | [简体中文](./CHANGELOG_CN.md)
- `Feat(Network)` Add "Start Time" of a request.
- `Feat(Network)` Use `curl` instead of `url` as the copy value of a request. (issue #410)
- `Fix(Storage)` Fix an event bug that overflow content cannot scroll. (issue #542)
- `Fix(Core)` Fix click event on `<select>` elements. (PR #577)


## 3.14.7 (2022-09-23)
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- `Feat(Network)` 新增 request 的 "Start Time"(发起时间)。
- `Feat(Network)` 使用 `curl` 格式作为 request 的复制内容,而非 `url`。 (issue #410)
- `Fix(Storage)` 修复内容溢出的元素无法滑动的问题。 (issue #542)
- `Fix(Core)` 修复 `<select>` 的点击事件问题。 (PR #577)


## 3.14.7 (2022-09-23)
Expand Down
20 changes: 11 additions & 9 deletions src/component/recycleScroller/recycleItem.svelte
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
<script lang="ts">
import { onMount, onDestroy } from 'svelte';
export let show: boolean
export let top: boolean
export let show: boolean;
export let top: boolean;
export let onResize: (height: number) => void = () => {}
export let onResize: (height: number) => void = () => {};
let item: HTMLDivElement | undefined
let item: HTMLDivElement | undefined;
let observer: ResizeObserver | null = null
let observer: ResizeObserver | null = null;
onMount(() => {
if (show) onResize(item.getBoundingClientRect().height)
if (show) {
onResize(item.getBoundingClientRect().height);
}
observer = new ResizeObserver((entries) => {
const entry = entries[0];
if (show) onResize(entry.contentRect.height)
})
observer.observe(item)
});
observer.observe(item);
});
onDestroy(() => {
observer.disconnect()
observer.disconnect();
});
</script>

Expand Down
12 changes: 6 additions & 6 deletions src/component/recycleScroller/recycleScroller.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts">
import { onMount, onDestroy } from "svelte";
import RecycleItem from "./recycleItem.svelte";
import ScrollHandler from "./scroll/scrollHandler";
import TouchTracker from "./scroll/touchTracker";
import Style from "./recycleScroller.less";
import createRecycleManager from "./recycleManager";
import { onMount, onDestroy } from 'svelte';
import RecycleItem from './recycleItem.svelte';
import ScrollHandler from './scroll/scrollHandler';
import TouchTracker from './scroll/touchTracker';
import Style from './recycleScroller.less';
import createRecycleManager from './recycleManager';
// props
export let items: any[];
Expand Down
4 changes: 2 additions & 2 deletions src/component/recycleScroller/scroll/linear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Linear {
this._x = x;
this._endX = endX;
this._v = (endX - x) / dt;
this._startTime = t || Date.now()
this._startTime = t || Date.now();
this._endTime = this._startTime + dt;
}

Expand All @@ -21,7 +21,7 @@ class Linear {

dx(t: number) {
if (this.done(t)) return 0;
return this._v
return this._v;
}

done(t: number) {
Expand Down
12 changes: 6 additions & 6 deletions src/component/recycleScroller/scroll/scroll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Friction from "./friction";
import Spring from "./spring";
import Friction from './friction';
import Spring from './spring';

/** *
* Scroll combines Friction and Spring to provide the
Expand Down Expand Up @@ -54,7 +54,7 @@ class Scroll {
if (this._enableSpring) {
this._spring.set(0, x, dx, t);
} else {
return 0
return 0;
}
} else {
const extent = this._getExtend();
Expand All @@ -63,7 +63,7 @@ class Scroll {
if (this._enableSpring) {
this._spring.set(-extent, x, dx, t);
} else {
return -extent
return -extent;
}
}
}
Expand All @@ -73,13 +73,13 @@ class Scroll {
dx(t: number) {
if (!this._toEdge) return this._friction.dx(t);
if (this._enableSpring) return this._spring.dx(t);
return 0
return 0;
}

done(t: number) {
if (!this._toEdge) return this._friction.done(t);
if (this._enableSpring) return this._spring.done(t);
return true
return true;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/component/recycleScroller/scroll/scrollHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Linear from "./linear";
import Scroll from "./scroll";
import { TrackerHandler } from "./touchTracker";
import Linear from './linear';
import Scroll from './scroll';
import { TrackerHandler } from './touchTracker';

// This function sets up a requestAnimationFrame-based timer which calls
// the callback every frame while the physics model is still moving.
Expand Down Expand Up @@ -186,7 +186,7 @@ class ScrollHandler implements TrackerHandler {
this._updatePosition(-pos);
});
} else {
this._updatePosition(position)
this._updatePosition(position);
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/component/recycleScroller/scroll/spring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,32 +96,32 @@ class Spring {
private _solution: {
x: (dt: number) => number;
dx: (dt: number) => number;
} | null
} | null;
private _endPosition: number;
private _startTime: number;

constructor(mass: number, springConstant: number, damping: number) {
this._solver = getSolver(mass, springConstant, damping);
this._solution = null
this._solution = null;
this._endPosition = 0;
this._startTime = 0;
}
x(t: number) {
if (!this._solution) return 0
if (!this._solution) return 0;
const dt = (t - this._startTime) / 1000.0;
return this._endPosition + this._solution.x(dt);
}
dx(t: number) {
if (!this._solution) return 0
if (!this._solution) return 0;
const dt = (t - this._startTime) / 1000.0;
return this._solution.dx(dt);
}
set(endPosition: number, x: number, velocity: number, t?: number) {
if (!t) t = Date.now();
this._endPosition = endPosition
this._endPosition = endPosition;
if (x == endPosition && almostZero(velocity)) return;
this._solution = this._solver(x - endPosition, velocity)
this._startTime = t
this._solution = this._solver(x - endPosition, velocity);
this._startTime = t;
}
done(t: number) {
if (!t) t = Date.now();
Expand Down
36 changes: 18 additions & 18 deletions src/component/recycleScroller/scroll/touchTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ export interface TrackerHandler {
}

const throttleRAF = (fn: () => void) => {
let timer: ReturnType<typeof requestAnimationFrame> | null = null
let call = false
let timer: ReturnType<typeof requestAnimationFrame> | null = null;
let call = false;

const notify = () => {
call = false
fn()
call = false;
fn();
timer = requestAnimationFrame(() => {
timer = null
if (call) notify()
})
});
}

const trigger = () => {
if (timer === null) {
notify()
notify();
} else {
call = true
call = true;
}
}

const cancel = () => {
if (timer) {
cancelAnimationFrame(timer)
call = false
timer = null
cancelAnimationFrame(timer);
call = false;
timer = null;
}
}

Expand Down Expand Up @@ -63,21 +63,21 @@ class TouchTracker {
};
}
}
return null
return null;
}

private _onTouchMove = () => {
const deltaX = this._historyX[this._historyX.length - 1]
const deltaY = this._historyY[this._historyY.length - 1]
const deltaX = this._historyX[this._historyX.length - 1];
const deltaY = this._historyY[this._historyY.length - 1];
this._handler.onTouchMove(deltaX, deltaY);
}

private _onWheel = throttleRAF(() => {
const deltaX = this._wheelDeltaX
const deltaY = this._wheelDeltaY
const deltaX = this._wheelDeltaX;
const deltaY = this._wheelDeltaY;

this._wheelDeltaX = 0
this._wheelDeltaY = 0
this._wheelDeltaX = 0;
this._wheelDeltaY = 0;

this._handler.onWheel(deltaX, deltaY);
})
Expand Down Expand Up @@ -108,7 +108,7 @@ class TouchTracker {
this._historyY.push(delta.y);
this._historyTime.push(Date.now());

this._onTouchMove()
this._onTouchMove();
};

handleTouchEnd = (e: TouchEvent) => {
Expand Down

0 comments on commit 9966f63

Please sign in to comment.