-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
76 lines (69 loc) · 2.91 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { createJavascriptTransition, createSimpleTransition } from './src/createTransition'
import ExpandTransitionGenerator from './src/transition-expand'
import InterlaceTransitionGenerator from './src/transition-interlace'
import CssRule from './src/utils/cssRule'
/**
* Javascript transitions
* 扩展用法
* .expand-transition-enter,
* .expand-transition-leave-to {
* opacity: 0;
* transform: 等等
* }
* **/
/************************************ 展开 ************************************* */
/** 展开高度 过渡*/
export const ExpandTransition = createJavascriptTransition(
'expand-transition',
ExpandTransitionGenerator()
)
/** 展开宽度 过渡*/
export const ExpandXTransition = createJavascriptTransition(
'expand-x-transition',
ExpandTransitionGenerator(true)
)
/** 默认的 "展开" 过渡样式 */
const expandCssRule = new CssRule()
;((classText: string) => {
expandCssRule.add('.expand-transition-enter-active', classText)
expandCssRule.add('.expand-transition-leave-active', classText)
})('transition: 0.35s cubic-bezier(0.075, 0.82, 0.165, 1) all; transform-origin: top;')
;((classText: string) => {
expandCssRule.add('.expand-transition-enter', classText)
expandCssRule.add('.expand-transition-leave-to', classText)
})('opacity: 0;transform: scaleY(0.8);')
/************************************ 列表交错过渡 ************************************* */
/** 列表交错过渡 */
export const InterlaceTransition = createJavascriptTransition(
'interlace-transition',
InterlaceTransitionGenerator(),
true
)
export const InterlaceReverseTransition = createJavascriptTransition(
'interlace-transition',
InterlaceTransitionGenerator(false, true),
true
)
/** 列表交错过渡 */
export const InterlaceXTransition = createJavascriptTransition(
'interlace-x-transition',
InterlaceTransitionGenerator(true),
true
)
/** 默认的 "列表交错过渡" 过渡样式 */
const interlaceCssRule = new CssRule()
;((classText: string) => {
interlaceCssRule.add('.interlace-transition-before-enter', classText)
interlaceCssRule.add('.interlace-x-transition-enter-active', classText)
})('transition: 1s cubic-bezier(0.075, 0.82, 0.165, 1) all')
/************************************ 滚动过渡 ************************************* */
export const ScrollYTransition = createSimpleTransition('scroll-y-transition')
/** 默认的 "列表交错过渡" 过渡样式 */
const ScrollYCssRule = new CssRule()
;((prefix: string) => {
ScrollYCssRule.add(`${prefix}-enter-from`, 'opacity: 0;transform: translateY(-15px);')
ScrollYCssRule.add(`${prefix}-enter-active`, 'transition: 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);')
ScrollYCssRule.add(`${prefix}-move`, 'transition: transform 0.6s;')
ScrollYCssRule.add(`${prefix}-leave-active`, 'transition: 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);')
ScrollYCssRule.add(`${prefix}-leave-to`, 'opacity: 0;transform: translateY(15px);')
})('.scroll-y-transition')