UNPKG

3.2 kBSource Map (JSON)View Raw
1{"version":3,"file":"positioning.service.js","sourceRoot":"","sources":["../../src/positioning/positioning.service.ts"],"names":[],"mappings":"OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe;OAC/C,EAAE,gBAAgB,EAAE,MAAM,kBAAkB;AAkCnD;IAAA;IA4BA,CAAC;IA3BQ,qCAAQ,GAAf,UAAgB,OAA2B;QAClC,6BAAO,EAAE,uBAAM,EAAE,+BAAU,EAAE,mCAAY,CAAY;QAC5D,gBAAgB,CACd,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAC5B,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAC7B,UAAU,EACV,YAAY,CAAC,CAAC;IAClB,CAAC;IAEO,4CAAe,GAAvB,UAAwB,OAA0C;QAChE,kCAAkC;QAClC,EAAE,CAAC,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAgB,CAAC;QACxD,CAAC;QAED,EAAE,CAAC,CAAC,OAAO,YAAY,UAAU,CAAC,CAAC,CAAC;YAClC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC;QAC/B,CAAC;QAED,MAAM,CAAC,OAAsB,CAAC;IAChC,CAAC;IACI,6BAAU,GAA0B;QAC3C,EAAE,IAAI,EAAE,UAAU,EAAE;KACnB,CAAC;IACF,kBAAkB;IACX,iCAAc,GAAmE,cAAM,OAAA,EAC7F,EAD6F,CAC7F,CAAC;IACF,yBAAC;AAAD,CAAC,AA5BD,IA4BC","sourcesContent":["import { Injectable, ElementRef } from '@angular/core';\nimport { positionElements } from './ng-positioning';\n\nexport interface PositioningOptions {\n /** The DOM element, ElementRef, or a selector string of an element which will be moved */\n element?: HTMLElement | ElementRef | string;\n\n /** The DOM element, ElementRef, or a selector string of an element which the element will be attached to */\n target?: HTMLElement | ElementRef | string;\n\n /**\n * A string of the form 'vert-attachment horiz-attachment' or 'placement'\n * - placement can be \"top\", \"bottom\", \"left\", \"right\"\n * not yet supported:\n * - vert-attachment can be any of 'top', 'middle', 'bottom'\n * - horiz-attachment can be any of 'left', 'center', 'right'\n */\n attachment?: string;\n\n /** A string similar to `attachment`. The one difference is that, if it's not provided, `targetAttachment` will assume the mirror image of `attachment`. */\n targetAttachment?: string;\n\n /** A string of the form 'vert-offset horiz-offset'\n * - vert-offset and horiz-offset can be of the form \"20px\" or \"55%\"\n */\n offset?: string;\n\n /** A string similar to `offset`, but referring to the offset of the target */\n targetOffset?: string;\n\n /** If true component will be attached to body */\n appendToBody?: boolean;\n}\n\n\nexport class PositioningService {\n public position(options: PositioningOptions): void {\n const {element, target, attachment, appendToBody} = options;\n positionElements(\n this._getHtmlElement(target),\n this._getHtmlElement(element),\n attachment,\n appendToBody);\n }\n\n private _getHtmlElement(element: HTMLElement | ElementRef | string): HTMLElement {\n // it means that we got a selector\n if (typeof element === 'string') {\n return document.querySelector(element) as HTMLElement;\n }\n\n if (element instanceof ElementRef) {\n return element.nativeElement;\n }\n\n return element as HTMLElement;\n }\nstatic decorators: DecoratorInvocation[] = [\n{ type: Injectable },\n];\n/** @nocollapse */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n];\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
\No newline at end of file