Giter Site home page Giter Site logo

ion-bottom-drawer's Introduction

Ionic 4 Bottom Drawer

Bottom drawer component for Ionic 4. Demo can be viewed here.

Installation

$ npm i ion-bottom-drawer --save

Dependencies

Peer dependencies [email protected] and @types/[email protected] can be installed with:

$ npm i [email protected] --save
$ npm i @types/[email protected] --save

API

Inputs

  • dockedHeight: number - Height of the drawer in docked position. Default value: 50.
  • shouldBounce: boolean - Determines whether the drawer should automatically bounce between docked, closed and top positions. Default value: True.
  • disableDrag: boolean - Disables drawer drag. Default value: False.
  • distanceTop: number - Distance from top of fully opened drawer. Default value: 0.
  • transition: string - Specify custom CSS transition for bounce movement. Default value: 0.25s ease-in-out.
  • state: DrawerState - Current state of the drawer. Possible values: DrawerState.Bottom, DrawerState.Docked, DrawerState.Top. Default value: DrawerState.Docked.
  • minimumHeight: number - Height of the drawer when in closed state calculated from the bottom of the screen. Default value: 0.

Behavior

The drawer has three basic states: closed, docked and opened to maximum 'distanceTop' from top of the screen. It will bounce by default which means it will always go to one of three states above. This can be disabled by setting 'shouldBounce' to false.

If 'ion-content' is beneath the drawer it might be bouncing itself while dragging the drawer. To prevent that add 'no-bounce' attribute to ion-content element.

<ion-content padding no-bounce>
...
</ion-content>

Integration and Usage

First, import the IonBottomDrawerModule to your app:

import { IonBottomDrawerModule } from 'ion-bottom-drawer';

@NgModule({
  imports: [
    ...,
    IonBottomDrawerModule
  ],
  ...
})
export class AppModule { }

Use it in your component template like this:

<ion-content no-bounce>Component content.<ion-content>

<ion-bottom-drawer [(state)]="drawerState" [minimumHeight]="minimumHeight" [dockedHeight]="dockedHeight"
  [shouldBounce]="shouldBounce" [distanceTop]="distanceTop">
  <div class="drawer-content">
    Bottom Drawer Content
  </div>
</ion-bottom-drawer>

Ionic 3

Last version which supported Ionic 3 was 1.0.3 and can be installed by running the following command:

$ npm i [email protected] --save

License

The MIT License (MIT)

Copyright (c) 2018 Toni Antunovic

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ion-bottom-drawer's People

Contributors

toniantunovi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ion-bottom-drawer's Issues

Suggestion: add drag resistence to drawer

Hi, first I'de like to say it's a great component!

My suggestion is adding an option to configure some resistence when dragging the drawer down (in px or % of screen height), for example if the user drag it down more than 200px then the drawer will dock or hide, but if the user drag less than that it should snap back to the top.

I dont know, but I think that this functionality will prevent users from unintentionally dragging the drawer.

Can only pull up drawer in small steps

Hello Toni,

Thanks for sharing this wonderful custom component. I am really grateful as I have been looking for something like this for quite a while.

I tried implementing it in my current project but It seems like it's not working properly.

1534758483668

Ionic 4 compatibility

Thanks for creating a working bottom drawer component. Have been looking for one with with proper states for a long time!

Unfortunately this library does not support ionic 4, because they changed the package to @ionic/angular and the Hammer dependency is missing. Got it working by modifying the imports. Don't know if I will have the time to create an PR, though.

Android hammer.js issue

ion-bottom-drawer is working fine with all iOS devices. But its not working with Android devices and web. Is there any solution to overcome this issue.

Skip States?

If I have the drawer fully at the bottom and I drag it to the very top is it possible for the drawer to go straight to the top. It currently makes me go from Bottom to Docked before I can go to Top.

Add class flag when drawer state changed

i think its better to add flag like css to ion-bottom-drawer components, when the drawer changed like top, docked, bottom.

to make the drawer easier to styling.

sorry for my english.

backdrop?

is is possible to implement a backdrop when component is docked?

shouldBounce flag not working in ionic 3.

I am setting this flag to true but doesn't seem to have the smooth transition from 'Docked' to 'Top' state and vice versa. Can you please suggest me a solution for the same. I had also included 'no-bounce' attribute to ion-content.

ps: the state transition is seemless in browser mode but in phone it doesn't seem to be effective.

Footer beneath ion-bottom-drawer

Hello @toniantunovi ,

Thanks, thanks, thanks for your work!

I want to add a footer to the ion-botton-drawer but is not working.

It works well with tabs but not on the regular pages.
Screenshot (280)

After placing it in the ion-content, this is what I get
Screenshot (282)

I'm able to get the footer and drawer but I have to scroll before I see it.
I want the footer to be at the beneath the ion-bottom-drawer like with the tabs
Screenshot (284)

