Skip to content

Commit d1b8280

Browse files
committed
update tween-one and core-js, fix parallax tween
1 parent bdf7ba3 commit d1b8280

File tree

9 files changed

+38
-28
lines changed

9 files changed

+38
-28
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-scroll-anim",
3-
"version": "2.5.6",
3+
"version": "2.5.7",
44
"description": "scroll-anim anim component for react",
55
"keywords": [
66
"react",
@@ -61,16 +61,16 @@
6161
},
6262
"devDependencies": {
6363
"@types/react": "^16.0.0",
64-
"core-js": "^2.5.1",
64+
"core-js": "^3.0.0",
6565
"expect.js": "0.3.x",
6666
"pre-commit": "1.x",
6767
"precommit-hook": "1.x",
68+
"rc-animate": "2.x",
69+
"rc-queue-anim": "^1.3.0",
6870
"rc-test": "6.x",
6971
"rc-tools": "8.x",
7072
"react": "^16.0.0",
7173
"react-dom": "^16.0.0",
72-
"rc-animate": "2.x",
73-
"rc-queue-anim": "^1.3.0",
7474
"typescript": "3.x"
7575
},
7676
"pre-commit": [
@@ -80,7 +80,7 @@
8080
"babel-runtime": "6.x",
8181
"prop-types": "^15.6.0",
8282
"raf": "3.x",
83-
"rc-tween-one": "^2.2.0",
83+
"rc-tween-one": "^2.4.0",
8484
"tween-functions": "1.x"
8585
}
8686
}

