javascript - Transparent overlay in React Native -
i'm trying transparent overlay sliding down in app, pretty here (all/filter-by):
so far found react-native-slider , react-native-overlay. modified slider work top bottom, moves down listview well. if using react-native-overlay, overlay static , can't move it.
i added demo code original react-native tutorial in gist. when clicking button, content should stick, , menu should overlay. transparency not important right awesome.
what smartest solution?
the key listview not moving down, set positioning of overlay absolute
. doing so, can set position , width/height of view manually , doesn't follow flexbox layout anymore. check out following short example. height of overlay fixed 360, can animate or make dynamic.
'use strict'; var react = require('react-native'); var dimensions = require('dimensions'); // can use make overlay fill entire width var { width, height } = dimensions.get('window'); var { appregistry, stylesheet, text, view, } = react; var sampleapp = react.createclass({ render: function() { return ( <view style={styles.container}> <text style={styles.welcome}> welcome react native playground! </text> <view style={[styles.overlay, { height: 360}]} /> </view> ); } }); var styles = stylesheet.create({ container: { flex: 1, justifycontent: 'center', alignitems: 'center', backgroundcolor: '#f5fcff', }, welcome: { fontsize: 20, textalign: 'center', margin: 10, }, // flex fill, position absolute, // fixed left/top, , width set window width overlay: { flex: 1, position: 'absolute', left: 0, top: 0, opacity: 0.5, backgroundcolor: 'black', width: width } }); appregistry.registercomponent('sampleapp', () => sampleapp); module.exports = sampleapp;
Comments
Post a Comment