I am just a beginner so don't judge me.
I have seen lot of angularjs plugins (directives/services) that uses $timeout function without any time (or time = 1ms).
For example :
scope.openGallery = function (i) {
if (typeof i !== undefined) {
scope.index = i;
showImage(scope.index);
}
scope.opened = true;
document.body.style.overflow = 'hidden';
/////*******Here*******/////
$timeout(function() {
var calculatedWidth = calculateThumbsWidth();
scope.thumbs_width = calculatedWidth.width;
$thumbnails.css({ width: calculatedWidth.width + 'px' });
$thumbwrapper.css({ width: calculatedWidth.visible_width + 'px' });
smartScroll(scope.index);
});
};
Any specific reason why they do it or benefits of doing it?