Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview: Fix element group rendering with respect to layer #2779

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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