Skip to content

Commit aeb79fb

Browse files
committed
Fix carousel for genes with multiple summaries.
1 parent 5d371aa commit aeb79fb

File tree

2 files changed

+50
-16
lines changed

2 files changed

+50
-16
lines changed

rnacentral/portal/static/css/gene.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,26 @@ text-decoration: none;
685685
}
686686

687687
/* Slick carousel overrides for litsumm */
688+
.gene__litsumm-carousel .slick-list {
689+
overflow: hidden;
690+
}
691+
692+
.gene__litsumm-carousel .slick-track {
693+
display: flex;
694+
align-items: stretch;
695+
}
696+
697+
.gene__litsumm-carousel .slick-slide {
698+
visibility: hidden;
699+
opacity: 0;
700+
transition: opacity 0.3s ease;
701+
}
702+
703+
.gene__litsumm-carousel .slick-slide.slick-active {
704+
visibility: visible;
705+
opacity: 1;
706+
}
707+
688708
.gene__litsumm-carousel .slick-prev {
689709
left: 0;
690710
}
@@ -698,6 +718,14 @@ text-decoration: none;
698718
color: #9e9e9e;
699719
}
700720

721+
.gene__litsumm-carousel .slick-disabled {
722+
cursor:not-allowed;
723+
}
724+
725+
.gene__litsumm-carousel .slick-disabled:before {
726+
opacity: 0.25;
727+
}
728+
701729
.gene__litsumm-carousel .slick-dots {
702730
bottom: -30px;
703731
}

rnacentral/portal/templates/portal/gene_detail.html

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,38 @@ <h4 class="alert-heading">Gene Not Found</h4>
3737
litsummSummaries: {{ litsummSummaries|safe }},
3838
geneFound: {{ geneFound|yesno:'true,false' }}
3939
};
40+
</script>
41+
{% endblock %}
4042

41-
// Initialize litsumm carousel after AngularJS renders the content
43+
{% block extra_js_uncompressed %}
44+
<script>
4245
$(document).ready(function() {
4346
var litsummData = window.geneDetailData.litsummSummaries || [];
4447
if (litsummData.length > 1) {
45-
// Wait for AngularJS to render the carousel items
48+
// Poll until the carousel element exists and has items
49+
var attempts = 0;
50+
var maxAttempts = 50;
51+
4652
var initCarousel = function() {
53+
attempts++;
4754
var $carousel = $('#gene-litsumm-carousel');
48-
var itemCount = $carousel.children('.gene__litsumm-panel').length;
4955

50-
if (itemCount >= litsummData.length && !$carousel.hasClass('slick-initialized')) {
51-
$carousel.slick({
52-
draggable: true,
53-
rows: 1,
54-
dots: true,
55-
infinite: true,
56-
lazyLoad: 'ondemand',
57-
slidesToShow: 1,
58-
slidesToScroll: 1,
59-
arrows: true
60-
});
61-
} else if (itemCount < litsummData.length) {
62-
// Retry if items not yet rendered
56+
if ($carousel.length && $carousel.find('.gene__litsumm-panel').length > 0) {
57+
if (!$carousel.hasClass('slick-initialized')) {
58+
$carousel.slick({
59+
draggable: true,
60+
dots: true,
61+
infinite: false,
62+
slidesToShow: 1,
63+
slidesToScroll: 1,
64+
arrows: true
65+
});
66+
}
67+
} else if (attempts < maxAttempts) {
6368
setTimeout(initCarousel, 100);
6469
}
6570
};
71+
6672
setTimeout(initCarousel, 500);
6773
}
6874
});

0 commit comments

Comments
 (0)