• I used the plugin on a site we are developing and I had to add the same scrolling text after each product in a category view, so I had from 3 to more than ten occurrences of the scrolling text in a page.

    I noticed that randomly (and randomly is the key, see below) some scrolling text was broken: instead of a single line of text I had three in the same scrolling text, and once all of them scrolled out the three lines remained empty.

    After some digging we noticed that the issue came from the fact that sometimes the “marquee-hsas-shortcode-<random number>” class had more occurrences, hence the jQuery code creating the dom elements duplicated them… the fact that random number was just two digits long resulted in a increment of the probability of the generation of two equal numbers growing with the number of texts…

    Our solution was to generate the random number and add a microtime.
    Not yet 100% safe, but good enough to no longer have malfunctioning scrolling texts in out tests.

    We added at line 354 of hsas-register.php the following code:

    ——————–
    $utime = sprintf(‘%.4f’, microtime(true)); //microtime(TRUE) does NOT always return a float! The fix is to format the microtime output to force it to always be a float
    $currDate = \DateTime::createFromFormat(‘U.u’, $utime)->setTimezone(new \DateTimeZone(‘Europe/Berlin’));
    $randnumber = $currDate->format(“dmY”) . $currDate->format(“hisu”) . sprintf(“%02d”, rand(0, 99));
    ——————–

    There is probably a better and more elegant solution, but this is what we came out with in the limited time we had.

  • The topic ‘Random issue with multiple scrolling texts in page (with solution)’ is closed to new replies.