Giter VIP home page Giter VIP logo

ng-sidebar's Introduction

ng-sidebar

⚠️ This package is deprecated and not maintained. ⚠️


NPM

Demo

Formerly called ng2-sidebar

An Angular sidebar component.

Installation

npm install --save ng-sidebar

SystemJS configuration

If you're using SystemJS, be sure to add the appropriate settings to your SystemJS config:

const map = {
  // ...
  'ng-sidebar': 'node_modules/ng-sidebar',
  // ...
};

const packages = {
  // ...
  'ng-sidebar': {
    main: 'lib/index',
    defaultExtension: 'js'
  },
  // ...
};

Changelog

See the releases page on GitHub.

Usage

Add SidebarModule to your app module:

import { SidebarModule } from 'ng-sidebar';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, SidebarModule.forRoot()],
  bootstrap: [AppComponent],
})
class AppModule {}

In your app component, simply use add a <ng-sidebar-container> wrapper, then place your <ng-sidebar>(s) and content within it. Your page content should be in some container with a ng-sidebar-content attribute.

@Component({
  selector: 'app',
  template: `
    <!-- Container for sidebar(s) + page content -->
    <ng-sidebar-container>

      <!-- A sidebar -->
      <ng-sidebar [(opened)]="_opened">
        <p>Sidebar contents</p>
      </ng-sidebar>

      <!-- Page content -->
      <div ng-sidebar-content>
        <button (click)="_toggleSidebar()">Toggle sidebar</button>
      </div>

    </ng-sidebar-container>
  `
})
class AppComponent {
  private _opened: boolean = false;

  private _toggleSidebar() {
    this._opened = !this._opened;
  }
}

If nothing seems to show up, your wrappers' heights may be collapsing. Try adding a height (e.g. height: 100vh;) to the wrapper <ng-sidebar-container> or other wrapper elements you may have. (See issue #100 for more info.)

A directive is also provided to easily close the sidebar by clicking something inside it:

<ng-sidebar>
  <a closeSidebar>Closes the sidebar</a>
</ng-sidebar>

You can also use the open() and close() functions:

<ng-sidebar #sidebar>
  <button (click)="sidebar.close()">Close sidebar</button>
</ng-sidebar>

<button (click)="sidebar.open()">Open sidebar</button>

Functions

The sidebar has a few public functions:

Function Description
open() Opens the sidebar.
close() Closes the sidebar.
triggerRerender() Manually trigger a re-render of the container. Useful if the sidebar contents might change.

Styling

Various class names are attached to the sidebar and container for easier styling.

If you are using Angular's default emulated view encapsulation, you may have to use the >>> selector to target the sidebar's classes. Check out Angular's documentation for more details. Note that the /deep/ selector will soon be deprecated.

Sidebar

Class name Description
ng-sidebar Always on the sidebar element.
ng-sidebar--opened When opened is true.
ng-sidebar--closed When opened is false.
ng-sidebar--left When position is 'left' (or the 'start'/'end' aliases are equivalent to 'left').
ng-sidebar--right When position is 'right' (or the 'start'/'end' aliases are equivalent to 'right').
ng-sidebar--top When position is 'top'.
ng-sidebar--bottom When position is 'bottom'.
ng-sidebar--over When mode is 'over'.
ng-sidebar--push When mode is 'push'.
ng-sidebar--slide When mode is 'slide'.
ng-sidebar--docked When the sidebar is docked (i.e. it is "closed" and dock is true).
ng-sidebar--inert Ignores pointer clicks. Class is applied when the sidebar is closed.
ng-sidebar--animate When animate is true for a sidebar.

Backdrop

Class name Description
ng-sidebar__backdrop Class of the backdrop div. Note that the div is only in the DOM when the backdrop is shown.

Page content

Class name Description
ng-sidebar__content Class of the wrapper div for the page content.
ng-sidebar__content--animate When animate is true for the container.

Options

<ng-sidebar-container>

Inputs