src/EventDispatcher.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
type ICallback = (e?: { type: string, target: HTMLElement }) => void;
22
export default class EventDispatcher {
3-
static addEventListener(
3+
public static addEventListener(
44
type: string,
55
callback: ICallback,
66
target: HTMLElement
77
): void;
8-
static removeEventListener(
8+
public static removeEventListener(
99
type: string,
1010
callback: ICallback,
1111
target: HTMLElement,
1212
force?: boolean
1313
): void;
14-
static removeAllType(type: string, target: HTMLElement): void;
15-
static reAllType(type: string, target: HTMLElement): void
14+
public static removeAllType(type: string, target: HTMLElement): void;
15+
public static reAllType(type: string, target: HTMLElement): void
1616
}

src/ScrollElement.d.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,26 @@ export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
44

55
export declare type IPlayScaleType = number | string | [number | string, number | string];
66

7-
export declare type IChangeCallBackype = { mode: 'enter' | 'leave', id: string };
7+
export interface IChangeCallBackType {
8+
mode: 'enter' | 'leave',
9+
id: string
10+
}
811

9-
export declare type IScrollCallBackype = { id: string, domEvent: Event, scrollTop: number, offsetTop: number, showHeight: number };
12+
export interface IScrollCallBackType {
13+
id: string,
14+
domEvent: Event,
15+
scrollTop: number,
16+
offsetTop: number,
17+
showHeight: number
18+
}
1019

1120
export interface IProps<T> extends Omit<React.HTMLAttributes<T>, 'onChange' | 'onScroll'> {
1221
targetId?: string;
1322
playScale?: IPlayScaleType;
1423
replay?: boolean;
1524
location?: string;
16-
onChange?: (e: IChangeCallBackype) => void;
17-
onScroll?: (e: IScrollCallBackype) => void;
25+
onChange?: (e: IChangeCallBackType) => void;
26+
onScroll?: (e: IScrollCallBackType) => void;
1827
component?: string | React.ReactNode;
1928
componentProps?: {};
2029
}

src/ScrollLink.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { IEaseType } from 'rc-tween-one/typings/AnimObject';
12
import * as React from 'react';
23
import { Omit } from './ScrollElement';
3-
import { IEaseType } from 'rc-tween-one/typings/AnimObject';
44

55
export interface IProps<T> extends Omit<React.HTMLAttributes<T>, 'onFocus'> {
66
to: string

src/ScrollParallax.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { IAnimType, IBezierProps, IChildrenProps, IEaseCallBack, IEaseType, IStyleAnimProps } from 'rc-tween-one/typings/AnimObject';
12
import * as React from 'react';
2-
import { IEaseCallBack, IAnimType, IEaseType, IBezierProps, IChildrenProps, IStyleAnimProps } from 'rc-tween-one/typings/AnimObject';
33

44
export interface IAnimProps extends IStyleAnimProps {
55
playScale?: number[];

src/ScrollParallax.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import ReactDom from 'react-dom';
33
import PropTypes from 'prop-types';
44
import easingTypes from 'tween-functions';
5-
import Timeline from 'rc-tween-one/lib/Tween';
5+
import { Tween as Timeline } from 'rc-tween-one';
66
import ticker from 'rc-tween-one/lib/ticker';
77
import EventListener from './EventDispatcher';
88
import { noop, dataToArray, objectEqual, currentScrollTop, windowHeight } from './util';
@@ -112,7 +112,8 @@ class ScrollParallax extends React.Component {
112112
if (this.timeline) {
113113
this.timeline.resetDefaultStyle();
114114
}
115-
this.timeline = new Timeline(this.dom, this.defaultTweenData, {});
115+
this.timeline = new Timeline(this.dom, this.defaultTweenData);
116+
this.timeline.init();
116117
this.scrollEventListener();
117118
}
118119

src/ScrollScreen.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export interface IVarsProps {
99
}
1010

1111
export default class RcSCrollScreen {
12-
static init: (vars?: IVarsProps) => void;
13-
static unMount: () => void;
12+
public static init: (vars?: IVarsProps) => void;
13+
public static unMount: () => void;
1414
}

src/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// Project: https://github.com/react-component/scroll-anim
33
// Definitions by: jljsj33 <https://github.com/jljsj33>
44
// Definitions: https://github.com/react-component/scroll-anim
5+
import ScrollEvent from './EventDispatcher';
56
import ScrollElement from './ScrollElement';
7+
import ScrollLink from './ScrollLink';
68
import ScrollOverPack from './ScrollOverPack';
79
import ScrollParallax from './ScrollParallax';
8-
import ScrollLink from './ScrollLink';
910
import Screen from './ScrollScreen';
10-
import ScrollEvent from './EventDispatcher';
1111

1212
export const Element: typeof ScrollElement;
1313
export const OverPack: typeof ScrollOverPack;

tests/test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as React from 'react';
22
// import { Parallax, Element, OverPack, Link, scrollScreen, Event } from '../typings';
3+
import Event from '../src/EventDispatcher';
34
import Element from '../src/ScrollElement';
5+
import Link from '../src/ScrollLink';
46
import OverPack from '../src/ScrollOverPack';
57
import Parallax from '../src/ScrollParallax';
6-
import Link from '../src/ScrollLink';
7-
import Event from '../src/EventDispatcher';
88
import scrollScreen from '../src/ScrollScreen';
99

10-
function TCompoent(props: { a?: string, b?: number }) {
10+
function TComponent(props: { a?: string, b?: number }) {
1111
return (
1212
<div>
1313
{props.a}
@@ -18,15 +18,15 @@ function TCompoent(props: { a?: string, b?: number }) {
1818

1919
function Text() {
2020
scrollScreen.init();
21-
Event.addEventListener('r', () => { }, document.body);
21+
Event.addEventListener('r', (e) => { console.log(e); }, document.body);
2222
return (
2323
<div>
24-
<Element targetId="a"><div key="1">test</div></Element>
24+
<Element targetId="a" onChange={(e) => { console.log(e.mode, e.id); }}><div key="1">test</div></Element>
2525
<Parallax
2626
animation={{ x: 100 }}
27-
component={TCompoent}
27+
component={TComponent}
2828
componentProps={{ a: 'number', b: 100 }}
29-
always
29+
always={true}
3030
>
3131
abc
3232
</Parallax>

0 commit comments

Comments
 (0)