Please can you help me? Thanks in advance.

mobile cannot scroll data with overflow scroll of css

I cannot scroll data with ion-list, even I used following code, hammerjs still influence child elements.

	ion-bottom-drawer{
		.scroll-content{
		    touch-action: auto !important;
		}		
	}

this is good plugin. thanks your assistance,
sorry for my bad english.

Navigation Issue while using ion-bottom-drawer

I have implemented ion-bottom-drawer in my app. And I am getting the navigation issue like blinking before navigation. And I have found its because of using 2 ion-content in the same page(One in the page and another one used inside of ion-bottom-drawer). Is there any solution for the navigation blink.

issue

changing minimum height has no effect until drawer state is changed (fix included)

Changing the minimum height has no effect until the drawer state is changed.
On some devices we want to have a different minimum height, so we change/calculate the value on ionViewEnter (or the constructor). Changing the value there has no effect because the ngOnChanges only looks for changes to the state.

Simple fix in ion-bottom-drawer.ts
from:

ngOnChanges(changes: SimpleChanges) {
    if (!changes.state) {
      return;
    }

    this._setDrawerState(changes.state.currentValue);
  }

to:

ngOnChanges(changes: SimpleChanges) {
    if (changes.state) {
        this._setDrawerState(changes.state.currentValue);
    }

    if (changes.minimumHeight) {    //allow changes to minimum height after initialization
        this._setDrawerState(this.state);
    } 
    if (changes.dockedHeight) {
        this._setDrawerState(this.state);
    } 
  }

Make div for static top area

Make it so you can top align a navbar component for example, then the content underneath inside the "drawer-content" scrolls.

e.g.:

 <div class="drawer-header"> Title bar here</div>
 <div class="drawer-content"> Scrollable content here</div>

Currently I can't see how that's possible.

Tabs support

Is there any way to use this with ion-tabs? If used globally in app.html, it is placed in front of the tabs, meaning that the tabs are unreachable.

Input textarea inside drawler doesnt work

I have an ion-textarea inside the bottom-drawler but when the keyboard appears, it seems that it brokes the height of the control. It doesnt resize good.

Screenshot_20200712-111943_Goia Tecnico
Screenshot_20200712-112039_Goia Tecnico
Screenshot_20200712-112030_Goia Tecnico

I have tried to make this on close() but doesnt work:

    this.dockedheight = 300;
    setTimeout(() => {
                this.dockedheight = 300;
                this.State = DrawerState.Bottom;
              }, 500);
    this.distancetop = 150;

Support for Ionic 4

For Ionic 4 ion-bottom-drawer is not working. The pan functionality is not working. Is there any workaround to make it work in ionic 4.

stages bottom to top

Hello,
I wonder if it is possible to skip the state automatically, today it is mandatory to go through the 3 stages bottom> docked> top, even the user pulling to the top.

Styling the Bottom Drawer

I assume the following is a quite simple question.

How can I style the ion-bottom-drawer?
The background-color and border-radius for example.

Thanks

Setting initial state of the drawer

How to set initial state of the drawer, I saw the documentation it said that [(state)] = drawerState. What are the potentials value for drawerState? Is it a string or a object and if I don't set it to anything initially it is in top

Can't bind to 'state' since it isn't a known property of 'ion-bottom-drawer'

