@mapxus/mapxus-visual-jp 1.8.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bitbucket-pipelines.yml +50 -0
- package/config/rollup.js +33 -0
- package/config/rollup.serve.config.js +3 -0
- package/debug/circlemarker.html +444 -0
- package/debug/create_tags.html +474 -0
- package/debug/distance.html +220 -0
- package/debug/index.html +92 -0
- package/debug/integration.html +1084 -0
- package/debug/leaflet.html +54 -0
- package/debug/markers.html +115 -0
- package/debug/multi_monitor_sync.html +377 -0
- package/debug/outdoor.html +1026 -0
- package/debug/rect_tags.html +147 -0
- package/debug/rotate.html +236 -0
- package/debug/sample.html +324 -0
- package/debug/sequence.html +75 -0
- package/debug/tags.html +218 -0
- package/package.json +34 -10
- package/rollup.config.js +39 -0
- package/server.js +35 -0
- package/spec/api/APIv3.spec.ts +86 -0
- package/spec/component/Component.spec.ts +68 -0
- package/spec/component/StatsComponent.spec.ts +33 -0
- package/spec/component/direction/DirectionComponent.spec.ts +163 -0
- package/spec/component/direction/DirectionDOMRenderer.spec.ts +233 -0
- package/spec/component/keyboard/KeyZoomHandler.spec.ts +236 -0
- package/spec/component/marker/Marker.spec.ts +104 -0
- package/spec/component/marker/MarkerComponent.spec.ts +88 -0
- package/spec/component/marker/MarkerScene.spec.ts +223 -0
- package/spec/component/marker/MarkerSet.spec.ts +453 -0
- package/spec/component/mouse/DoubleClickZoomHandler.spec.ts +211 -0
- package/spec/component/popup/Popup.spec.ts +479 -0
- package/spec/component/popup/PopupComponent.spec.ts +414 -0
- package/spec/component/tag/CreateHandlerBase.spec.ts +83 -0
- package/spec/component/tag/CreatePointHandler.spec.ts +190 -0
- package/spec/component/tag/OutlineRenderTag.spec.ts +91 -0
- package/spec/component/tag/PointGeometry.spec.ts +131 -0
- package/spec/component/tag/PolygonGeometry.spec.ts +497 -0
- package/spec/component/tag/RectGeometry.spec.ts +1157 -0
- package/spec/component/tag/TagComponent.spec.ts +513 -0
- package/spec/component/tag/TagScene.spec.ts +346 -0
- package/spec/component/tag/TagSet.spec.ts +241 -0
- package/spec/component/utils/HandlerBase.spec.ts +203 -0
- package/spec/geo/Camera.spec.ts +250 -0
- package/spec/geo/GeoCoords.spec.ts +364 -0
- package/spec/geo/Spatial.spec.ts +711 -0
- package/spec/geo/Transform.spec.ts +850 -0
- package/spec/geo/ViewportCoords.spec.ts +534 -0
- package/spec/graph/FilterCreator.spec.ts +892 -0
- package/spec/graph/Graph.spec.ts +2078 -0
- package/spec/graph/GraphCalculator.spec.ts +263 -0
- package/spec/graph/GraphService.spec.ts +663 -0
- package/spec/graph/Node.spec.ts +373 -0
- package/spec/graph/NodeCache.spec.ts +206 -0
- package/spec/graph/Sequence.spec.ts +37 -0
- package/spec/graph/edge/EdgeCalculator.Pano.spec.ts +963 -0
- package/spec/graph/edge/EdgeCalculator.Sequence.spec.ts +108 -0
- package/spec/graph/edge/EdgeCalculator.Similar.spec.ts +272 -0
- package/spec/graph/edge/EdgeCalculator.Step.spec.ts +383 -0
- package/spec/graph/edge/EdgeCalculator.Turn.spec.ts +278 -0
- package/spec/graph/edge/EdgeCalculator.spec.ts +747 -0
- package/spec/helper/ContainerMockCreator.spec.ts +33 -0
- package/spec/helper/DOMRendererMockCreator.spec.ts +22 -0
- package/spec/helper/EdgeCalculatorHelper.spec.ts +96 -0
- package/spec/helper/EventHelper.spec.ts +92 -0
- package/spec/helper/GLRendererMockCreator.spec.ts +23 -0
- package/spec/helper/GeoHelper.spec.ts +16 -0
- package/spec/helper/ImageLoadingServiceMockCreator.spec.ts +24 -0
- package/spec/helper/KeyboardServiceMockCreator.spec.ts +21 -0
- package/spec/helper/LoadingServiceMockCreator.spec.ts +21 -0
- package/spec/helper/MockCreator.spec.ts +18 -0
- package/spec/helper/MockCreatorBase.spec.ts +17 -0
- package/spec/helper/MouseServiceMockCreator.spec.ts +38 -0
- package/spec/helper/NavigatorMockCreator.spec.ts +28 -0
- package/spec/helper/NodeHelper.spec.ts +77 -0
- package/spec/helper/NodeMockCreator.spec.ts +19 -0
- package/spec/helper/RenderServiceMockCreator.spec.ts +25 -0
- package/spec/helper/SpriteServiceMockCreator.spec.ts +22 -0
- package/spec/helper/StateServiceMockCreator.spec.ts +33 -0
- package/spec/helper/TouchServiceMockCreator.spec.ts +29 -0
- package/spec/helper/TransformHelper.spec.ts +17 -0
- package/spec/render/DOMRenderer.spec.ts +112 -0
- package/spec/render/GLRenderer.spec.ts +453 -0
- package/spec/render/RenderCamera.spec.ts +535 -0
- package/spec/render/RenderService.spec.ts +531 -0
- package/spec/state/StateBase.spec.ts +369 -0
- package/spec/state/StateService.spec.ts +9 -0
- package/spec/state/TraversingState.spec.ts +262 -0
- package/spec/state/WaitingState.spec.ts +319 -0
- package/spec/tiles/TextureProvider.spec.ts +653 -0
- package/spec/utils/EventEmitter.spec.ts +71 -0
- package/spec/utils/Support.spec.ts +54 -0
- package/spec/viewer/CacheService.spec.ts +160 -0
- package/spec/viewer/ComponentController.spec.ts +310 -0
- package/spec/viewer/LoadingService.spec.ts +19 -0
- package/spec/viewer/MouseService.spec.ts +1344 -0
- package/spec/viewer/Navigator.spec.ts +970 -0
- package/spec/viewer/Observer.spec.ts +96 -0
- package/spec/viewer/SpriteService.spec.ts +224 -0
- package/src/API.ts +3 -0
- package/src/Component.ts +77 -0
- package/src/Edge.ts +6 -0
- package/src/Error.ts +3 -0
- package/src/FilterRender.ts +27 -0
- package/src/Geo.ts +7 -0
- package/src/Graph.ts +19 -0
- package/src/MapxusVisual.ts +66 -0
- package/src/Render.ts +7 -0
- package/src/State.ts +8 -0
- package/src/Support.ts +35 -0
- package/src/Tiles.ts +5 -0
- package/src/Utils.ts +6 -0
- package/src/Viewer.ts +16 -0
- package/src/api/API.ts +396 -0
- package/src/api/Auth.ts +76 -0
- package/src/api/AuthStore.ts +11 -0
- package/src/api/GraphQLCreator.ts +100 -0
- package/src/api/interfaces/IAuth.ts +7 -0
- package/src/api/interfaces/IBuildingBase.ts +7 -0
- package/src/api/interfaces/IBuildingInfo.ts +19 -0
- package/src/api/interfaces/ICoreNode.ts +28 -0
- package/src/api/interfaces/IFillNode.ts +96 -0
- package/src/api/interfaces/IFloorInfo.ts +10 -0
- package/src/api/interfaces/IFullNode.ts +10 -0
- package/src/api/interfaces/IGPano.ts +38 -0
- package/src/api/interfaces/IImageTagInfo.ts +14 -0
- package/src/api/interfaces/IKey.ts +13 -0
- package/src/api/interfaces/ILatLon.ts +19 -0
- package/src/api/interfaces/IOutdoor.ts +14 -0
- package/src/api/interfaces/IPathNode.ts +37 -0
- package/src/api/interfaces/IProject.ts +8 -0
- package/src/api/interfaces/IQueryBuilding.ts +37 -0
- package/src/api/interfaces/IResponse.ts +7 -0
- package/src/api/interfaces/ISequence.ts +16 -0
- package/src/api/interfaces/IUser.ts +13 -0
- package/src/api/interfaces/interfaces.ts +17 -0
- package/src/component/AttributionComponent.ts +48 -0
- package/src/component/BackgroundComponent.ts +39 -0
- package/src/component/BearingComponent.ts +282 -0
- package/src/component/CacheComponent.ts +295 -0
- package/src/component/Component.ts +130 -0
- package/src/component/ComponentService.ts +150 -0
- package/src/component/CoverComponent.ts +132 -0
- package/src/component/DebugComponent.ts +157 -0
- package/src/component/ImageComponent.ts +96 -0
- package/src/component/LoadingComponent.ts +85 -0
- package/src/component/NavigationComponent.ts +233 -0
- package/src/component/RouteComponent.ts +354 -0
- package/src/component/StatsComponent.ts +100 -0
- package/src/component/direction/DirectionComponent.ts +254 -0
- package/src/component/direction/DirectionDOMCalculator.ts +243 -0
- package/src/component/direction/DirectionDOMRenderer.ts +631 -0
- package/src/component/imageplane/ImagePlaneComponent.ts +497 -0
- package/src/component/imageplane/ImagePlaneFactory.ts +314 -0
- package/src/component/imageplane/ImagePlaneGLRenderer.ts +247 -0
- package/src/component/imageplane/ImagePlaneScene.ts +87 -0
- package/src/component/imageplane/ImagePlaneShaders.ts +16 -0
- package/src/component/imageplane/SliderComponent.ts +697 -0
- package/src/component/imageplane/interfaces/IBBoxShaderMaterial.ts +10 -0
- package/src/component/imageplane/interfaces/IShaderMaterial.ts +9 -0
- package/src/component/imageplane/interfaces/interfaces.ts +2 -0
- package/src/component/imageplane/shaders/equirectangular.fragment.glsl.ts +26 -0
- package/src/component/imageplane/shaders/equirectangular.vertex.glsl.ts +15 -0
- package/src/component/imageplane/shaders/perspective.fragment.glsl.ts +27 -0
- package/src/component/imageplane/shaders/perspective.vertex.glsl.ts +15 -0
- package/src/component/interfaces/ICacheConfiguration.ts +72 -0
- package/src/component/interfaces/IComponentConfiguration.ts +5 -0
- package/src/component/interfaces/ICoverConfiguration.ts +15 -0
- package/src/component/interfaces/IDirectionConfiguration.ts +63 -0
- package/src/component/interfaces/IImagePlaneConfiguration.ts +17 -0
- package/src/component/interfaces/IKeyboardConfiguration.ts +44 -0
- package/src/component/interfaces/IMarkerConfiguration.ts +31 -0
- package/src/component/interfaces/IMouseConfiguration.ts +52 -0
- package/src/component/interfaces/INavigationConfiguration.ts +35 -0
- package/src/component/interfaces/IRouteConfiguration.ts +20 -0
- package/src/component/interfaces/ISequenceConfiguration.ts +72 -0
- package/src/component/interfaces/IShader.ts +6 -0
- package/src/component/interfaces/ISliderConfiguration.ts +61 -0
- package/src/component/interfaces/ITagConfiguration.ts +40 -0
- package/src/component/interfaces/interfaces.ts +17 -0
- package/src/component/keyboard/KeySequenceNavigationHandler.ts +86 -0
- package/src/component/keyboard/KeySpatialNavigationHandler.ts +216 -0
- package/src/component/keyboard/KeyZoomHandler.ts +106 -0
- package/src/component/keyboard/KeyboardComponent.ts +125 -0
- package/src/component/marker/Marker.ts +5 -0
- package/src/component/marker/MarkerComponent.ts +856 -0
- package/src/component/marker/MarkerScene.ts +145 -0
- package/src/component/marker/MarkerSet.ts +142 -0
- package/src/component/marker/interfaces/IArrowMarkerOptions.ts +41 -0
- package/src/component/marker/interfaces/ICircleMarkerOptions.ts +30 -0
- package/src/component/marker/interfaces/IDotMarkerOptions.ts +18 -0
- package/src/component/marker/interfaces/IMarkerEvent.ts +28 -0
- package/src/component/marker/interfaces/ISimpleMarkerOptions.ts +54 -0
- package/src/component/marker/interfaces/interfaces.ts +5 -0
- package/src/component/marker/marker/ArrowMarker.ts +84 -0
- package/src/component/marker/marker/CircleMarker.ts +82 -0
- package/src/component/marker/marker/DotMarker.ts +68 -0
- package/src/component/marker/marker/ImageMarker.ts +45 -0
- package/src/component/marker/marker/Marker.ts +99 -0
- package/src/component/marker/marker/SimpleMarker.ts +187 -0
- package/src/component/mouse/BounceHandler.ts +148 -0
- package/src/component/mouse/DoubleClickZoomHandler.ts +106 -0
- package/src/component/mouse/DragPanHandler.ts +489 -0
- package/src/component/mouse/HandlerTypes.ts +13 -0
- package/src/component/mouse/MouseComponent.ts +170 -0
- package/src/component/mouse/ScrollZoomHandler.ts +137 -0
- package/src/component/mouse/TouchZoomHandler.ts +136 -0
- package/src/component/path/PathComponent.ts +75 -0
- package/src/component/path/PathEvent.ts +245 -0
- package/src/component/path/PathMarker.ts +42 -0
- package/src/component/path/PathRender.ts +163 -0
- package/src/component/popup/Popup.ts +2 -0
- package/src/component/popup/PopupComponent.ts +244 -0
- package/src/component/popup/interfaces/IPopupOffset.ts +37 -0
- package/src/component/popup/interfaces/IPopupOptions.ts +81 -0
- package/src/component/popup/popup/Popup.ts +594 -0
- package/src/component/popup/popup/PopupAlignment.ts +3 -0
- package/src/component/sequence/SequenceComponent.ts +500 -0
- package/src/component/sequence/SequenceDOMInteraction.ts +23 -0
- package/src/component/sequence/SequenceDOMRenderer.ts +179 -0
- package/src/component/tag/Tag.ts +9 -0
- package/src/component/tag/TagComponent.ts +787 -0
- package/src/component/tag/TagCreator.ts +138 -0
- package/src/component/tag/TagDOMRenderer.ts +35 -0
- package/src/component/tag/TagMode.ts +37 -0
- package/src/component/tag/TagOperation.ts +7 -0
- package/src/component/tag/TagScene.ts +216 -0
- package/src/component/tag/TagSet.ts +186 -0
- package/src/component/tag/error/GeometryTagError.ts +11 -0
- package/src/component/tag/geometry/Geometry.ts +62 -0
- package/src/component/tag/geometry/PointGeometry.ts +89 -0
- package/src/component/tag/geometry/PolygonGeometry.ts +349 -0
- package/src/component/tag/geometry/RectGeometry.ts +759 -0
- package/src/component/tag/geometry/VertexGeometry.ts +185 -0
- package/src/component/tag/handlers/CreateHandlerBase.ts +81 -0
- package/src/component/tag/handlers/CreatePointHandler.ts +35 -0
- package/src/component/tag/handlers/CreatePolygonHandler.ts +33 -0
- package/src/component/tag/handlers/CreateRectDragHandler.ts +199 -0
- package/src/component/tag/handlers/CreateRectHandler.ts +57 -0
- package/src/component/tag/handlers/CreateVertexHandler.ts +165 -0
- package/src/component/tag/handlers/EditVertexHandler.ts +275 -0
- package/src/component/tag/handlers/TagHandlerBase.ts +57 -0
- package/src/component/tag/interfaces/IInteraction.ts +14 -0
- package/src/component/tag/interfaces/IOutlineCreateTagOptions.ts +15 -0
- package/src/component/tag/interfaces/IOutlineTagOptions.ts +89 -0
- package/src/component/tag/interfaces/ISpotTagOptions.ts +37 -0
- package/src/component/tag/interfaces/interfaces.ts +4 -0
- package/src/component/tag/tag/OutlineCreateTag.ts +330 -0
- package/src/component/tag/tag/OutlineRenderTag.ts +569 -0
- package/src/component/tag/tag/OutlineTag.ts +380 -0
- package/src/component/tag/tag/RenderTag.ts +50 -0
- package/src/component/tag/tag/SpotRenderTag.ts +160 -0
- package/src/component/tag/tag/SpotTag.ts +170 -0
- package/src/component/tag/tag/Tag.ts +103 -0
- package/src/component/utils/HandlerBase.ts +71 -0
- package/src/error/ArgumentBeeviewError.ts +11 -0
- package/src/error/BeeviewError.ts +9 -0
- package/src/error/GraphBeeviewError.ts +11 -0
- package/src/geo/Camera.ts +149 -0
- package/src/geo/GeoCoords.ts +280 -0
- package/src/geo/GeoRBush.ts +25 -0
- package/src/geo/Spatial.ts +259 -0
- package/src/geo/Transform.ts +543 -0
- package/src/geo/ViewportCoords.ts +518 -0
- package/src/geo/interfaces/ILatLonAlt.ts +7 -0
- package/src/geo/interfaces/interfaces.ts +1 -0
- package/src/graph/FilterCreator.ts +106 -0
- package/src/graph/FilterExpression.ts +16 -0
- package/src/graph/Graph.ts +1516 -0
- package/src/graph/GraphCalculator.ts +197 -0
- package/src/graph/GraphService.ts +516 -0
- package/src/graph/ImageLoadingService.ts +44 -0
- package/src/graph/MeshReader.ts +19 -0
- package/src/graph/Node.ts +622 -0
- package/src/graph/NodeCache.ts +548 -0
- package/src/graph/Sequence.ts +117 -0
- package/src/graph/edge/EdgeCalculator.ts +919 -0
- package/src/graph/edge/EdgeCalculatorCoefficients.ts +43 -0
- package/src/graph/edge/EdgeCalculatorDirections.ts +80 -0
- package/src/graph/edge/EdgeCalculatorSettings.ts +61 -0
- package/src/graph/edge/EdgeDirection.ts +63 -0
- package/src/graph/edge/interfaces/IEdge.ts +26 -0
- package/src/graph/edge/interfaces/IEdgeData.ts +22 -0
- package/src/graph/edge/interfaces/IPano.ts +8 -0
- package/src/graph/edge/interfaces/IPotentialEdge.ts +106 -0
- package/src/graph/edge/interfaces/IStep.ts +7 -0
- package/src/graph/edge/interfaces/ITurn.ts +7 -0
- package/src/graph/edge/interfaces/interfaces.ts +6 -0
- package/src/graph/interfaces/IEdgeStatus.ts +25 -0
- package/src/graph/interfaces/IGraphConfiguration.ts +26 -0
- package/src/graph/interfaces/ILoadStatus.ts +18 -0
- package/src/graph/interfaces/ILoadStatusObject.ts +8 -0
- package/src/graph/interfaces/IMesh.ts +20 -0
- package/src/graph/interfaces/interfaces.ts +5 -0
- package/src/render/DOMRenderer.ts +288 -0
- package/src/render/GLRenderStage.ts +6 -0
- package/src/render/GLRenderer.ts +436 -0
- package/src/render/RenderCamera.ts +212 -0
- package/src/render/RenderMode.ts +34 -0
- package/src/render/RenderService.ts +264 -0
- package/src/render/interfaces/IGLRender.ts +10 -0
- package/src/render/interfaces/IGLRenderFunction.ts +10 -0
- package/src/render/interfaces/IGLRenderHash.ts +8 -0
- package/src/render/interfaces/ISize.ts +6 -0
- package/src/render/interfaces/IVNodeHash.ts +8 -0
- package/src/render/interfaces/interfaces.ts +5 -0
- package/src/state/FrameGenerator.ts +36 -0
- package/src/state/State.ts +6 -0
- package/src/state/StateContext.ts +180 -0
- package/src/state/StateService.ts +600 -0
- package/src/state/StateTransitionMatrix.ts +58 -0
- package/src/state/interfaces/ICurrentState.ts +21 -0
- package/src/state/interfaces/IFrame.ts +9 -0
- package/src/state/interfaces/IRotation.ts +6 -0
- package/src/state/interfaces/IState.ts +11 -0
- package/src/state/interfaces/IStateContext.ts +31 -0
- package/src/state/interfaces/interfaces.ts +5 -0
- package/src/state/states/StateBase.ts +425 -0
- package/src/state/states/TraversingState.ts +861 -0
- package/src/state/states/WaitingState.ts +109 -0
- package/src/tiles/ImageTileLoader.ts +121 -0
- package/src/tiles/ImageTileStore.ts +70 -0
- package/src/tiles/RegionOfInterestCalculator.ts +158 -0
- package/src/tiles/TextureProvider.ts +609 -0
- package/src/tiles/interfaces/IBoundingBox.ts +28 -0
- package/src/tiles/interfaces/IRegionOfInterest.ts +25 -0
- package/src/tiles/interfaces/interfaces.ts +2 -0
- package/src/utils/DOM.ts +28 -0
- package/src/utils/EventEmitter.ts +61 -0
- package/src/utils/Func.ts +3 -0
- package/src/utils/Settings.ts +39 -0
- package/src/utils/Support.ts +70 -0
- package/src/utils/Urls.ts +43 -0
- package/src/viewer/Alignment.ts +53 -0
- package/src/viewer/CacheService.ts +75 -0
- package/src/viewer/ComponentController.ts +237 -0
- package/src/viewer/Container.ts +100 -0
- package/src/viewer/EventNames.ts +192 -0
- package/src/viewer/ImageSize.ts +28 -0
- package/src/viewer/KeyboardService.ts +15 -0
- package/src/viewer/LoadingService.ts +66 -0
- package/src/viewer/MouseService.ts +541 -0
- package/src/viewer/Navigator.ts +362 -0
- package/src/viewer/Observer.ts +441 -0
- package/src/viewer/Projection.ts +162 -0
- package/src/viewer/SpriteService.ts +281 -0
- package/src/viewer/TouchService.ts +336 -0
- package/src/viewer/Viewer.ts +1132 -0
- package/src/viewer/interfaces/IComponentOptions.ts +176 -0
- package/src/viewer/interfaces/IMouseClaim.ts +6 -0
- package/src/viewer/interfaces/IMouseDeferPixels.ts +6 -0
- package/src/viewer/interfaces/IPinch.ts +81 -0
- package/src/viewer/interfaces/ISpriteAtlas.ts +12 -0
- package/src/viewer/interfaces/IUnprojection.ts +9 -0
- package/src/viewer/interfaces/IViewerMouseEvent.ts +56 -0
- package/src/viewer/interfaces/IViewerOptions.ts +88 -0
- package/src/viewer/interfaces/PointOfView.ts +19 -0
- package/src/viewer/interfaces/interfaces.ts +9 -0
- package/styles/AttributionComponent.css +26 -0
- package/styles/BackgroundComponent.css +21 -0
- package/styles/BearingComponent.css +48 -0
- package/styles/CoverComponent.css +169 -0
- package/styles/DebugComponent.css +28 -0
- package/styles/DirectionComponent.css +154 -0
- package/styles/LoadingComponent.css +14 -0
- package/styles/NavigationComponent.css +64 -0
- package/styles/NorthBg.png +0 -0
- package/styles/PopupComponent.css +188 -0
- package/styles/RouteComponent.css +21 -0
- package/styles/SequenceComponent.css +120 -0
- package/styles/SliderComponent.css +82 -0
- package/styles/TagComponent.css +105 -0
- package/styles/cover-logo.png +0 -0
- package/styles/mapillary-js.css +29 -0
- package/styles/pano-indicator.svg +3 -0
- package/styles/pano.svg +20 -0
- package/styles/pointer-wheat.svg +3 -0
- package/styles/pointer-white.svg +3 -0
- package/styles/spinner.svg +1 -0
- package/styles/stepper-left.svg +1 -0
- package/styles/stepper-play.svg +1 -0
- package/styles/stepper-right.svg +1 -0
- package/styles/stepper-stop.svg +1 -0
- package/styles/turn-around.svg +3 -0
- package/styles/turn.svg +3 -0
- package/tsconfig.json +28 -0
- package/tslint.json +81 -0
- package/types/graphql/index.d.ts +28 -0
- package/types/graphql/language/ast/index.d.ts +7 -0
- package/types/images/index.d.ts +7 -0
- package/types/pbf/index.d.ts +16 -0
- package/types/rbush/index.d.ts +28 -0
- package/version/beeview-0.1.0.css +2 -0
- package/version/beeview-0.1.0.js +1 -0
- package/version/beeview-0.1.1.css +2 -0
- package/version/beeview-0.1.1.js +1 -0
- package/version/beeview-0.1.2.css +2 -0
- package/version/beeview-0.1.2.js +1 -0
- package/version/beeview-0.2.0.css +2 -0
- package/version/beeview-0.2.0.js +1 -0
- package/version/beeview-0.2.1.css +2 -0
- package/version/beeview-0.2.1.js +1 -0
- package/version/beeview-0.3.0.css +2 -0
- package/version/beeview-0.3.0.js +1 -0
- package/version/beeview-0.4.0.css +2 -0
- package/version/beeview-0.4.0.js +1 -0
- package/version/beeview-0.4.1.css +2 -0
- package/version/beeview-0.4.1.js +1 -0
- package/version/mapxus-visual-1.0.0.css +2 -0
- package/version/mapxus-visual-1.0.0.js +1 -0
- package/version/mapxus-visual-1.1.0.css +2 -0
- package/version/mapxus-visual-1.1.0.js +1 -0
- package/version/mapxus-visual-1.1.1.css +2 -0
- package/version/mapxus-visual-1.1.1.js +1 -0
- package/version/mapxus-visual-1.1.2.css +2 -0
- package/version/mapxus-visual-1.1.2.js +1 -0
- package/version/mapxus-visual-1.2.0.css +2 -0
- package/version/mapxus-visual-1.2.0.js +1 -0
- package/version/mapxus-visual-1.3.0.css +2 -0
- package/version/mapxus-visual-1.3.0.js +1 -0
- package/LICENSE +0 -11
- package/README.md +0 -28
- package/index.css +0 -2
- package/index.d.ts +0 -163
- package/index.js +0 -1
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
import { Observable, Subject } from "rxjs";
|
|
2
|
+
import {
|
|
3
|
+
IPopupOffset,
|
|
4
|
+
IPopupOptions,
|
|
5
|
+
PopupAlignment,
|
|
6
|
+
} from "../../../Component";
|
|
7
|
+
import {
|
|
8
|
+
Transform,
|
|
9
|
+
ViewportCoords,
|
|
10
|
+
} from "../../../Geo";
|
|
11
|
+
import {
|
|
12
|
+
ISize,
|
|
13
|
+
RenderCamera,
|
|
14
|
+
} from "../../../Render";
|
|
15
|
+
import {DOM} from "../../../Utils";
|
|
16
|
+
import {Alignment} from "../../../Viewer";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @class Popup
|
|
20
|
+
*
|
|
21
|
+
* @classdesc Popup instance for rendering custom HTML content
|
|
22
|
+
* on top of images. Popups are based on 2D basic image coordinates
|
|
23
|
+
* (see the {@link Viewer} class documentation for more information about coordinate
|
|
24
|
+
* systems) and a certain popup is therefore only relevant to a single image.
|
|
25
|
+
* Popups related to a certain image should be removed when moving
|
|
26
|
+
* to another image.
|
|
27
|
+
*
|
|
28
|
+
* A popup must have both its content and its point or rect set to be
|
|
29
|
+
* rendered. Popup options can not be updated after creation but the
|
|
30
|
+
* basic point or rect as well as its content can be changed by calling
|
|
31
|
+
* the appropriate methods.
|
|
32
|
+
*
|
|
33
|
+
* To create and add one `Popup` with default configuration
|
|
34
|
+
* (tooltip visuals and automatic float) and one with specific options
|
|
35
|
+
* use
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```
|
|
39
|
+
* var defaultSpan = document.createElement('span');
|
|
40
|
+
* defaultSpan.innerHTML = 'hello default';
|
|
41
|
+
*
|
|
42
|
+
* var defaultPopup = new Beeview.PopupComponent.Popup();
|
|
43
|
+
* defaultPopup.setDOMContent(defaultSpan);
|
|
44
|
+
* defaultPopup.setBasicPoint([0.3, 0.3]);
|
|
45
|
+
*
|
|
46
|
+
* var cleanSpan = document.createElement('span');
|
|
47
|
+
* cleanSpan.innerHTML = 'hello clean';
|
|
48
|
+
*
|
|
49
|
+
* var cleanPopup = new Beeview.PopupComponent.Popup({
|
|
50
|
+
* clean: true,
|
|
51
|
+
* float: Beeview.Alignment.Top,
|
|
52
|
+
* offset: 10,
|
|
53
|
+
* opacity: 0.7,
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* cleanPopup.setDOMContent(cleanSpan);
|
|
57
|
+
* cleanPopup.setBasicPoint([0.6, 0.6]);
|
|
58
|
+
*
|
|
59
|
+
* popupComponent.add([defaultPopup, cleanPopup]);
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @description Implementation of API methods and API documentation inspired
|
|
63
|
+
* by/used from https://github.com/mapbox/mapbox-gl-js/blob/v0.38.0/src/ui/popup.js
|
|
64
|
+
*/
|
|
65
|
+
export class Popup {
|
|
66
|
+
protected _notifyChanged$: Subject<Popup>;
|
|
67
|
+
|
|
68
|
+
private _container: HTMLDivElement;
|
|
69
|
+
private _content: HTMLDivElement;
|
|
70
|
+
private _parentContainer: HTMLElement;
|
|
71
|
+
private _options: IPopupOptions;
|
|
72
|
+
private _tip: HTMLDivElement;
|
|
73
|
+
|
|
74
|
+
private _point: number[];
|
|
75
|
+
private _rect: number[];
|
|
76
|
+
|
|
77
|
+
private _dom: DOM;
|
|
78
|
+
private _viewportCoords: ViewportCoords;
|
|
79
|
+
|
|
80
|
+
constructor(options?: IPopupOptions, viewportCoords?: ViewportCoords, dom?: DOM) {
|
|
81
|
+
this._options = {};
|
|
82
|
+
|
|
83
|
+
if (!!options) {
|
|
84
|
+
this._options.capturePointer = options.capturePointer == null ? true : options.capturePointer;
|
|
85
|
+
this._options.clean = options.clean;
|
|
86
|
+
this._options.float = options.float;
|
|
87
|
+
this._options.offset = options.offset;
|
|
88
|
+
this._options.opacity = options.opacity;
|
|
89
|
+
this._options.position = options.position;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this._dom = !!dom ? dom : new DOM();
|
|
93
|
+
this._viewportCoords = !!viewportCoords ? viewportCoords : new ViewportCoords();
|
|
94
|
+
|
|
95
|
+
this._notifyChanged$ = new Subject<Popup>();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @ignore
|
|
100
|
+
*
|
|
101
|
+
* @description Internal observable used by the component to
|
|
102
|
+
* render the popup when its position or content has changed.
|
|
103
|
+
*/
|
|
104
|
+
public get changed$(): Observable<Popup> {
|
|
105
|
+
return this._notifyChanged$;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @ignore
|
|
110
|
+
*
|
|
111
|
+
* @description Internal method used by the component to
|
|
112
|
+
* remove all references to the popup.
|
|
113
|
+
*/
|
|
114
|
+
public remove(): void {
|
|
115
|
+
if (this._content && this._content.parentNode) {
|
|
116
|
+
this._content.parentNode.removeChild(this._content);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (this._container) {
|
|
120
|
+
this._container.parentNode.removeChild(this._container);
|
|
121
|
+
delete this._container;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (this._parentContainer) {
|
|
125
|
+
delete this._parentContainer;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Sets a 2D basic image coordinates point to the popup's anchor, and
|
|
131
|
+
* moves the popup to it.
|
|
132
|
+
*
|
|
133
|
+
* @description Overwrites any previously set point or rect.
|
|
134
|
+
*
|
|
135
|
+
* @param {Array<number>} basicPoint - Point in 2D basic image coordinates.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```
|
|
139
|
+
* var popup = new Beeview.PopupComponent.Popup();
|
|
140
|
+
* popup.setText('hello image');
|
|
141
|
+
* popup.setBasicPoint([0.3, 0.3]);
|
|
142
|
+
*
|
|
143
|
+
* popupComponent.add([popup]);
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
public setBasicPoint(basicPoint: number[]): void {
|
|
147
|
+
this._point = basicPoint.slice();
|
|
148
|
+
this._rect = null;
|
|
149
|
+
|
|
150
|
+
this._notifyChanged$.next(this);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Sets a 2D basic image coordinates rect to the popup's anchor, and
|
|
155
|
+
* moves the popup to it.
|
|
156
|
+
*
|
|
157
|
+
* @description Overwrites any previously set point or rect.
|
|
158
|
+
*
|
|
159
|
+
* @param {Array<number>} basicRect - Rect in 2D basic image
|
|
160
|
+
* coordinates ([topLeftX, topLeftY, bottomRightX, bottomRightY]) .
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```
|
|
164
|
+
* var popup = new Beeview.PopupComponent.Popup();
|
|
165
|
+
* popup.setText('hello image');
|
|
166
|
+
* popup.setBasicRect([0.3, 0.3, 0.5, 0.6]);
|
|
167
|
+
*
|
|
168
|
+
* popupComponent.add([popup]);
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
public setBasicRect(basicRect: number[]): void {
|
|
172
|
+
this._rect = basicRect.slice();
|
|
173
|
+
this._point = null;
|
|
174
|
+
|
|
175
|
+
this._notifyChanged$.next(this);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Sets the popup's content to the element provided as a DOM node.
|
|
180
|
+
*
|
|
181
|
+
* @param {Node} htmlNode - A DOM node to be used as content for the popup.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```
|
|
185
|
+
* var div = document.createElement('div');
|
|
186
|
+
* div.innerHTML = 'hello image';
|
|
187
|
+
*
|
|
188
|
+
* var popup = new Beeview.PopupComponent.Popup();
|
|
189
|
+
* popup.setDOMContent(div);
|
|
190
|
+
* popup.setBasicPoint([0.3, 0.3]);
|
|
191
|
+
*
|
|
192
|
+
* popupComponent.add([popup]);
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
public setDOMContent(htmlNode: Node): void {
|
|
196
|
+
if (this._content && this._content.parentNode) {
|
|
197
|
+
this._content.parentNode.removeChild(this._content);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const className: string = "beeviewjs-popup-content" +
|
|
201
|
+
(this._options.clean === true ? "-clean" : "") +
|
|
202
|
+
(this._options.capturePointer === true ? " beeviewjs-popup-capture-pointer" : "");
|
|
203
|
+
|
|
204
|
+
this._content = this._dom.createElement("div", className, this._container);
|
|
205
|
+
|
|
206
|
+
this._content.appendChild(htmlNode);
|
|
207
|
+
|
|
208
|
+
this._notifyChanged$.next(this);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Sets the popup's content to the HTML provided as a string.
|
|
213
|
+
*
|
|
214
|
+
* @description This method does not perform HTML filtering or sanitization,
|
|
215
|
+
* and must be used only with trusted content. Consider Popup#setText if the
|
|
216
|
+
* content is an untrusted text string.
|
|
217
|
+
*
|
|
218
|
+
* @param {string} html - A string representing HTML content for the popup.
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```
|
|
222
|
+
* var popup = new Beeview.PopupComponent.Popup();
|
|
223
|
+
* popup.setHTML('<div>hello image</div>');
|
|
224
|
+
* popup.setBasicPoint([0.3, 0.3]);
|
|
225
|
+
*
|
|
226
|
+
* popupComponent.add([popup]);
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
public setHTML(html: string): void {
|
|
230
|
+
const frag: DocumentFragment = this._dom.document.createDocumentFragment();
|
|
231
|
+
const temp: HTMLBodyElement = this._dom.createElement("body");
|
|
232
|
+
let child: Node;
|
|
233
|
+
temp.innerHTML = html;
|
|
234
|
+
|
|
235
|
+
while (true) {
|
|
236
|
+
child = temp.firstChild;
|
|
237
|
+
if (!child) {
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
frag.appendChild(child);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
this.setDOMContent(frag);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Sets the popup's content to a string of text.
|
|
249
|
+
*
|
|
250
|
+
* @description This function creates a Text node in the DOM, so it cannot insert raw HTML.
|
|
251
|
+
* Use this method for security against XSS if the popup content is user-provided.
|
|
252
|
+
*
|
|
253
|
+
* @param {string} text - Textual content for the popup.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```
|
|
257
|
+
* var popup = new Beeview.PopupComponent.Popup();
|
|
258
|
+
* popup.setText('hello image');
|
|
259
|
+
* popup.setBasicPoint([0.3, 0.3]);
|
|
260
|
+
*
|
|
261
|
+
* popupComponent.add([popup]);
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
public setText(text: string): void {
|
|
265
|
+
this.setDOMContent(this._dom.document.createTextNode(text));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @ignore
|
|
270
|
+
*
|
|
271
|
+
* @description Internal method for attaching the popup to
|
|
272
|
+
* its parent container so that it is rendered in the DOM tree.
|
|
273
|
+
*/
|
|
274
|
+
public setParentContainer(parentContainer: HTMLElement): void {
|
|
275
|
+
this._parentContainer = parentContainer;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* @ignore
|
|
280
|
+
*
|
|
281
|
+
* @description Internal method for updating the rendered
|
|
282
|
+
* position of the popup called by the popup component.
|
|
283
|
+
*/
|
|
284
|
+
public update(renderCamera: RenderCamera, size: ISize, transform: Transform): void {
|
|
285
|
+
if (!this._parentContainer || !this._content) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (!this._point && !this._rect) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (!this._container) {
|
|
294
|
+
this._container = this._dom.createElement("div", "beeviewjs-popup", this._parentContainer);
|
|
295
|
+
|
|
296
|
+
const showTip: boolean =
|
|
297
|
+
this._options.clean !== true &&
|
|
298
|
+
this._options.float !== Alignment.Center;
|
|
299
|
+
|
|
300
|
+
if (showTip) {
|
|
301
|
+
const tipClassName: string =
|
|
302
|
+
"beeviewjs-popup-tip" +
|
|
303
|
+
(this._options.capturePointer === true ? " beeviewjs-popup-capture-pointer" : "");
|
|
304
|
+
|
|
305
|
+
this._tip = this._dom.createElement("div", tipClassName, this._container);
|
|
306
|
+
this._dom.createElement("div", "beeviewjs-popup-tip-inner", this._tip);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
this._container.appendChild(this._content);
|
|
310
|
+
this._parentContainer.appendChild(this._container);
|
|
311
|
+
|
|
312
|
+
if (this._options.opacity != null) {
|
|
313
|
+
this._container.style.opacity = this._options.opacity.toString();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
let classList: DOMTokenList;
|
|
318
|
+
let pointPixel: number[] = null;
|
|
319
|
+
let position: PopupAlignment = this._alignmentToPopupAligment(this._options.position);
|
|
320
|
+
let float: PopupAlignment = this._alignmentToPopupAligment(this._options.float);
|
|
321
|
+
|
|
322
|
+
if (this._point != null) {
|
|
323
|
+
pointPixel =
|
|
324
|
+
this._viewportCoords.basicToCanvasSafe(
|
|
325
|
+
this._point[0],
|
|
326
|
+
this._point[1],
|
|
327
|
+
{ offsetHeight: size.height, offsetWidth: size.width },
|
|
328
|
+
transform,
|
|
329
|
+
renderCamera.perspective);
|
|
330
|
+
} else {
|
|
331
|
+
classList = this._container.classList;
|
|
332
|
+
const alignments: PopupAlignment[] =
|
|
333
|
+
["center", "top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"];
|
|
334
|
+
|
|
335
|
+
let appliedPosition: PopupAlignment = null;
|
|
336
|
+
for (const alignment of alignments) {
|
|
337
|
+
if (classList.contains(`beeviewjs-popup-float-${alignment}`)) {
|
|
338
|
+
appliedPosition = alignment;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
[pointPixel, position] = this._rectToPixel(this._rect, position, appliedPosition, renderCamera, size, transform);
|
|
344
|
+
|
|
345
|
+
if (!float) {
|
|
346
|
+
float = position;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (pointPixel == null) {
|
|
351
|
+
this._container.style.visibility = "hidden";
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
this._container.style.visibility = "visible";
|
|
356
|
+
|
|
357
|
+
if (!float) {
|
|
358
|
+
const width: number = this._container.offsetWidth;
|
|
359
|
+
const height: number = this._container.offsetHeight;
|
|
360
|
+
const floats: PopupAlignment[] = this._pixelToFloats(pointPixel, size, width, height);
|
|
361
|
+
|
|
362
|
+
float = floats.length === 0 ? "top" : <PopupAlignment>floats.join("-");
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const offset: { [key in PopupAlignment]: number[] } = this._normalizeOffset(this._options.offset);
|
|
366
|
+
|
|
367
|
+
pointPixel = [pointPixel[0] + offset[float][0], pointPixel[1] + offset[float][1]];
|
|
368
|
+
pointPixel = [Math.round(pointPixel[0]), Math.round(pointPixel[1])];
|
|
369
|
+
|
|
370
|
+
const floatTranslate: {[key in PopupAlignment]: string } = {
|
|
371
|
+
"bottom": "translate(-50%,0)",
|
|
372
|
+
"bottom-left": "translate(-100%,0)",
|
|
373
|
+
"bottom-right": "translate(0,0)",
|
|
374
|
+
"center": "translate(-50%,-50%)",
|
|
375
|
+
"left": "translate(-100%,-50%)",
|
|
376
|
+
"right": "translate(0,-50%)",
|
|
377
|
+
"top": "translate(-50%,-100%)",
|
|
378
|
+
"top-left": "translate(-100%,-100%)",
|
|
379
|
+
"top-right": "translate(0,-100%)",
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
classList = this._container.classList;
|
|
383
|
+
for (const key in floatTranslate) {
|
|
384
|
+
if (!floatTranslate.hasOwnProperty(key)) {
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
classList.remove(`beeviewjs-popup-float-${key}`);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
classList.add(`beeviewjs-popup-float-${float}`);
|
|
392
|
+
|
|
393
|
+
this._container.style.transform = `${floatTranslate[float]} translate(${pointPixel[0]}px,${pointPixel[1]}px)`;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private _rectToPixel(
|
|
397
|
+
rect: number[],
|
|
398
|
+
position: PopupAlignment,
|
|
399
|
+
appliedPosition: PopupAlignment,
|
|
400
|
+
renderCamera: RenderCamera,
|
|
401
|
+
size: ISize, transform:
|
|
402
|
+
Transform): [number[], PopupAlignment] {
|
|
403
|
+
let pointBasic: number[];
|
|
404
|
+
|
|
405
|
+
if (!position) {
|
|
406
|
+
const width: number = this._container.offsetWidth;
|
|
407
|
+
const height: number = this._container.offsetHeight;
|
|
408
|
+
|
|
409
|
+
const floatOffsets: { [key: string]: number[] } = {
|
|
410
|
+
"bottom": [0, height / 2],
|
|
411
|
+
"bottom-left": [-width / 2, height / 2],
|
|
412
|
+
"bottom-right": [width / 2, height / 2],
|
|
413
|
+
"left": [-width / 2, 0],
|
|
414
|
+
"right": [width / 2, 0],
|
|
415
|
+
"top": [0, -height / 2],
|
|
416
|
+
"top-left": [-width / 2, -height / 2],
|
|
417
|
+
"top-right": [width / 2, -height / 2],
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
const automaticPositions: PopupAlignment[] =
|
|
421
|
+
["top", "bottom", "left", "right"];
|
|
422
|
+
|
|
423
|
+
let largestVisibleArea: [number, number[], PopupAlignment] = [0, null, null];
|
|
424
|
+
|
|
425
|
+
for (const automaticPosition of automaticPositions) {
|
|
426
|
+
pointBasic = this._pointFromRectPosition(rect, automaticPosition);
|
|
427
|
+
const pointPixel: number[] =
|
|
428
|
+
this._viewportCoords.basicToCanvasSafe(
|
|
429
|
+
pointBasic[0],
|
|
430
|
+
pointBasic[1],
|
|
431
|
+
{ offsetHeight: size.height, offsetWidth: size.width },
|
|
432
|
+
transform,
|
|
433
|
+
renderCamera.perspective);
|
|
434
|
+
|
|
435
|
+
if (pointPixel == null) {
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const floatOffset: number[] = floatOffsets[automaticPosition];
|
|
440
|
+
const offsetedPosition: number[] = [pointPixel[0] + floatOffset[0], pointPixel[1] + floatOffset[1]];
|
|
441
|
+
const staticCoeff: number = appliedPosition != null && appliedPosition === automaticPosition ? 1 : 0.7;
|
|
442
|
+
const floats: PopupAlignment[] =
|
|
443
|
+
this._pixelToFloats(offsetedPosition, size, width / staticCoeff, height / (2 * staticCoeff));
|
|
444
|
+
|
|
445
|
+
if (floats.length === 0 &&
|
|
446
|
+
pointPixel[0] > 0 &&
|
|
447
|
+
pointPixel[0] < size.width &&
|
|
448
|
+
pointPixel[1] > 0 &&
|
|
449
|
+
pointPixel[1] < size.height) {
|
|
450
|
+
|
|
451
|
+
return [pointPixel, automaticPosition];
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const minX: number = Math.max(offsetedPosition[0] - width / 2, 0);
|
|
455
|
+
const maxX: number = Math.min(offsetedPosition[0] + width / 2, size.width);
|
|
456
|
+
const minY: number = Math.max(offsetedPosition[1] - height / 2, 0);
|
|
457
|
+
const maxY: number = Math.min(offsetedPosition[1] + height / 2, size.height);
|
|
458
|
+
|
|
459
|
+
const visibleX: number = Math.max(0, maxX - minX);
|
|
460
|
+
const visibleY: number = Math.max(0, maxY - minY);
|
|
461
|
+
|
|
462
|
+
const visibleArea: number = staticCoeff * visibleX * visibleY;
|
|
463
|
+
|
|
464
|
+
if (visibleArea > largestVisibleArea[0]) {
|
|
465
|
+
largestVisibleArea[0] = visibleArea;
|
|
466
|
+
largestVisibleArea[1] = pointPixel;
|
|
467
|
+
largestVisibleArea[2] = automaticPosition;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (largestVisibleArea[0] > 0) {
|
|
472
|
+
return [largestVisibleArea[1], largestVisibleArea[2]];
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
pointBasic = this._pointFromRectPosition(rect, position);
|
|
477
|
+
const pointCanvas: number[] =
|
|
478
|
+
this._viewportCoords.basicToCanvasSafe(
|
|
479
|
+
pointBasic[0],
|
|
480
|
+
pointBasic[1],
|
|
481
|
+
{ offsetHeight: size.height, offsetWidth: size.width },
|
|
482
|
+
transform,
|
|
483
|
+
renderCamera.perspective);
|
|
484
|
+
|
|
485
|
+
return [pointCanvas, position != null ? position : "top"];
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
private _alignmentToPopupAligment(float: Alignment): PopupAlignment {
|
|
489
|
+
switch (float) {
|
|
490
|
+
case Alignment.Bottom:
|
|
491
|
+
return "bottom";
|
|
492
|
+
case Alignment.BottomLeft:
|
|
493
|
+
return "bottom-left";
|
|
494
|
+
case Alignment.BottomRight:
|
|
495
|
+
return "bottom-right";
|
|
496
|
+
case Alignment.Center:
|
|
497
|
+
return "center";
|
|
498
|
+
case Alignment.Left:
|
|
499
|
+
return "left";
|
|
500
|
+
case Alignment.Right:
|
|
501
|
+
return "right";
|
|
502
|
+
case Alignment.Top:
|
|
503
|
+
return "top";
|
|
504
|
+
case Alignment.TopLeft:
|
|
505
|
+
return "top-left";
|
|
506
|
+
case Alignment.TopRight:
|
|
507
|
+
return "top-right";
|
|
508
|
+
default:
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
private _normalizeOffset(offset: number | IPopupOffset): { [key in PopupAlignment]: number[] } {
|
|
514
|
+
if (offset == null) {
|
|
515
|
+
return this._normalizeOffset(0);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (typeof offset === "number") {
|
|
519
|
+
// input specifies a radius
|
|
520
|
+
const sideOffset: number = <number>offset;
|
|
521
|
+
const sign: number = sideOffset >= 0 ? 1 : -1;
|
|
522
|
+
const cornerOffset: number = sign * Math.round(Math.sqrt(0.5 * Math.pow(sideOffset, 2)));
|
|
523
|
+
return {
|
|
524
|
+
"bottom": [0, sideOffset],
|
|
525
|
+
"bottom-left": [-cornerOffset, cornerOffset],
|
|
526
|
+
"bottom-right": [cornerOffset, cornerOffset],
|
|
527
|
+
"center": [0, 0],
|
|
528
|
+
"left": [-sideOffset, 0],
|
|
529
|
+
"right": [sideOffset, 0],
|
|
530
|
+
"top": [0, -sideOffset],
|
|
531
|
+
"top-left": [-cornerOffset, -cornerOffset],
|
|
532
|
+
"top-right": [cornerOffset, -cornerOffset],
|
|
533
|
+
};
|
|
534
|
+
} else {
|
|
535
|
+
// input specifes a value for each position
|
|
536
|
+
return {
|
|
537
|
+
"bottom": offset.bottom || [0, 0],
|
|
538
|
+
"bottom-left": offset.bottomLeft || [0, 0],
|
|
539
|
+
"bottom-right": offset.bottomRight || [0, 0],
|
|
540
|
+
"center": offset.center || [0, 0],
|
|
541
|
+
"left": offset.left || [0, 0],
|
|
542
|
+
"right": offset.right || [0, 0],
|
|
543
|
+
"top": offset.top || [0, 0],
|
|
544
|
+
"top-left": offset.topLeft || [0, 0],
|
|
545
|
+
"top-right": offset.topRight || [0, 0],
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
private _pixelToFloats(pointPixel: number[], size: ISize, width: number, height: number): PopupAlignment[] {
|
|
551
|
+
const floats: PopupAlignment[] = [];
|
|
552
|
+
|
|
553
|
+
if (pointPixel[1] < height) {
|
|
554
|
+
floats.push("bottom");
|
|
555
|
+
} else if (pointPixel[1] > size.height - height) {
|
|
556
|
+
floats.push("top");
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
if (pointPixel[0] < width / 2) {
|
|
560
|
+
floats.push("right");
|
|
561
|
+
} else if (pointPixel[0] > size.width - width / 2) {
|
|
562
|
+
floats.push("left");
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
return floats;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
private _pointFromRectPosition(rect: number[], position: PopupAlignment): number[] {
|
|
569
|
+
switch (position) {
|
|
570
|
+
case "bottom":
|
|
571
|
+
return [(rect[0] + rect[2]) / 2, rect[3]];
|
|
572
|
+
case "bottom-left":
|
|
573
|
+
return [rect[0], rect[3]];
|
|
574
|
+
case "bottom-right":
|
|
575
|
+
return [rect[2], rect[3]];
|
|
576
|
+
case "center":
|
|
577
|
+
return [(rect[0] + rect[2]) / 2, (rect[1] + rect[3]) / 2];
|
|
578
|
+
case "left":
|
|
579
|
+
return [rect[0], (rect[1] + rect[3]) / 2];
|
|
580
|
+
case "right":
|
|
581
|
+
return [rect[2], (rect[1] + rect[3]) / 2];
|
|
582
|
+
case "top":
|
|
583
|
+
return [(rect[0] + rect[2]) / 2, rect[1]];
|
|
584
|
+
case "top-left":
|
|
585
|
+
return [rect[0], rect[1]];
|
|
586
|
+
case "top-right":
|
|
587
|
+
return [rect[2], rect[1]];
|
|
588
|
+
default:
|
|
589
|
+
return [(rect[0] + rect[2]) / 2, rect[3]];
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export default Popup;
|