Property name Type Default Description
contentClass string Additional class name on the div wrapping the page contents.
backdropClass string Additional class name on the overlay element.
showBackdrop boolean false Controls the backdrop state of the sidebar container. This should be two-way bound.
allowSidebarBackdropControl boolean true Determines if the container component respects the sidebar's showBackdrop input option.
animate boolean true Animates the container sliding.

Outputs

Property name Callback arguments Description
showBackdropChange showBackdrop: boolean Emitted when showBackdrop is modified. This allows for you to do "two-way binding" (i.e. [(showBackdrop)]).
onBackdropClicked Emitted when a backdrop is clicked.

<ng-sidebar>

Inputs

Property name Type Default Description
opened boolean false Controls the opened state of the sidebar. This should be two-way bound.
mode 'over', 'push', 'slide' 'over' See the "Modes" section.
dock boolean false Show the sidebar as docked when closed.
dockedSize string '0px' When mode is set to 'dock', this value indicates how much of the sidebar is still visible when "closed".
position 'left', 'right', 'top', 'bottom', 'start', 'end' 'start' What side the sidebar should be docked to. 'start' and 'end' are aliases that respect the page's language (e.g. start is the same as left for English, but would be right for Hebrew.
autoCollapseHeight number Window height in pixels in which to automatically close the sidebar.
autoCollapseWidth number Window width in pixels in which to automatically close the sidebar.
autoCollapseOnInit boolean true Collapse sidebar based on autoCollapseHeight and/or autoCollapseWidth on initial render as needed.
animate boolean true Animate the opening/closing of the sidebar.
sidebarClass string Additional class name on the sidebar element.
ariaLabel string Value for the sidebar's aria-label attribute.
trapFocus boolean false Keeps focus within the sidebar when open. Note that this only works if there's one sidebar open at a time.
autoFocus boolean true Automatically focus the first focusable element in the sidebar when opened.
showBackdrop boolean false If a translucent black backdrop overlay should appear over the page contents when the sidebar is opened. This is ignored if the sidebar's parent container has its allowSidebarBackdropControl property set to true.
closeOnClickBackdrop boolean false Whether clicking on the backdrop of the open sidebar will close it.
closeOnClickOutside boolean false Whether clicking outside of the open sidebar will close it.
keyClose boolean false Close the sidebar when a keyboard button is pressed.
keyCode number 27 The key code for keyClose.

Outputs

Property name Callback arguments Description
onContentInit Corresponds with ngAfterContentInit lifecycle event of the sidebar component.
openedChange opened: boolean Emitted when opened is modified. This allows for you to do "two-way binding" (i.e. [(opened)]).
onOpenStart Emitted when the sidebar is opening.
onOpened Emitted when the sidebar is opened.
onCloseStart Emitted when the sidebar is closing.
onClosed Emitted when the sidebar is closed.
onTransitionEnd Emitted when the animation for opening or closing ends.
onModeChange mode: string Emitted when mode is changed.
onPositionChange position: string Emitted when position is changed.

Modes

over

This is the default mode. The sidebar slides in over the page contents.

push

The page contents is pushed to make space for the sidebar.

slide

The entire page slides over to show the sidebar. Note that this only works if you have one sidebar open at a time.

ng-sidebar's People

Contributors

arkon avatar cluetjen avatar dependabot[bot] avatar echeung-amzn avatar falbech avatar klemense avatar pablodoble avatar shiptoncraig 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng-sidebar's Issues

closeOnClickOutside

'closeOnClickOutside' doesn't work on iPhone Chrome (56.0.2824.79) and Safari (iOS 10.2.1)

Mode not working in angular 2

I have added mode properties which is not working at all am getting undefined error in my browser console any help

Sidebar not found

Greatings,

I have installed ng2-sibebar successfully

