2

I am attempting to have a marquee pause on hover and continue on mouseOut

I tried by including this but it does not work

marquee.hover(
  function() {
   go = false;
  },
function() {
    go = true;
  }
);

Can anyone suggest what I am doing wrong here?

$(function() {

var marquee = $("#marquee"); 
marquee.css({"overflow": "hidden", "width": "100%"});

    marquee.hover(
function() {
   go = false;
  },
function() {
    go = true;
  }
);

// wrap "My Text" with a span (IE doesn't like divs inline-block)
marquee.wrapInner("<span>");
marquee.find("span").css({ "width": "50%", "display": "inline-block", "text-align":"center" }); 
marquee.append(marquee.find("span").clone()); // now there are two spans with "My Text"

marquee.wrapInner("<div>");
marquee.find("div").css("width", "200%");

var reset = function() {
    $(this).css("margin-left", "0%");
    $(this).animate({ "margin-left": "-100%" }, 28000, 'linear', reset);
};

reset.call(marquee.find("div"));
});
Burger Sasha
  • 187
  • 6
  • 17
  • Possible duplicate of [How can I create a marquee effect?](https://stackoverflow.com/questions/21233033/how-can-i-create-a-marquee-effect) or http://jsfiddle.net/MaY5A/1437/ for CSS-only options – WOUNDEDStevenJones Sep 12 '19 at 22:35
  • That is a css3 marquee this is Javascript – Burger Sasha Sep 12 '19 at 22:37
  • is there a reason it needs to be done via JS? It's likely easier and more efficient to do in CSS alone. – WOUNDEDStevenJones Sep 12 '19 at 22:39
  • Yes because this JS specifically makes the content appear on the right side of the broswer the second it exits on the left whereas css3 has to exit all the content out of the left side before it comes out of the right again – Burger Sasha Sep 12 '19 at 22:42
  • Does your solution need to handle dynamic widths for both the marquee box and the content? What happens if the text is more narrow than the div it's scrolling through - is the text listed multiple times? i.e. if the marquee box is 800px wide and the content is only 300px - is the content triplicated to fill the box? This is a specific requirement that should be edited into your question. – WOUNDEDStevenJones Sep 12 '19 at 22:44

0 Answers0