Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gl-react-native-v2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
gl-react-native-v2
Commits
7c93033c
Commit
7c93033c
authored
Jun 12, 2016
by
Gaëtan Renaudeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exposes AnimatedSurface allowing animated width & height props
parent
63cb60d5
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133 additions
and
63 deletions
+133
-63
example/package.json
example/package.json
+2
-2
example/src/Animated/index.js
example/src/Animated/index.js
+47
-0
example/src/index.js
example/src/index.js
+8
-6
src/GLCanvas.js
src/GLCanvas.js
+1
-0
src/Surface.js
src/Surface.js
+0
-52
src/index.js
src/index.js
+21
-3
src/makeSurface.js
src/makeSurface.js
+54
-0
No files found.
example/package.json
View file @
7c93033c
...
...
@@ -11,8 +11,8 @@
"gl-react-blur"
:
"^1.2.2"
,
"gl-react-native"
:
"file:.."
,
"glsl-transitions"
:
"^2016.2.15"
,
"react"
:
"^15.
0
.0"
,
"react-native"
:
"^0.2
6.0
"
,
"react"
:
"^15.
1
.0"
,
"react-native"
:
"^0.2
7.2
"
,
"react-native-fs"
:
"^1.4.0"
,
"react-native-material-kit"
:
"PyYoshi/react-native-material-kit#rn-0.25.1"
,
"react-transform-hmr"
:
"^1.0.2"
,
...
...
example/src/Animated/index.js
0 → 100644
View file @
7c93033c
import
React
,
{
Component
}
from
"
react
"
;
import
{
View
,
Animated
}
from
"
react-native
"
;
import
{
AnimatedSurface
}
from
"
gl-react-native
"
;
import
GL
from
"
gl-react
"
;
import
Dimensions
from
"
Dimensions
"
;
const
{
width
:
viewportW
,
height
:
viewportH
}
=
Dimensions
.
get
(
"
window
"
);
export
default
class
Tests
extends
Component
{
state
=
{
heightValue
:
new
Animated
.
Value
(
200
)
};
componentWillMount
()
{
let
i
=
0
;
this
.
interval
=
setInterval
(()
=>
{
Animated
.
spring
(
this
.
state
.
heightValue
,
{
toValue
:
++
i
%
2
?
500
:
200
,
}).
start
();
},
1000
);
}
componentWillUnmount
()
{
clearInterval
(
this
.
interval
);
}
render
()
{
const
{
heightValue
}
=
this
.
state
;
return
<
View
style
=
{{
backgroundColor
:
"
#000
"
,
flex
:
1
,
paddingTop
:
60
,
alignItems
:
"
center
"
}}
>
<
AnimatedSurface
width
=
{
200
}
height
=
{
heightValue
}
>
<
GL
.
Node
shader
=
{{
frag
:
`
precision highp float;
varying vec2 uv;
void main () {
gl_FragColor = vec4(uv.x, uv.y, 0.5, 1.0);
}
`
}}
/
>
<
/AnimatedSurface
>
<
/View>
;
}
}
example/src/index.js
View file @
7c93033c
import
React
,
{
Component
,
PropTypes
}
from
"
react
"
;
import
{
StyleSheet
,
View
,
Text
,
TouchableOpacity
,
Navigator
,
AsyncStorage
}
from
"
react-native
"
;
const
screens
=
{
Simple
:
require
(
"
./Simple
"
),
AdvancedEffects
:
require
(
"
./AdvancedEffects
"
),
Hearts
:
require
(
"
./Hearts
"
),
Tests
:
require
(
"
./Tests
"
),
};
import
Simple
from
"
./Simple
"
;
import
AdvancedEffects
from
"
./AdvancedEffects
"
;
import
Hearts
from
"
./Hearts
"
;
import
Tests
from
"
./Tests
"
;
import
Animated
from
"
./Animated
"
;
const
screens
=
{
Simple
,
AdvancedEffects
,
Hearts
,
Tests
,
Animated
};
const
homeRoute
=
{
id
:
"
home
"
,
...
...
@@ -18,6 +19,7 @@ const routes = [
{
id
:
"
AdvancedEffects
"
},
{
id
:
"
Hearts
"
},
{
id
:
"
Tests
"
},
{
id
:
"
Animated
"
},
];
const
styles
=
StyleSheet
.
create
({
...
...
src/GLCanvas.js
View file @
7c93033c
...
...
@@ -104,6 +104,7 @@ class GLCanvas extends Component {
width
,
height
,
onLoad
,
onProgress
,
eventsThrough
,
...
restProps
}
=
this
.
props
;
return
<
GLCanvasNative
ref
=
"
native
"
{...
restProps
}
...
...
src/Surface.js
deleted
100644 → 0
View file @
63cb60d5
import
invariant
from
"
invariant
"
;
import
{
createSurface
}
from
"
gl-react
"
;
import
React
from
"
react
"
;
import
{
View
,
PixelRatio
}
from
"
react-native
"
;
import
GLCanvas
from
"
./GLCanvas
"
;
invariant
(
typeof
createSurface
===
"
function
"
,
"
gl-react createSurface is not a function. Check your gl-react dependency
"
);
const
getPixelRatio
=
props
=>
props
.
scale
||
PixelRatio
.
get
();
function
renderVcontent
(
width
,
height
,
id
,
children
,
{
visibleContent
})
{
const
childrenStyle
=
{
position
:
"
absolute
"
,
top
:
visibleContent
?
0
:
height
,
// as a workaround for RN, we offset the content so it is not visible but still can be rasterized
left
:
0
,
width
:
width
,
height
:
height
,
overflow
:
"
hidden
"
,
};
return
<
View
key
=
{
id
}
style
=
{
childrenStyle
}
>
{
children
}
<
/View>
;
}
function
renderVGL
(
props
)
{
return
<
GLCanvas
ref
=
"
canvas
"
{...
props
}
/>
;
}
function
renderVcontainer
({
style
,
width
,
height
,
visibleContent
,
eventsThrough
},
contents
,
renderer
)
{
const
parentStyle
=
[
{
position
:
"
relative
"
,
},
style
,
{
width
:
width
,
height
:
height
,
overflow
:
"
hidden
"
,
}
];
return
<
View
pointerEvents
=
{
!
visibleContent
&&
eventsThrough
?
"
none
"
:
"
auto
"
}
style
=
{
parentStyle
}
>
{
contents
}
{
renderer
}
<
/View>
;
}
module
.
exports
=
createSurface
(
renderVcontainer
,
renderVcontent
,
renderVGL
,
getPixelRatio
);
src/index.js
View file @
7c93033c
import
invariant
from
"
invariant
"
;
import
{
Shaders
}
from
"
gl-react
"
;
import
Surface
from
"
./Surface
"
;
import
{
NativeModules
}
from
"
react-native
"
;
import
isAnimated
from
"
gl-react/src/isAnimated
"
;
import
makeSurface
from
"
./makeSurface
"
;
import
GLCanvas
from
"
./GLCanvas
"
;
import
{
NativeModules
,
View
,
Animated
}
from
"
react-native
"
;
const
{
RNGLContext
}
=
NativeModules
;
invariant
(
RNGLContext
,
`gl-react-native: the native module is not available.
...
...
@@ -22,5 +24,21 @@ Shaders.setImplementation({
});
module
.
exports
=
{
Surface
Surface
:
makeSurface
({
View
,
GLCanvas
,
dimensionInvariant
:
(
value
,
field
)
=>
isAnimated
(
value
)
?
invariant
(
false
,
"
GL.Surface
"
+
field
+
"
prop cannot be an Animated object. Use GL.AnimatedSurface instead
"
)
:
invariant
(
typeof
value
===
"
number
"
&&
value
>
0
,
"
GL.Surface:
"
+
field
+
"
prop must be a strictly positive number
"
)
}),
AnimatedSurface
:
makeSurface
({
View
:
Animated
.
View
,
GLCanvas
:
Animated
.
createAnimatedComponent
(
GLCanvas
),
dimensionInvariant
:
(
value
,
field
)
=>
invariant
(
isAnimated
(
value
)
||
typeof
value
===
"
number
"
&&
value
>
0
,
"
GL.AnimatedSurface:
"
+
field
+
"
must be a strictly positive number OR an Animated object
"
)
}),
};
src/makeSurface.js
0 → 100644
View file @
7c93033c
import
invariant
from
"
invariant
"
;
import
{
createSurface
}
from
"
gl-react
"
;
import
React
from
"
react
"
;
import
{
PixelRatio
}
from
"
react-native
"
;
invariant
(
typeof
createSurface
===
"
function
"
,
"
gl-react createSurface is not a function. Check your gl-react dependency
"
);
const
getPixelRatio
=
props
=>
props
.
scale
||
PixelRatio
.
get
();
export
default
C
=>
{
const
renderVcontainer
=
({
style
,
width
,
height
,
visibleContent
,
eventsThrough
},
contents
,
renderer
)
=>
{
const
parentStyle
=
[
{
position
:
"
relative
"
,
},
style
,
{
width
:
width
,
height
:
height
,
overflow
:
"
hidden
"
,
}
];
return
<
C
.
View
pointerEvents
=
{
!
visibleContent
&&
eventsThrough
?
"
none
"
:
"
auto
"
}
style
=
{
parentStyle
}
>
{
contents
}
{
renderer
}
<
/C.View>
;
};
const
renderVcontent
=
(
width
,
height
,
id
,
children
,
{
visibleContent
})
=>
{
const
childrenStyle
=
{
position
:
"
absolute
"
,
top
:
visibleContent
?
0
:
height
,
// as a workaround for RN, we offset the content so it is not visible but still can be rasterized
left
:
0
,
width
:
width
,
height
:
height
,
overflow
:
"
hidden
"
,
};
return
<
C
.
View
key
=
{
id
}
style
=
{
childrenStyle
}
>
{
children
}
<
/C.View>
;
};
const
renderVGL
=
props
=>
{
C
.
dimensionInvariant
(
props
.
width
,
"
width
"
);
C
.
dimensionInvariant
(
props
.
height
,
"
height
"
);
return
<
C
.
GLCanvas
ref
=
"
canvas
"
{...
props
}
/>
;
};
return
createSurface
(
renderVcontainer
,
renderVcontent
,
renderVGL
,
getPixelRatio
,
);
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment