2
これに類似した質問がいくつかありましたが、正確には同じではありません。私はng-repeat
を使って、私がアップロードしたすべての画像を表示しています。私は1つをクリックすることができ、それはデフォルトの画像になります。クリックした画像は通常のように見え、他の画像はoverlay
です。 selectImage
機能で$('overlay').hide()
を設定しようとしましたが、それは最初の画像のHTMLからオーバーレイを削除するだけです。どのように私はこれを行うことができます上の任意のアイデア?選択したもの以外のすべてのタイルに不透明度を設定します。
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);
}
私は 'ng-repeat'を使っているので、それはうまくいきません。私はすべての画像を「退色」し、正常に選択された画像にします。背景色:rgba(0、0、0、0.4)のため、すべての画像が色あせてしまいました。選択した画像にその画像を削除してもらいたい。 – daveskylark