I’m attempting to create an animated timeline. I’m using scroll reveal to trigger the animation when the timeline comes into view. Each timeline entry has a left border and a pseudo element :before associated with it. The :before element is a dot that marks the beginning of each timeline entry. When animating the height of the divs that contain the border, the :before pseudo element overflow is cut off. I’ve set overflow to visible with the !important flag but that doesn’t seem to do the trick. Does anyone know why the :before pseudo element is being cut off? Thanks for the help!
JavaScript
x
61
61
1
$(function() {
2
$('.tml-content h2').css("opacity", 0);
3
$('.tml-content p').css("opacity", 0);
4
var height = $('.timeline').height();
5
$('.timeline').height(height);
6
window.sr = ScrollReveal();
7
var config = {
8
// 'bottom', 'left', 'top', 'right'
9
origin: 'bottom',
10
11
// Can be any valid CSS distance, e.g. '5rem', '10%', '20vw', etc.
12
distance: '0px',
13
14
// Time in milliseconds.
15
duration: 1000,
16
delay: 0,
17
18
// Starting angles in degrees, will transition from these values to 0 in all axes.
19
rotate: {
20
x: 0,
21
y: 0,
22
z: 0
23
},
24
25
// Starting opacity value, before transitioning to the computed opacity.
26
opacity: 1,
27
28
// Starting scale value, will transition from this value to 1
29
scale: 1,
30
31
// true: reveals occur every time elements become visible
32
// false: reveals occur once as elements become visible
33
reset: false,
34
35
// Change when an element is considered in the viewport. The default value
36
// of 0.20 means 20% of an element must be visible for its reveal to occur.
37
viewFactor: 0.0,
38
39
// Callbacks that fire for each triggered element reveal, and reset.
40
beforeReveal: function(domEl) {},
41
beforeReset: function(domEl) {},
42
43
// Callbacks that fire for each completed element reveal, and reset.
44
afterReveal: function(domEl) {animateHeight(domEl)},
45
afterReset: function(domEl) {}
46
};
47
sr.reveal('.tml-line', config, 3000);
48
49
function animateHeight(domEl) {
50
var height = $(domEl).height();
51
$(domEl).css("border-left", "1px solid #cf1e27");
52
$(domEl).height(0);
53
$(domEl).children('.tml-content').addClass("fg-timeline-active");
54
$(".tml-line").animate({
55
height: height
56
}, 2000, function() {
57
$(domEl).find('h2').animate({"opacity": 1}, 1000);
58
$(domEl).find('p').animate({"opacity": 1}, 1000);
59
});
60
}
61
});
JavaScript
1
40
40
1
.filler {
2
height: 1200px;
3
width: 100%;
4
background-color: azure;
5
}
6
7
.timeline {
8
height: 100%;
9
margin: 16px auto;
10
margin: 1rem auto;
11
border-radius: 1rem;
12
padding: 32px 24px;
13
padding: 2rem 1.5rem;
14
overflow: visible !important;
15
}
16
17
.timeline .tml-content {
18
-webkit-transform: translate(0, -2rem);
19
-ms-transform: translate(0, -2rem);
20
transform: translate(0, -2rem);
21
padding: 24px;
22
padding: 1.5rem;
23
overflow: visible !important;
24
}
25
26
.timeline .tml-content.fg-timeline-active:before {
27
content: "";
28
width: 8px;
29
width: 0.5rem;
30
height: 8px;
31
height: 0.5rem;
32
background: #fff;
33
border-radius: 0.5rem;
34
border: 4px solid #cf1e27;
35
position: absolute;
36
-webkit-transform: translate(-2rem, 0.5rem);
37
-ms-transform: translate(-2rem, 0.5rem);
38
transform: translate(-2rem, 0.5rem);
39
z-index: 9999;
40
}
JavaScript
1
37
37
1
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
2
<script src="https://unpkg.com/scrollreveal@3.3.2/dist/scrollreveal.min.js"></script>
3
<div class="filler">
4
5
</div>
6
<div class="timeline">
7
<div id="test" class="tml-line">
8
<div class="tml-content">
9
<h2>1900</h2>
10
<p>Sample text</p>
11
</div>
12
</div>
13
<div class="tml-line">
14
<div class="tml-content">
15
<h2>1900 - 2000</h2>
16
<p>Sample text</p>
17
</div>
18
</div>
19
<div class="tml-line">
20
<div class="tml-content">
21
<h2>2001</h2>
22
<p>Sample text</p>
23
</div>
24
</div>
25
<div class="tml-line">
26
<div class="tml-content">
27
<h2>2002</h2>
28
<p>Sample text</p>
29
</div>
30
</div>
31
<div class="tml-line">
32
<div class="tml-content">
33
<h2>2003</h2>
34
<p>Sample text</p>
35
</div>
36
</div>
37
</div>
Advertisement
Answer
You can probably answer your own question but I’m posting an answer anyway. As you saw all you need is to set the overflow style to the tml-line class.
JavaScript
1
4
1
.tml-line {
2
overflow: visible !important;
3
}
4