question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

modal not begin from bottom

See original GitHub issue

I try to make modal that begin from bottom of the screen until the middle of screen, but it always have little space between bottom to the modal and I don’t want it. screenshot_2019-01-26-18-38-00-567_com torme_mobile I want the modal begin from the bottom.

import React, { Component } from 'react'
import { View, Text, Platform, Linking, Image } from 'react-native'
import { Button } from '..'
import style from './style'
import Modal from 'react-native-modal'
import Colors from '../../utils/Colors'

class MakeAppointmentModal extends Component {
  constructor(props) {
    super(props)
    this.state = {
      modalVisible: false,
    }
  }
  componentDidMount = () => {
    try {
      this.props.onRef(this)
    } catch (e) {}
  }

  componentWillUnmount = () => {
    this.props.onRef(undefined)
  }
  setModalVisible = () => {
    this.setState(state => {
      return { modalVisible: !state.modalVisible }
    })
  }

  render() {
    const { container, view_modal, view_container_modal } = style
    return (
      <View style={container}>
        <Modal
          isVisible={this.state.modalVisible}
          backdropColor={Colors.black}
          backdropOpacity={0.8}
          animationIn='fadeInUp'
          hideModalContentWhileAnimating={true}
          animationInTiming={1000}
          animationOutTiming={600}
          useNativeDriver={true}
          onCancelPressed={() => this.setModalVisible()}
          onBackButtonPressed={() => setModalInvisible()}
          onModalHide={() => {
            // this.setModalInvisible()
          }}
          onRequestClose={() => {
            this.setModalVisible()
          }}
        >
          <View style={view_modal}>
            <View style={view_container_modal} />
          </View>
        </Modal>
      </View>
    )
  }
}
export default MakeAppointmentModal

style

import { StyleSheet, Dimensions } from 'react-native'
import Colors from '../../utils/Colors'
import { calcSize } from '../../utils'
import { DIMENSIONS } from '../../utils/Consts'

const style = StyleSheet.create({
  container: {
    flex: 1,
  },
  view_modal: {
    flex: 1,
    position: 'absolute',
    bottom: 0,
    justifyContent: 'center',
    alignItems: 'center',
    shadowOpacity: 0,
  },
  view_container_modal: {
    width: DIMENSIONS.width,
    height: DIMENSIONS.height - calcSize(250),
    backgroundColor: Colors.white,
    alignItems: 'center',
    justifyContent: 'center',
  },
})
export default style

info

"react-native-modal": "^7.0.2",
  "react": "16.6.3",
  "react-native": "0.57.8",

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
omars94commented, Aug 10, 2020

<Modal style={{ margin: 0 }}>....</Modal>

can fix your problem

4reactions
mmazzarolocommented, Jan 28, 2019

Try the following:

render() {
  const deviceWidth = Dimensions.get("window").width;
  const deviceHeight = Platform.OS === "ios" 
    ? Dimensions.get("window").height
    : 2000; // Just an high number

  return (
  <Modal
    isVisible={this.state.isVisible}
    deviceWidth={deviceWidth}
    deviceHeight={deviceHeight}
  >
    <View style={{ flex: 1 }}>
      <Text>I am the modal content!</Text>
    </View>
  </Modal>
  )
}

If it does work, please follow the README.md

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to do Modal Bootstrap appear on bottom - Stack Overflow
Use modal-dialog, not modal, otherwise the modal won't disappear if you click above it. https://jsfiddle.net/9fg7jsu3/2/ · Share.
Read more >
Modal - Bootstrap
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >
How to prevent Body from scrolling when a modal is opened ...
Given an HTML document with a modal, the task is to prevent the body element from scrolling whenever the modal is in an...
Read more >
Bootstrap Modal Position - Visual LightBox
Shown below is a static modal sample ( signifying the position and display have been overridden). Incorporated are the modal header, modal body...
Read more >
Prevent Page Scrolling When a Modal is Open | CSS-Tricks
The body will not respond when the screen is touched. However, there's still a “small” problem here. Let's say the modal trigger is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found