package.json:
"dependencies": {
"@angular/common": "~2.1.0",
"@angular/compiler": "~2.1.0",
"@angular/core": "~2.1.0",
"@angular/forms": "~2.1.0",
"@angular/http": "~2.1.0",
"@angular/platform-browser": "~2.1.0",
"@angular/platform-browser-dynamic": "~2.1.0",
"@angular/router": "~3.1.0",
"@angular/upgrade": "~2.1.0",
"angular-in-memory-web-api": "~0.1.5",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"ng2-sidebar": "^1.6.1",

app.module:
import { SidebarModule } from 'ng2-sidebar';
@NgModule({
imports: [ SidebarModule],

Error Message:
"(SystemJS) XHR error (404 Not Found) loading http://localhost:3000/ng2-sidebar
Error: XHR error (404 Not Found) loading http://localhost:3000/ng2-sidebar
at wrapFn (http://localhost:3000/node_modules/zone.js/dist/zone.js:698:17)
at ZoneDelegate.prototype.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:263:17)
at Zone.prototype.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:154:21)
at invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:335:21)
Error loading http://localhost:3000/ng2-sidebar as "ng2-sidebar" from http://localhost:3000/app/app.module.js"

Adding/removing backdrop while sidebar open

I am using ng-sidebar in a project and need to be able to add/remove the backdrop while a sidebar is already open. Is this something you've ever considered implementing?

Feature request: SidebarService

If you write a element with the closeSidebar directive directly on the lightdom of the ng2-sidebar all runs as expected.

@Component({
  selector: 'my-app',
  styles: [":host /deep/ ng2-sidebar aside { background-color: white }"],
  template: `
    <ng2-sidebar [(open)]="_open">
      <p>Sidebar contents</p>
      <a closeSidebar>Close</a>
    </ng2-sidebar>

    <button (click)="_toggleSidebar()">Toggle sidebar</button>
  `
})
export class App {
  private _open: boolean = false;

  private _toggleSidebar() {
    this._open = !this._open;
  }
}

But, if you insert and component that includes the closeSidebar directive on the lightdom, the sidebar doesn't close.

@Component({
  selector: 'my-app',
  styles: [":host /deep/ ng2-sidebar aside { background-color: white }"],
  template: `
    <ng2-sidebar [(open)]="_open">
      <p>Sidebar contents</p>
      <close-sidebar></close-sidebar>
    </ng2-sidebar>

    <button (click)="_toggleSidebar()">Toggle sidebar</button>
  `
})
export class App {
  private _open: boolean = false;

  private _toggleSidebar() {
    this._open = !this._open;
  }
}

@Component({
  selector: 'close-sidebar',
  template: `
    <a closeSidebar>Close</a>
  `
})
export class CloseSidebar{}

I think, and my team use this, ng2-sidebar needs a SidebarService that have a subscriber and the functions to execute this close function. With this, closeSidebar can put on any component inside or outside of the sidebar if it needed.

If you like, we can send a pull request with this feature.

Plnkr
Example service on our fork

Experimental support for decorators

I am able to install and start a local version of your repo but when i open a component in my editor, say the Sidebar class i get an error:

experimental support for decorators is a feature that is subject to change in a future release

Have you run into this before?

I am running tsc -v 1.8.10, if that helps?

Problems with AOT

Problems with AOT:
Error at /aot/node_modules/ng-sidebar/lib/sidebar-container.component.ngfactory.ts:93:44: Property '_sidebars' is private and only accessible within class 'SidebarContainer'.
Error at /aot/node_modules/ng-sidebar/lib/sidebar-container.component.ngfactory.ts:194:44: Property '_showBackdrop' is private and only accessible within class 'SidebarContainer'.
Error at /aot/node_modules/ng-sidebar/lib/sidebar-container.component.ngfactory.ts:197:44: Property '_getStyles' does not exist on type 'SidebarContainer'.
Error at /aot/node_modules/ng-sidebar/lib/sidebar.component.ngfactory.ts:282:18: Property '_elSidebar' is private and only accessible within class 'Sidebar'.
Error at /aot/node_modules/ng-sidebar/lib/sidebar.component.ngfactory.ts:304:44: Property '_getTransformStyle' does not exist on type 'Sidebar'.
Error at /aot/app/home/home.component.ngfactory.ts:188:44: Property '_sidebars' is private and only accessible within class 'SidebarContainer'.

Because private, protected accessors should be changed to public for any members accessed from template

Not able to integrate ng2-sidebar in application

Hi

I am getting below error after following the steps :

localhost/:52 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-sidebar.js
Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-sidebar.js
at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:647:29)
at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:236:37)
at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:136:47)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:304:33)
Error loading http://localhost:3000/node_modules/ng2-sidebar.js as "ng2-sidebar" from http://localhost:3000/app/shared/shared.module.js
at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:647:29)
at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:236:37)
at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:136:47)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js?1478617667938:304:33)
Error loading http://localhost:3000/node_modules/ng2-sidebar.js as "ng2-sidebar" from http://localhost:3000/app/shared/shared.module.js "Error while loading app"

