Skip to content

Commit

Permalink
Preview: Fix element group rendering with respect to layer (#2778)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenberttpingol authored Oct 18, 2024
1 parent e4dd568 commit ae60d5e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
24 changes: 23 additions & 1 deletion modules/src/xibo-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1370,12 +1370,28 @@ XiboPlayer.prototype.renderGlobalElements = function(currentWidget) {
if (isGroup) {
// Grouped elements
if (elemObj.items.length > 0) {
// Check if group element exists
// If not, then create
let $groupContent;
if ($content.find(`.${itemKey}`).length === 0) {
$groupContent = $(`<div class="${itemKey}"></div>`);

$groupContent.css({
width: elemObj.width,
height: elemObj.height,
position: 'absolute',
top: elemObj.top,
left: elemObj.left,
zIndex: elemObj.layer,
});
}

// Loop through group items
elemObj.items.forEach(function(groupItem) {
// Load element functions
self.loadElementFunctions(groupItem, {});

(groupItem.hbs) && $content.append(
(groupItem.hbs) ($groupContent) && $groupContent.append(
PlayerHelper.renderElement(
groupItem.hbs,
groupItem.templateData,
Expand All @@ -1398,6 +1414,12 @@ XiboPlayer.prototype.renderGlobalElements = function(currentWidget) {
meta,
);
});

// If there's a group content element
// Append it to the page
if ($groupContent) {
$content.append($groupContent);
}
}
} else {
// Single elements
Expand Down
11 changes: 11 additions & 0 deletions ui/src/helpers/player-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ const PlayerHelper = function() {
const hbsTemplate = hbs(Object.assign(props, globalOptions));
let topPos = props.top;
let leftPos = props.left;
const hasGroup = Boolean(props.groupId);
const hasGroupProps = Boolean(props.groupProperties);

// @NOTE: I think this is deprecated but needs more checking
if (props.group) {
if (props.group.isMarquee) {
topPos = (props.top - props.group.top);
Expand Down Expand Up @@ -165,6 +168,14 @@ const PlayerHelper = function() {
left: props.left,
zIndex: props.layer,
};

if (hasGroup && hasGroupProps) {
cssStyles.top = (props.top >= props.groupProperties.top) ?
(props.top - props.groupProperties.top) : 0;
cssStyles.left = (props.left >= props.groupProperties.left) ?
(props.left - props.groupProperties.left) : 0;
cssStyles.zIndex = 'none';
}
}

if (!props.isGroup && props.dataOverride === 'text' &&
Expand Down

0 comments on commit ae60d5e

Please sign in to comment.