javascript - Set opacity to all tiles except for the one selected -
i noticed there couple questions similar one, not same exactly. using ng-repeat
show of uploaded images have. can click on 1 , become default picture. want image clicked normal while others have overlay
. tried setting $('overlay').hide()
in selectimage
function, remove overlay html on first image. ideas on how can this?
html
<!-- photos --> <div class="uploads-section" style="width: 100%;"> <md-grid-list md-cols="3" md-row-height="1:1" md-gutter="8px" style="padding-top: 10px;"> <md-grid-tile md-rowspan="1" md-colspan="1"> <div style="background-color: #3f454b; padding: 30px; cursor: pointer; height: 100%; width: 100%;" class="upload-tile no-outline" layout="column" layout-align="center start" ng-click="uploadimage('photo')"> <md-icon style="color: #ffffff; width: 40px; height: 40px;" md-svg-icon="images/upload.png"></md-icon> <p class="action-link" style="margin: 0; color: #ffffff;">upload</p> </div> </md-grid-tile> <md-grid-tile ng-repeat="photo in org.attachments | filter:{type:'photo'}" md-rowspan="1" md-colspan="1" style="opacity: .5;"> <div style="width: 100%; height: 100%; position: relative; overflow: hidden;" class="attachment-tile no-outline" layout="row" layout-align="center center" ng-click="selectimage($event, photo)"> <!-- <p class="m1">loading...</p> --> <img attachment-src="{{ photo.path | thumbnailfilter }}" default-src="images/no_img.png" style="cursor: pointer; height: 100%; width: 100%; object-fit: cover;"> </div> </md-grid-tile> <md-grid-tile ng-repeat="photo in org.defaultorgimages | filter:{type:'photo'}" md-rowspan="1" md-colspan="1"> <div style="width: 100%; height: 100%; position: relative; overflow: hidden;" class="attachment-tile no-outline" layout="row" layout-align="center center" ng-click="selectimage($event, photo)"> <!-- <p class="m1">loading...</p> --> <img attachment-src="{{ photo.path | thumbnailfilter }}" default-src="images/no_img.png" style="cursor: pointer; height: 100%; width: 100%; object-fit: cover;"> <div id="overlay"></div> </div> </md-grid-tile> </md-grid-list> </div>
controller
$scope.selectimage = function (ev, attachment) { if (attachment.type == 'photo' && attachment.path != $scope.org.defaultphoto) { $scope.org.defaultphoto = attachment.path; saveorg(); } };
less
#overlay { position: relative; cursor: pointer; height: 100%; width: 100%; background-color: rgba(0, 0, 0, 0.4); }
i easiest way accomplish create class in css/less file so:
.faded { opacity: 0.5; }
and have append faded
class value of img want faded.
this best , easiest way change opacity of multiple elements.
Comments
Post a Comment