I have explored the functionalities of display:none and visibility:hidden. However, I need to utilize display:none for a specific reason while still preserving the element's allocated space in the DOM to prevent any impact on adjacent elements. Is this achievable?
This question follows up on the issue identified with the display:none property. You can refer to the original question HERE
UPDATE: As per T.J. Crowder's request, all relevant details from my initial query are provided here.
How can I incorporate a smooth fade effect into my function for more seamless animation instead of toggling visibility hidden / visible at regular intervals?
I am not interested in using plugins or adding the jQuery UI library.
My JS :
setBlinkingInterval: function(elem, event) {
if (intervalIdForBlinking != 0)
window.clearInterval(intervalIdForBlinking);
$(elem).show();
intervalIdForBlinking = setInterval(function() {
if (eventsObj.eventIsFinished(event)) {
timer.setClosedStatus(elem, event);
}
else {
if (elem.css('visibility') == 'hidden')
elem.css('visibility', 'visible');
else
elem.css('visibility', 'hidden');
}
}, 500);
}
Update 1: HTML markup included for better understanding of one answer.
$('<span/>')
.append('<div id="closing_blink" class="yellowText" style="display:none;">' + closing + ' </div>')
.append(date.formatFullDate(new Date(event.timeUtc)) + timezone)
.append('<br/>')
.append((weatherInfo != '' && trackInfo != '') ? '<div class="whiteText">' + weather + '</div>' + '<div class="orangeText">' + weatherInfo + '</div>' + ' ' + '<div class="whiteText">' + track + '</div>' + '<div class="orangeText">' + trackInfo + '</div>' : '')
.appendTo(rightTd);
Upon implementing solutions based on the given answers, I encountered display issues when viewed on the page.
Case 1: Using the original solution (works fine)
Screen recording link HERE
Case 2: Utilizing the fade in/out method (Display issue)
Screen recording link HERE
Case 3: Employing the toggle method (Display issue)
Screen recording link HERE
Is there a quick fix available to resolve the display issue?
Here is the complete HTML generated by a JS function drawRaceHead: function(event) {
// Setting all race numbers back to default values
styling.makeAllRaceNumbersUnselected();
// Making the current race number active (including Racing Specials)
styling.makeCurrentEventNumberSelected(event)
// Race information
$("#raceInfo").html('');
$("#raceInfo").append($('<table/>').append($('<tr/>')))
var leftTd = $('<td style="width: 295px"/>')
.appendTo($('#raceInfo')),
rightTd = $('<td/>')
.appendTo($('#raceInfo'));
// If not under Racing Specials category
if (event.parentCategoryId != 2863) leftTd.html(raceFullName + ' ' + event.name)
else leftTd.html(event.name);
$('<div id="closing_time" style="display:none"/>')
.appendTo(leftTd)
// Date, time, weather, track
var weatherInfo = '', trackInfo = '';
if (event.markets.length > 0) {
weatherInfo = (event.markets[0].weather == null) ? '-' : event.markets[0].weather;
trackInfo = (event.markets[0].track == null) ? '-' : event.markets[0].track;
}
var isMSIE = /*@cc_on!@*/false;
var ieVersion = (function(reg) { return isMSIE && navigator.userAgent.match(reg) ? RegExp.$1 * 1 : null; })(/MSIE\s([0-9]+[\.0-9]*)/);
if (isMSIE && ieVersion < 11) {
timezone = '';
}
else {
var regExp = /\(([^)]+)\)/, timezone = (regExp.exec(new Date)[1]).split(' ')[0];
timezone = ' (' + timezone + ')';
}
$('<span/>')
.append('<div id="closing_blink" class="yellowText" style="display:none;">' + closing + ' </div>')
.append(date.formatFullDate(new Date(event.timeUtc)) + timezone)
.append('<br/>')
.append((weatherInfo != '' && trackInfo != '') ? '<div class="whiteText">' + weather + '</div>' + '<div class="orangeText">' + weatherInfo + '</div>' + ' ' + '<div class="whiteText">' + track + '</div>' + '<div class="orangeText">' + trackInfo + '</div>' : '')
.appendTo(rightTd);
},