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 #2777

Closed
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
32 changes: 31 additions & 1 deletion modules/player.bundle.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -4203,12 +4203,27 @@ XiboPlayer.prototype.renderGlobalElements = function (currentWidget) {
if (isGroup) {
// Grouped elements
if (elemObj.items.length > 0) {
// Check if group element exists
// If not, then create
var $groupContent;
if ($content.find(".".concat(itemKey)).length === 0) {
$groupContent = $("<div class=\"".concat(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) {
var _groupItem$templateDa;
// Load element functions
self.loadElementFunctions(groupItem, {});
groupItem.hbs && $content.append(PlayerHelper.renderElement(groupItem.hbs, groupItem.templateData, true));
groupItem.hbs && $groupContent && $groupContent.append(PlayerHelper.renderElement(groupItem.hbs, groupItem.templateData, true));
var itemID = groupItem.uniqueID || ((_groupItem$templateDa = groupItem.templateData) === null || _groupItem$templateDa === void 0 ? void 0 : _groupItem$templateDa.uniqueID);

// Call onTemplateRender
Expand All @@ -4219,6 +4234,12 @@ XiboPlayer.prototype.renderGlobalElements = function (currentWidget) {
data: {}
}), meta);
});

// If there's a group content element
// Append it to the page
if ($groupContent) {
$content.append($groupContent);
}
}
} else {
var _elemObj$templateData;
Expand Down Expand Up @@ -7286,6 +7307,10 @@ var PlayerHelper = function () {
var hbsTemplate = hbs(Object.assign(props, globalOptions));
var topPos = props.top;
var leftPos = props.left;
var hasGroup = Boolean(props.groupId);
var 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 @@ -7314,6 +7339,11 @@ var 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' && props.group && props.group.isMarquee && (props.effect === 'marqueeLeft' || props.effect === 'marqueeRight')) {
cssStyles = _objectSpread(_objectSpread({}, cssStyles), {}, {
Expand Down
1 change: 1 addition & 0 deletions modules/player.bundle.min.js.map

Large diffs are not rendered by default.

24 changes: 23 additions & 1 deletion modules/src/xibo-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1372,12 +1372,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 @@ -1399,6 +1415,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