1.1.2 • Published 5 years ago

angular-draggable-widget v1.1.2

Weekly downloads
37
License
-
Repository
github
Last release
5 years ago

Angular Draggable Widget

angular-draggable-widget is a tiny library to add multible draggable widgets to your angular application.

alt text

Installation

node

npm install angular-draggable-widget

yarn

yarn add angular-draggable-widget

SystemJs

add to systemjs.config.js

'angular-draggable-widget': 'node_modules/angular-draggable-widget/bundles/angular-draggable-widget.umd.min.js',

Usage

Import AngularDraggableWidgetModule in your AppModule

import { AngularDraggableWidgetModule } from 'angular-draggable-widget';

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

and then in html template

<draggable-widget
   [isOpened]="true"
   [isDraggable]="true"
   [isMinimizable]="false"
   title="my widget title"
   xPosition="25px"
   yPosition="50px"
   [zIndex]="2"
   iconImageSrc="../assets/logo.png"
   (onClose)="isOpened = false">
    Add your widget content here
  </draggable-widget>

Events, properties, and styling

Events

EventDescription
onOpenwhen the widget opened
onClosewhen the sidget closed
onMinimizewhen the widget minimized
onDragStartwhen widget drag starts
onDragEndwhen widget drag stops
onDragMovedwhile the widget is dragging
onDragReleasedwhen the widget drag has released
onWidgetDClickedwhen the minimized widget double clicked

Properties

PropertyDescriptionDefault valuetype
isOpenedshow/hide widgetfalseboolean
isDraggableEnable/disable dragtrueboolean
isMinimizableminimize/maximize widgettrueboolean
titlewidget titleTitlestring
xPositioninital top position in px or %dynamicstring
yPositioninital left position in px or %dynamicstring
zIndexwidget order between other widgetsdynamicnumber
iconImageSrcwidget icon image pathstring

Styling

you can override the css classes to theme your widget.

css classDescription
widgetwidget active class
headerwidget header
titlewidget title
imageheader icom image
widgetMinimizedactive when the widget minimized
widgetAsIconthw widget icon when minimized
widgetAsIcon > imgto style the image inside widget icon

Small screens

use media query to override widget styling on small screens

@media only screen and (max-width:600px) {
    .widget {
        bottom: 0px ;
        width: 100% ;
    }
}