Skip to content

Commit

Permalink
Fix marquee nesting and add seamless scroll support (#1925)
Browse files Browse the repository at this point in the history
  • Loading branch information
maurofmferrao authored Jul 20, 2023
1 parent a5838f1 commit 669be95
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
6 changes: 3 additions & 3 deletions modules/src/xibo-layout-animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ jQuery.fn.extend({
options.effect === 'marqueeUp' ||
options.effect === 'marqueeDown'
) {
$contentDiv.find('.scroll').marquee();
$contentDiv.find('.scroll:not(.animating)').marquee();
} else if (
options.effect === 'marqueeLeft' ||
options.effect === 'marqueeRight'
) {
if (isAndroid) {
$contentDiv.find('.scroll').overflowMarquee();
$contentDiv.find('.scroll:not(.animating)').overflowMarquee();
} else {
$contentDiv.find('.scroll').marquee();
$contentDiv.find('.scroll:not(.animating)').marquee();
}
} else if (options.effect !== 'none') { // Cycle effect
// Resume effect
Expand Down
19 changes: 16 additions & 3 deletions modules/src/xibo-text-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jQuery.fn.extend({
widgetDesignHeight: 0,
widgetDesignGap: 0,
displayDirection: 0,
seamless: true,
};

options = $.extend({}, defaults, options);
Expand All @@ -52,16 +53,25 @@ jQuery.fn.extend({
// Remove animation items
$contentDiv.find('.text-render-anim-item').remove();

// If options is seamless, remove second .scroll marquee div
// so we don't have duplicated elements
if (
options.seamless &&
$contentDiv.find('.scroll .js-marquee').length > 1
) {
$contentDiv.find('.scroll .js-marquee')[1].remove();
}

// Show and reset the hidden elements
const $originalElements =
$contentDiv.find('.text-render-hidden-element');
$originalElements.removeClass('text-render-hidden-element').show();

// If we have a scroll container, move elements
// to content and destroy container
if ($contentDiv.find('div[class="scroll"]').length > 0) {
if ($contentDiv.find('.scroll').length > 0) {
$originalElements.appendTo($contentDiv);
$contentDiv.find('div[class="scroll"]').remove();
$contentDiv.find('.scroll').remove();
}
};

Expand Down Expand Up @@ -405,7 +415,7 @@ jQuery.fn.extend({
'data-is-legacy': false,
'data-speed': options.speed / 25 * 1000,
'data-direction': options.direction,
'data-duplicated': true,
'data-duplicated': options.seamless,
scaleFactor: options.scaleFactor,
});
} else {
Expand Down Expand Up @@ -440,6 +450,9 @@ jQuery.fn.extend({
} else {
$contentDiv.find('.scroll').overflowMarquee();
}

// Add animating class to prevent multiple inits
$contentDiv.find('.scroll').addClass('animating');
}
}

Expand Down
Loading

0 comments on commit 669be95

Please sign in to comment.