애니메이션을 지원하는 프로젝트에 ngAnimate를 구현했지만 특정 요소와 관련하여 매우 이상한 행동을하고 있습니다.ngAnimate 특정 요소에서 최대 높이가 작동하지 않습니다.
배경을 추가하려면 카테고리 안에 카테고리 및 제품이있는 쇼핑몰이 있습니다. 나는 ng-repeat를 다음과 같이하고있다 : data-ng-repeat="product in currentProductCategory.Products"
그리고 내 루트 요소에 data-ng-class="{ 'open': product.ShowDetails == true }"
이있다.
내 루트 요소의 ID는 product-{{product.Id}}-{{currentProductCategory.Id}}
이며 ID가 product-options-{{product.Id}}-{{currentProductCategory.Id}}
인 하위 요소가있는 제품입니다.
버튼을 클릭하면 상위 요소의 최대 높이를 원하는 높이로 설정하고 CSS에서 애니메이션을 처리하는 함수를 호출합니다.
var reg = /\d+/g;
var productParentElement = $('#product-' + product.Id + '-' + $scope.currentProductCategory.Id);
var optionsElement = $('#product-options-' + product.Id + '-' + $scope.currentProductCategory.Id);
var productParentPaddingTop = parseInt(productParentElement.css("padding-top").match(reg));
var productParentPaddingBottom = parseInt(productParentElement.css("padding-bottom").match(reg));
var productParentTotalHeight = productParentPaddingTop + productParentPaddingBottom + productParentElement.height() + optionsElement.height();
var optionsElementPaddingTop = parseInt(optionsElement.css("padding-top").match(reg));
var optionsElementPaddingBottom = parseInt(optionsElement.css("padding-bottom").match(reg));
var optionsElementTotalHeight = optionsElementPaddingTop + optionsElementPaddingBottom + optionsElement.height();
var totalHeight = productParentTotalHeight + optionsElementTotalHeight;
if (product.ShowDetails) {
product.ShowDetails = true;
productParentElement.css("max-height", totalHeight);
} else {
product.ShowDetails = false;
productParentElement.removeAttr('style');
}
그리고 폐쇄 및 오픈 클래스 내 CSS :
휴관일 :
.products-list .product {
margin-bottom: 20px;
max-height: 200px;
overflow: hidden;
-moz-transition: max-height 2s ease;
-o-transition: max-height 2s ease;
-webkit-transition: max-height 2s ease;
transition: max-height 2s ease;
}
열기 다음은 기능 코드의
.products-list .product.open {
-moz-transition: max-height 2s ease;
-o-transition: max-height 2s ease;
-webkit-transition: max-height 2s ease;
transition: max-height 2s ease;
max-height: 200px;
}
문제가되는 중 4 개의 카테고리를 넘은 많은 제품들, 각 카테고리의 동일한 제품인 동일한 제품은 애니메이션으로 열리지 않습니다. 닫기/축소를 애니메이션 처리하지만, 열면 즉시 열리는 것처럼 보입니다.
이것은 오랫동안 우리를 게이팅하고 있으며 실제 문제가되고 있습니다. 어떤 도움도 크게 받으실 수 있습니다.
업데이트 : 이제 "제품"중 아무 것도 열어 보이지 않지만 닫히게됩니다. 클래스가 아닌 스타일의 최대 높이를 설정하기 때문에 이것이 가능합니까?
명확한 설명을 위해 - 각 카테고리 내의 제품 유형 중 하나만 올바르게 애니메이션이 적용되지 않지만 카테고리 내의 다른 모든 제품 유형은 잘 움직입니다. –
맞습니다! 다른 개체의 속성 값과는 달리 (모든 개체의 데이터는 모두 동일합니다. 모든 카테고리에서 동일한 문제가있는 '제품'이 하나 있습니다. 예 : JPEG (위반자)는 3 가지 카테고리의 제품입니다. 각 카테고리에는 JPEG 제품 오브젝트가 있으며, 동일한 카테고리를 참조하지 않습니다. 그러나 3 개의 JPEG 제품 모두 애니메이션을 거부합니다. –
조금만 짐작 하겠지만 확실한 답을 줄 수있는 충분한 코드가 여기에 없습니다.하지만 문제 제품에 특유한 것에 집중할 것입니다. 항상 목록의 동일한 위치에 나타나거나 문제가있는 제품에 다른 제품에없는 다른 속성이 있습니까? –