Could you please help me on this?
Am i missing anything?

Cannot import SidebarModule

Hello,

I have this error when I import SidebarModule in my @NgModule.

SyntaxError: export declarations may only appear at top level of a module (Browser's console Error)

I am using angular2 + meteor (latest version).

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { SidebarModule } from 'ng-sidebar';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { AccountsModule } from 'angular2-meteor-accounts-ui';
import {Ng2PaginationModule} from 'ng2-pagination';
import { AgmCoreModule } from 'angular2-google-maps/core';
import { Select2Module } from 'ng2-select2';
import { AppComponent } from './app.component';
import { routes, ROUTES_PROVIDERS } from './app.routes';
import { DASHBOARD_DECLARATIONS } from './dashboard';
import { AUTH_DECLARATIONS } from "./authentication/index";
import { PARTIES_DECLARATIONS } from './parties';
import { CUSTOMERS_DECLARATIONS } from './customers';
import { SHARED_DECLARATIONS } from './shared';
import { ModalModule } from 'ng2-bootstrap/modal';
@NgModule({
  imports: [
    BrowserModule,
    SidebarModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule.forRoot(routes),
    AccountsModule,
    Ng2PaginationModule,
    AgmCoreModule.forRoot({
      apiKey: '*****'
    }),
    ModalModule.forRoot(),
    Select2Module
  ],
  declarations: [
    AppComponent,
    ...AUTH_DECLARATIONS,
    ...CUSTOMERS_DECLARATIONS,
    ...DASHBOARD_DECLARATIONS,
    ...PARTIES_DECLARATIONS,
    ...SHARED_DECLARATIONS
  ],
  providers: [
    ...ROUTES_PROVIDERS
  ],
  bootstrap: [
    AppComponent
  ]
})
export class AppModule {}

Styles on ng-sidebar not working

I am newbie to Angular2. Could you help me with below issue.
Stylings marked via the class mentioned as sidebarClass isn't getting applied.
ng-sidebar

Update demo

I need to update it so it uses angular-cli/AOT and whatnot instead of the custom-spun Webpack stuff that's going on right now.

SideBar In a container

Hi,

I tried to implement sidebar inside the child component (an div container) without success.
Is this possible? Do you have an example how to implement this?

Thanks

Custom collapse amount

As requested in #14, it'd be nice to be able to specify the collapse amount so it's not always 110% (e.g. showing a thin portion when "collapsed").

Directive for closing sidebar.

It'd be nice to be able to throw a directive on contents in the sidebar indicating that clicking them would close the sidebar, like:

<ng2-sidebar>
  <button closeSidebar>Something</button>
</ng2-sidebar>

Better way of styling

It would be nice if users could somehow pass styles as an object or something, instead of explicitly overriding the defaults via CSS?

Custom Sidebar animation

Howdy,

Is there a way to override thee default animation of the sidebar? (it pulls from left to right)

I only see the following on the documentation:
animate boolean true Animate the opening/closing of the sidebar.

I was wondering, since I'm doing some animations using angular2 api

Thanks,
e. Vazquez 😄

Sidebar does not work correctly in IE 11 in dock mode

I noticed while testing my own app that the sidebar does not work correctly in the internet explorer. I retried it with your showcase sidebar and the bug does also occur.

When the mode is set to dock, the sidebar is shown correctly:
dock initial cutted

Then after you open and close it, the content of the main page is behind the sidebar, instead of being pushed.
dock after cutted

The system I use is Windows 7 64 bit with the Internet Explorer 11 .
The push mode per se works correctly in the ie.

Add start/end aliases for positions

To better support different writing modes (e.g. RTL), the default position should simply be "start" instead of "left", adapting to the language as needed.

Unable to integrate with a new project created with angular-cli

Setup -

  • OS - macOS Sierra 10.12.2
  • Node - v6.9.2
  • NPM - v4.0.4
  • IDE - IntelliJ Idea CE

I am able to clone, compile and run the demo directly but not able to integrate ng-sidebar with my new angular-cli created project.

I have followed the instructions given in the readme.md file here
If I add just <ng-sidebar </ng-sidebar> then it doesn't give any error. However if I add the content from the github readme file

    <!-- Container for sidebar(s) + page content -->
    <ng-sidebar-container>

      <!-- A sidebar -->
      <ng-sidebar [(opened)]="_opened">
        <p>Sidebar contents</p>
      </ng-sidebar>

      <!-- Page content -->
      <button (click)="_toggleSidebar()">Toggle sidebar</button>

    </ng-sidebar-container>

then get following error.

Error -

Unhandled Promise rejection: Template parse errors:
Can't bind to 'opened' since it isn't a known property of 'ng-sidebar'.
1. If 'ng-sidebar' is an Angular component and it has 'opened' input, then verify that it is part of this module.
2. If 'ng-sidebar' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
 ("

      <!-- A sidebar -->
      <ng-sidebar [ERROR ->][(opened)]="_opened">
        <p>Sidebar contents</p>
      </ng-sidebar>
"): AppComponent@4:18
'ng-sidebar-container' is not a known element:
1. If 'ng-sidebar-container' is an Angular component, then verify that it is part of this module.
2. If 'ng-sidebar-container' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("<!-- Container for sidebar(s) + page content -->
    [ERROR ->]<ng-sidebar-container>

      <!-- A sidebar -->
"): AppComponent@1:4 ; Zone: <root> ; Task: Promise.then ; Value: SyntaxError {_nativeError: Error: Template parse errors:
Can't bind to 'opened' since it isn't a known property of 'ng-sidebar'…} Error: Template parse errors:
Can't bind to 'opened' since it isn't a known property of 'ng-sidebar'.
1. If 'ng-sidebar' is an Angular component and it has 'opened' input, then verify that it is part of this module.
2. If 'ng-sidebar' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
 ("

      <!-- A sidebar -->
      <ng-sidebar [ERROR ->][(opened)]="_opened">
        <p>Sidebar contents</p>
      </ng-sidebar>
"): AppComponent@4:18
'ng-sidebar-container' is not a known element:
1. If 'ng-sidebar-container' is an Angular component, then verify that it is part of this module.
2. If 'ng-sidebar-container' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("<!-- Container for sidebar(s) + page content -->
    [ERROR ->]<ng-sidebar-container>

Make sidebar responsive

Hi. It would be great if you can add option for automatic close sidebar when screen size is < 640px(for example) .

Problem running Karma tests after adding sidebar

This might be my fault when adding sidebar. But the sidebar shows up ok when running the website so it seems to work. The problem is that when running the karma tests I get the error pasted bellow. The problem seems to be that the array _closeDirectives.forEach is undefined for some reason when the test run. I'm new to javavscript and it seems to me like it could be the combination of tools that I use which triggers this issue. But I was thinking that it could be something to look at for stability reasons. I can send you the project that I have to trigger the issue if you are interested.

  Chrome 53.0.2785 (Mac OS X 10.11.6)
Error: Error in /Users/perka124/Documents/dev/Java/StoryTeller/ui/dist/dev/app/app.component.html:0:0 caused by: Cannot read property 'forEach' of undefined
TypeError: Cannot read property 'forEach' of undefined
    at Sidebar.ngOnDestroy (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/ng2-sidebar/lib/sidebar.component.js:58:30)
    at DebugAppView._View_AppComponent0.destroyInternal (AppComponent.ngfactory.js:312:21)
    at DebugAppView.AppView.destroyLocal (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9402:18)
    at DebugAppView.destroyLocal (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9565:47)
    at DebugAppView.AppView._destroyRecurse (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9390:18)
    at DebugAppView.AppView._destroyRecurse (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9388:29)
    at DebugAppView.AppView._destroyRecurse (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9388:29)
    at DebugAppView.AppView.destroy (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:9376:18)
    at ComponentRef_.destroy (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core.umd.js:5911:86)
    at ComponentFixture.destroy (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core-testing.umd.js:302:35)
    at eval (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core-testing.umd.js:760:78)
    at Array.forEach (native)
    at TestBed.resetTestingModule (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core-testing.umd.js:760:34)
    at Function.TestBed.resetTestingModule (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core-testing.umd.js:668:26)
    at Object.eval (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/@angular/core/bundles/core-testing.umd.js:994:21)
    at ZoneDelegate.invoke (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:203:28)
    at ProxyZoneSpec.onInvoke (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/proxy.js:72:39)
    at ZoneDelegate.invoke (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:202:34)
    at Zone.run (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:96:43)
    at Object.<anonymous> (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/jasmine-patch.js:91:50)
    at ZoneQueueRunner.jasmine.QueueRunner.ZoneQueueRunner.execute (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/jasmine-patch.js:119:42)
    at ZoneDelegate.invokeTask (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:236:37)
    at Zone.runTask (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:136:47)
    at drainMicroTaskQueue (/Users/perka124/Documents/dev/Java/StoryTeller/ui/node_modules/zone.js/dist/zone.js:368:35)
    a

Add "focusFirstItem" input to enable/disable first focusable item autofocus.

Hi @arkon.

I'm developing an Angular2 app using your sidebar component and it's really good. The problem is that I have an input tag into a sidebar and it's autofocused when the sidebar opens. In desktop browsers it's not a big deal, but in mobile browsers it causes the keyboard to raise up automatically and it disturbs the user experience a little bit on my opinion. So what do you think about adding a "focusFirstItem" input flag on the sidebar component (that could be true by default) to avoid this in case the developer wants to? I'm able to make a PR if you agree.

Regards and thanks again!

Abstract event listeners

We're binding directly to document right now, which might not work with things like web workers.

Might want to use Document/BrowserDomAdapter.

Can not use in a lazy-loaded feature module

Uncaught (in promise): Error: BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.

We are trying to use the module in a lazy loaded feature module. The error comes because you can not import Browser Module in a feature module. By using the CommonModule it will be more universally usable.

I have updated it locally by replacing the BrowserModule import with the CommonModule import and it is now working.

Is ng-sidebar unstyled

I've installed ng-sidebar in a clean angular-cli project (beta 30) and it comes up unstyled, as per the picture below? Is this by design or have I missed something?

ngsidebar

I followed the instructions in the readme.md.

I installed using npm install ng-sidebar --save

My app.component.html file looks like this:

       <!-- A sidebar -->
      <ng-sidebar [(opened)]="_opened">
        <p>Sidebar contents</p>
      </ng-sidebar>

     <!-- Page content -->
      <button (click)="_toggleSidebar()">Toggle sidebar</button>
   </ng-sidebar-container>

My app.component.ts file looks like this:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  title = 'app works!';
  private _opened: boolean = false;

  private _toggleSidebar() {
    this._opened = !this._opened;
  }
}

And my app.module.ts looks like this:

import { SidebarModule } from 'ng-sidebar';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    SidebarModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Thank you for a great project and welcome your thoughts.

Update dist structure

It'd be nice if you could do something like:

import Sidebar from 'ng2-sidebar/sidebar';

angular-seed extension

Hi arkon,

I am not able to add this module to angular-seed. I have tried multiple ways like using the System Js configuraton, project.config.ts file but nothing works.

Disable mouse click/hover events for page elements beneath the overlay

When using the showOverlay = true option, links and other DOM elements respond to my mouse cursor (hover styles and click events) when moving my mouse around the sidebar overlay.

This can cause an unexpected side effect of the user accidentally clicking a link when just trying to close the sidebar.

It would be much better to disable mouse events underneath the overlay, such as the behaviour of Bootstrap modals (http://getbootstrap.com/javascript/#modals).

I have had a quick look through the source code, and I can see 'pointer-events' is set to 'none', and I am not 100% sure how to approach fixing this.

Happy to attempt a fix and submit a PR if someone could point me in the right direction?

Thanks and good job on the package! 👍

Keyclose=false ignored.

We are using the ng-sidebar with the keyClose input set to false and keycode left as default however the sidebar is still closing when the escape key is pressed.

Two Side bars and getting errors

Thanks for the component. We are building a proto-type app, and it's finding its spot in a good place.

I was able to utilize the sidebar on the right side and it works fine.

However, when I tried to add "two" sidebars with different #, I get this odd issue.

Error: Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.
    at ExpressionChangedAfterItHasBeenCheckedError.ZoneAwareError (zone.js:992)
    at ExpressionChangedAfterItHasBeenCheckedError.BaseError [as constructor] (errors.js:22)
    at new ExpressionChangedAfterItHasBeenCheckedError (errors.js:59)
    at checkBinding (view_utils.js:167)
    at Wrapper_NgControlStatus.checkHost (/InternalFormsSharedModule/NgControlStatus/wrapper.ngfactory.js:33)
    at View_NgTableComponent10.detectChangesInternal (/AppModule/NgTableComponent/component.ngfactory.js:715)
    at View_NgTableComponent10.AppView.detectChanges (view.js:425)
    at View_NgTableComponent10.DebugAppView.detectChanges (view.js:620)
    at ViewContainer.detectChangesInNestedViews (view_container.js:67)
    at View_NgTableComponent9.detectChangesInternal (/AppModule/NgTableComponent/component.ngfactory.js:845)
    at View_NgTableComponent9.AppView.detectChanges (view.js:425)
    at View_NgTableComponent9.DebugAppView.detectChanges (view.js:620)
    at ViewContainer.detectChangesInNestedViews (view_container.js:67)
    at CompiledTemplate.proxyViewClass.View_NgTableComponent0.detectChangesInternal (/AppModule/NgTableComponent/component.ngfa

The container for this is very simple one as below.

<ng-sidebar-container>
  <!-- A sidebar -->
  <ng-sidebar #bottombar
              [(opened)]="_displayed"
              [keyClose]="false"
              [position]="'bottom'"
              [mode]="'push'">
    Test

    <button>Test</button>
    <!--<button type="button" class="btn btn-secondary" (click)="bottombar.close()">Cancel</button>-->
    <!--&lt;!&ndash;<button type="button" class="btn btn-secondary btn-sm" (click)="submit()">Delete</button>&ndash;&gt;-->
    <!--<button type="button" class="btn btn-primary" (click)="submit()">Save</button>-->
  </ng-sidebar>
</ng-sidebar-container>

Am I doing something wrong here?

The "#" name for both sidebar are different. Above is "#bottombar", but the other one is called "sidebar"..

Any help is appreciated.

Is it possible to put the page content outside of the wrapper?

<ng-sidebar-container>
  <!-- A sidebar -->
  <ng-sidebar [(opened)]="_opened">
    <p>Sidebar contents</p>
  </ng-sidebar>
  Test
</ng-sidebar-container>

Instead of above,

<ng-sidebar-container>
  <!-- A sidebar -->
  <ng-sidebar [(opened)]="_opened">
    <p>Sidebar contents</p>
  </ng-sidebar>
</ng-sidebar-container>

Content here..

That way, I can create my own component much easier by encapsulating the with it.

THanks.

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.