-
Notifications
You must be signed in to change notification settings - Fork 7
/
migrate-1.x.coffee
92 lines (85 loc) · 2.11 KB
/
migrate-1.x.coffee
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import Visual from 'vue-visual'
Vue.component 'visual',
name: 'VueVisual'
# Support Vue 1.* props that a different type signature in 2.x
props:
alt: String
poster: String|Object
image: String|Object
video: String|Object
fallback: String|Object
posterFromImage: Boolean
requireAutoplay: Boolean
assetMutator: Function
load: String|Boolean
loadPoster: String|Boolean
loadImage: String|Boolean
loadVideo: String|Boolean
loader: String|Object
loaderThrottle: Number
width: String|Number
height: String|Number
aspect: String|Number
fill: Boolean
align: String
background: String
backgroundPosition: String
transition: String
transitionPoster: String
transitionImage: String
transitionVideo: String
transitionLoader: String
autoplay: String|Boolean
autopause: String
loop: Boolean
muted: Boolean
controls: Boolean
inViewportActive: Boolean
inViewportOnce: Boolean
inViewportRootMargin: Number|String
inViewportRoot: String|Function|Object
inViewportThreshold: Number|Array
functional: true
render: (create, { props, data, children }) ->
# Clone the props
props = { ...props }
# Handle lazy-loading values differently
if props.autoplay == 'visible'
props.autopause = true
delete props.autoplay
if props.load == 'visible'
props.lazyLoad = true
delete props.load
else if props.load == true
props.lazyLoad = false
# Renamed props
[ ['load', 'autoload']
['background', 'objectFit']
['backgroundPosition', 'objectPosition']
['fill', 'expand']
].forEach ([ from, to]) ->
return unless props[from]
props[to] = props[from]
delete props[from]
# Remove unsupported props
[ 'poster'
'fallback'
'requireAutoplay'
'assetMutator'
'loadPoster'
'loadImage'
'loadVideo'
'loader'
'loaderThrottle'
'transitionPoster'
'transitionImage'
'transitionVideo'
'transitionLoader'
'inViewportActive'
'inViewportOnce'
'inViewportRootMargin'
'inViewportRoot'
'inViewportThreshold'
].forEach (key) -> delete props[key]
# Create Visual 2.x instance
create Visual, {...data, props, children }