ERROR Error: "Uncaught (in promise): Error: Template parse errors:
Can't bind to 'state' since it isn't a known property of 'ion-bottom-drawer'.

  1. If 'ion-bottom-drawer' is an Angular component and it has 'state' input, then verify that it is part of this module.
  2. If 'ion-bottom-drawer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
  3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
][(state)]="drawerState" [minimumHeight]="minimumHeight" [dockedHeight]="dockedHeight" [shouldBounce"): ng:///MapPagePageModule/MapPagePage.html@32:19 Can't bind to 'minimumHeight' since it isn't a known property of 'ion-bottom-drawer'. 1. If 'ion-bottom-drawer' is an Angular component and it has 'minimumHeight' input, then verify that it is part of this module. 2. If 'ion-bottom-drawer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. (" ][minimumHeight]="minimumHeight" [dockedHeight]="dockedHeight" [shouldBounce]="shouldBounce" [distan"): ng:///MapPagePageModule/MapPagePage.html@32:43 Can't bind to 'dockedHeight' since it isn't a known property of 'ion-bottom-drawer'. 1. If 'ion-bottom-drawer' is an Angular component and it has 'dockedHeight' input, then verify that it is part of this module. 2. If 'ion-bottom-drawer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. (" ][dockedHeight]="dockedHeight" [shouldBounce]="shouldBounce" [distanceTop]="distanceTop">
][shouldBounce]="shouldBounce" [distanceTop]="distanceTop">
Bottom "): ng:///MapPagePageModule/MapPagePage.html@33:2 Can't bind to 'distanceTop' since it isn't a known property of 'ion-bottom-drawer'. 1. If 'ion-bottom-drawer' is an Angular component and it has 'distanceTop' input, then verify that it is part of this module. 2. If 'ion-bottom-drawer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("tate" [minimumHeight]="minimumHeight" [dockedHeight]="dockedHeight" [shouldBounce]="shouldBounce" [ERROR ->][distanceTop]="distanceTop">
Bottom Drawer Content "): ng:///MapPagePageModule/MapPagePage.html@33:32 'ion-bottom-drawer' is not a known element: 1. If 'ion-bottom-drawer' is an Angular component, then verify that it is part of this module. 2. If 'ion-bottom-drawer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. (" [ERROR ->] ][(state)]="drawerState" [minimumHeight]="minimumHeight" [dockedHeight]="dockedHeight" [shouldBounce"): ng:///MapPagePageModule/MapPagePage.html@32:19 Can't bind to 'minimumHeight' since it isn't a known property of 'ion-bottom-drawer'. 1. If 'ion-bottom-drawer' is an Angular component and it has 'minimumHeight' input, then verify that it is part of this module. 2. If 'ion-bottom-drawer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. (" ][minimumHeight]="minimumHeight" [dockedHeight]="dockedHeight" [shouldBounce]="shouldBounce" [distan"): ng:///MapPagePageModule/MapPagePage.html@32:43 Can't bind to 'dockedHeight' since it isn't a known property of 'ion-bottom-drawer'. 1. If 'ion-bottom-drawer' is an Angular component and it has 'dockedHeight' input, then verify that it is part of this module. 2. If 'ion-bottom-drawer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. (" ][dockedHeight]="dockedHeight" [shouldBounce]="shouldBounce" [distanceTop]="distanceTop">
][shouldBounce]="shouldBounce" [distanceTop]="distanceTop">
Bottom "): ng:///MapPagePageModule/MapPagePage.html@33:2 Can't bind to 'distanceTop' since it isn't a known property of 'ion-bottom-drawer'. 1. If 'ion-bottom-drawer' is an Angular component and it has 'distanceTop' input, then verify that it is part of this module. 2. If 'ion-bottom-drawer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("tate" [minimumHeight]="minimumHeight" [dockedHeight]="dockedHeight" [shouldBounce]="shouldBounce" [ERROR ->][distanceTop]="distanceTop">
Bottom Drawer Content "): ng:///MapPagePageModule/MapPagePage.html@33:32 'ion-bottom-drawer' is not a known element: 1. If 'ion-bottom-drawer' is an Angular component, then verify that it is part of this module. 2. If 'ion-bottom-drawer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. (" [ERROR ->]

laggin ionic in real device.

I am using this component in my mapping application.

if is working perfect in browser. but when i enable disableDrag="true" it lagging or giving very bad experience to user in real device.

Now i have disableDrag="false" and programatic toggling it.

can someone help me

Unable to add <ion-navbar> in ion-botton-drawer

Hi There,

I am using "ion-bottom-drawer" and trying to show an inside this. But when I implement this it is hampering(hiding the back button) the outer .

Where the outer navbar is the in the component/page where I have implemented the ion-bottom-drawer.

I have a work-around "I should create a custom back icon and implement the same functionality as navbar do".

Is there a better way to do the same?
My code ---

<!-- LEAD FORM -->
<div class="header header-top">
  <ion-navbar id="one">
      <span color="primary">
          NON-DOCKED  DATA
        </span>
  </ion-navbar>    
  </div>
  <div class="header header-docked">        
    <div class=add-details>Docked Data</div> 
  </div>
  <ion-scroll scrollY="true" style="height: 90vh; border: 1px">
    <h1>FORM GOES HERE</h1>
  </ion-scroll>

<!-- bottom-drawer -->
<bottom-drawer>  
  <lead-form></lead-form>
</bottom-drawer>

https://gist.github.com/tarun-nagpal-github/d1a8a8634f485229aa3834faf9c377b8

can i scroll up view programmatically in ionic4?

I try to build a view like iOS12/13 when I click on search input my view scroll on top and show an available list of destinations.
can anyone help me?
code:

<ion-searchbar
       (ionFocus)="showFullContaint()"
       (ionCancel)="directionCancel($event)"
       placeholder="Source"
       animated
       cancelButtonText="Close"
       showCancelButton="focus"
     ></ion-searchbar>
 showFullContaint() {
    console.log('this.drawerState', this.drawerState);
    this.drawerState = 2;
  }
  directionCancel(event) {
    console.log('directionCancelevent', event);
    this.drawerState = 1;
  }

Image from iOS
Image from iOS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.