Last active
March 12, 2018 17:24
-
-
Save ChiranjeeviAdi/b922f74f07ff1577c1b13b176df12d33 to your computer and use it in GitHub Desktop.
Angularjs Directive For Displaying an Image Overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var app = ng.module('app', []); | |
| app.directive("overlay", function($rootScope) { | |
| return { | |
| restrict: 'AE', | |
| replace: true, | |
| templateUrl: 'app/modules/layout/views/overlay.html', | |
| link: function(scope, element, attrs){ | |
| $rootScope.overLayImage=attrs.image; | |
| $rootScope.showoverlay = false; | |
| } | |
| }; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Small image will be displayed on Clicking on image below it will show the same image in bigger overlay --> | |
| <img ng-src="" ng-click="$root.overlay_image_name=t.image_name;$root.showoverlay=true" style="width:20px;height:30px;"></img> | |
| <overlay image={{$root.overlay_image_name}}></overlay> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="container" ng-if="$root.showoverlay"> | |
| <i class="fa fa-close fa-2x text-right cursor overlayCloseBtn" ng-click="$root.showoverlay=false"></i> | |
| <div class='container overlay' > | |
| <img src="{{$root.overlay_image_name}}" width="40%" height=80%"></img> | |
| </div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .overlayCloseBtn { | |
| position: fixed; | |
| top: 24px; | |
| opacity: 1; | |
| transition: all linear 0.5s; | |
| align-items: 'center'; | |
| right: 35%; | |
| color: red; | |
| background-color: white; | |
| } | |
| .overlay { | |
| position: fixed; | |
| top: 42px; | |
| /* right: 42px; */ | |
| opacity: 1; | |
| transition: all linear 0.5s; | |
| align-items: 'center'; | |
| left: 31%; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment