Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
burhandodhy committed Jul 30, 2024
1 parent 55fb7b0 commit 62e903b
Showing 1 changed file with 3 additions and 50 deletions.
53 changes: 3 additions & 50 deletions assets/js/src/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
var sizing = props.attributes.sizing || 'responsive';
var aspectRatio = props.attributes.aspect_ratio || '16:9';


const width = props.attributes.width || '640px';
const height = props.attributes.height || '360px';

Expand All @@ -70,49 +69,13 @@
}
}, [aspectRatio]);

// element.useEffect(() => {
// if (!maxHeight) {
// let newMaxHeight;
// if (aspectRatio === '16:9') {
// newMaxHeight = '360px';
// } else if (aspectRatio === '4:3') {
// newMaxHeight = '480px';
// } else {
// newMaxHeight = height;
// }

// props.setAttributes({
// ...props.attributes,
// max_height: height === '100%' && newMaxHeight ? newMaxHeight : height,
// });
// }
// }, []);

// element.useEffect(() => {
// if (sizing === 'responsive' && !inPageExperienceId) {
// let newMaxHeight;
// if (aspectRatio === '16:9') {
// newMaxHeight = '360px';
// } else if (aspectRatio === '4:3') {
// newMaxHeight = '480px';
// } else {
// newMaxHeight = height;
// }

// props.setAttributes({
// ...props.attributes,
// max_height: newMaxHeight,
// });
// }
// }, [height, sizing, aspectRatio, inPageExperienceId]);

element.useEffect(() => {
if (!experienceId) {
let newMaxHeight;
if (aspectRatio === '16:9') {
newMaxHeight = parseInt(parseInt(width) * (9 / 16)) + 'px';
newMaxHeight = parseInt(parseInt(width, 10) * (9 / 16), 10) + 'px';
} else if (aspectRatio === '4:3') {
newMaxHeight = parseInt(parseInt(width) * (3 / 4)) + 'px';
newMaxHeight = parseInt(parseInt(width, 10) * (3 / 4), 10) + 'px';
} else {
newMaxHeight = height;
}
Expand All @@ -130,7 +93,6 @@
(width === '100%' || height === '100%') &&
!inPageExperienceId
) {

props.setAttributes({
...props.attributes,
width: width === '100%' ? maxWidth : undefined,
Expand Down Expand Up @@ -352,14 +314,6 @@
playlistId;
}

if (typeof height === 'undefined') {
height = maxHeight || 250;
}

if (typeof width === 'undefined') {
width = maxWidth || 500;
}

const players = wpbc.players[accountId]
.filter((player) => {
return playlistId ? player.is_playlist : !player.is_playlist;
Expand Down Expand Up @@ -586,10 +540,9 @@
},
],
onChange: function (value) {

props.setAttributes({
...props.attributes,
aspect_ratio: value
aspect_ratio: value,
});
},
}),
Expand Down

0 comments on commit 62e903b

Please sign in to comment.