Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Details

Privacy

Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

Template

Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:

Screenshot

Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO

HTML

              
                <link href="../../shared/css/styles.css" type="text/css" rel="stylesheet">
<link href="../../shared/css/fonts.css" type="text/css" rel="stylesheet"><style>
            * {
                margin: 0;
                padding: 0;
            }
            body.portrait,
            body.portrait.cw {
                transform: translateY(720px) rotate(-90deg);
                -ms-transform: translateY(720px) rotate(-90deg); /* IE 9 */
                -webkit-transform: translateY(720px) rotate(-90deg); /* Safari and Chrome */
                -o-transform: translateY(720px) rotate(-90deg); /* Opera */
                -moz-transform: translateY(720px) rotate(-90deg); /* Firefox */
                transform-origin: top left;
                -ms-transform-origin: top left;
                -webkit-transform-origin: top left;
                -o-transform-origin: top left;
                -moz-transform-origin: top left;
            }
            body.portrait.ccw {
                transform: translateX(1280px) rotate(90deg);
                -ms-transform: translateX(1280px) rotate(90deg);
                -webkit-transform: translateX(1280px) rotate(90deg);
                -o-transform: translateX(1280px) rotate(90deg);
                -moz-transform: translateX(1280px) rotate(90deg);
                transform-origin: top left;
                -ms-transform-origin: top left;
                -webkit-transform-origin: top left;
                -o-transform-origin: top left;
                -moz-transform-origin: top left;
            }
            .container {
                margin: 0;
                padding: 0;
            }
            #corner_logo {
                position: absolute;
                top: 20px;
                right: 20px;
                z-index: 10000;
            }
            #master_container {
                overflow: hidden;
                position: relative;
            }
            #master_container div {
                background-repeat: no-repeat;
            }
            #master_container p {
                margin: 0;
                white-space: pre;
            }
            .landscape {
              height: 720px;
              width: 1280px;
            }
            .portrait {
              height: 1280px;
              width: 720px;
            }
            .fixgen {
                position: absolute;
            }
        </style></head><body id="body" class="landscape cw">
        <div class="container">
            <div id="master_container" class="landscape"></div>
        </div>
</body></html>

              
            
!

CSS

              
                
              
            
!

JS

              
                
        var date = new Date(); // get todays date;
        var day = date.getDay(); // get the day of the week that is today.

        var type; // advert type: basic, fixgen

        //var fixgenData = new Array(); // fixgen fixture data from AJAX

        var assetArray = new Array();

        var masterTimeline = new TimelineMax( { paused: true, repeat: -1, onRepeat: masterTimelineComplete } );

        //var objectArray = new Array();

        function build() {

            $.each(objectArray, function(a, b) {
                //console.log(a, b);

                var fixgenData = new Array();

                type = b.details.type;

                // check the schedule and if the advert is scheduled for today, build it, else skip it
                if(b.schedule[day] == 1) {

                    // add background colour
                    $('#master_container').css('background-color', b.details.background);

                    var objectSubTimeline = new TimelineMax( { onStart: objectSubTimelineStart, onStartParams: [ assetArray ], onComplete: objectSubTimelineComplete, onCompleteParams: [ assetArray ] } );
                    var duration = b.details.duration;

                    // Get fixgen fixtures via AJAX
                    if(type == 'fixgen') {
                        $.ajax({
                            async: false, // this makes sure the AJAX call complates before we attempt to build the advert
                            crossDomain: true,
                            dataType: 'json',
                            timeout: 500,
                            url: 'http://api.adgentv.com/api/get_fixtures/'+ entityType +'/' + entityId
                        }).done(function(data) {
                            // split the returned data into groups of 3
                            var i,j,temparray,chunk = 3;

                            for (i=0,j=data.length; i<j; i+=chunk) {
                                temparray = data.slice(i,i+chunk);
                                fixgenData.push(temparray);
                            }

                            buildAssets(b.assets, fixgenData, objectSubTimeline);
                        }).error(function() {
                            duration = 10000;

                            $('#master_container').append('<div><img src="https://storage.googleapis.com/adgen-web-adverts/7963/' + b.assets[0].src + '"/>');
                            $('#master_container').append('<div class="error" style="color:white;font-family:Archivo Black;font-size:40px;position:absolute;text-align:center;top:50%;width:1280px;"><p>Sorry, we are currently unable to fetch your fixtures.');

                            var timeline = new TimelineMax();

                            timeline.set($('.error'), { opacity: 0 } );

                            timeline.to($('.error'), 5, { opacity: 1 });

                            objectSubTimeline.add(timeline);

                            masterTimeline.add(objectSubTimeline);
                        });
                    } else {
                        buildAssets(b.assets, fixgenData, objectSubTimeline);
                    }

                    objectSubTimeline.set({}, {}, duration / 1000);
                } else {
                    // if not scheduled to play, call the reload() function via the JS Interface
                    if(typeof Android != 'undefined') {
                        Android.reload();
                    }
                }

            });
        }
        
        function toRadians (angle) {
            return angle * (Math.PI / 180);
        }

        function buildAssets(assets, fixgenData, objectSubTimeline) {
            var fixgenAssetArray = new Array();

            if(fixgenData.length > 0) {
                //var fixgenTimeline = new TimelineMax( { onStart: fixgenTimelineStart, onStartParams: [ assetArray ], onComplete: fixgenTimelineComplete, onCompleteParams: [ assetArray ] } );

                var fixgenMasterTimeline = new TimelineMax( { onComplete: fixgenTimelineComplete } );

                // Loop through fixgen data and replace text assets
                $.each(fixgenData, function(a, fixtures) {
                    //console.log(a, fixtures);

                    //var fixgenAssetArray = new Array();

                    var fixtureTimeline = new TimelineMax( { onStart: fixtureTimelineStart, onStartParams: [ fixgenAssetArray ], onComplete: fixtureTimelineComplete, onCompleteParams: [ fixgenAssetArray ] } );

                    $.each(fixtures, function(b, fixture) {

                        var index = b + 1;

                        $.each(assets, function(c, asset) {
                            var width;
                            var left;

                            fixgenAssetArray.push(asset.type + '_' + asset.id+'_'+fixture.id);

                            if(asset.type == 'text') {
                                if(asset.name == '[home'+index+']') {
                                    $('#master_container').append('<div class="fixgen" id="'+asset.type+'_'+asset.id+'_'+fixture.id+'"><p>'+fixture.home_team+'');
                                    //textAlign = asset.textAlign;
                                }
                                if(asset.name == '[away'+index+']') {
                                    $('#master_container').append('<div class="fixgen" id="'+asset.type+'_'+asset.id+'_'+fixture.id+'"><p>'+fixture.away_team+'');
                                    //textAlign = asset.textAlign;
                                }
                                if(asset.name == '[date'+index+']') {
                                    $('#master_container').append('<div class="fixgen" id="'+asset.type+'_'+asset.id+'_'+fixture.id+'"><p>'+fixture.datetime+'');
                                }

                            } else if(asset.type == 'image') {
                              if(asset.name == '[image'+index+']') {
                                $('#master_container').append('<div class="fixgen" id="'+asset.type+'_'+asset.id+'_'+fixture.id+'">');
                              }
                            }

                            TweenMax.set($('#' + asset.type + '_' + asset.id+'_'+fixture.id), { autoAlpha: 0 } );

                            var timeline = new TimelineMax();

                            timeline.set($('#' + asset.type + '_' + asset.id+'_'+fixture.id), { autoAlpha: 1, immediateRender: false } );

                            // Set properties
                            if(asset.type == 'text') {
                                timeline.set( $('#' + asset.type + '_' + asset.id+'_'+fixture.id), {
                                    color: asset.transitions[0].fill,
                                    fontFamily: asset.fontFamily,
                                    fontSize: asset.fontSize,
                                    textShadow: shadow,
                                    textAlign: asset.textAlign,
                                    lineHeight: asset.lineHeight+"em",
                                    height: asset.transitions[0].height + "px",
                                    position: "absolute",
                                    whiteSpace: 'nowrap',
                                    opacity: asset.transitions[0].opacity,
                                    scaleX: asset.transitions[0].scaleX,
                                    scaleY: asset.transitions[0].scaleY,
                                    rotation: asset.transitions[0].angle,
                                    width: asset.transitions[0].width + "px",
                                    x: asset.transitions[0].left - (asset.transitions[0].width / 2),
                                    y: asset.transitions[0].top - (asset.transitions[0].height / 2),
                                    transformOrigin: asset.transitions[0].originX + " " + asset.transitions[0].originY,
                                    immediateRender: false
                                });
                            } else if(asset.type == 'image') {
                              timeline.set($('#' + asset.type + '_' + asset.id+'_'+fixture.id), {
                                  backgroundImage: "url('https://storage.googleapis.com/adgen-web-adverts/7963/"+ asset.src +"')",
                                  height: asset.transitions[0].height + "px",
                                  position: "absolute",
                                  opacity: parseInt(asset.transitions[0].opacity),
                                  width: asset.transitions[0].width + "px",
                                  scaleX: asset.transitions[0].scaleX,
                                  scaleY: asset.transitions[0].scaleY,
                                  rotation: parseInt(asset.transitions[0].angle),
                                  x: asset.transitions[0].left - (asset.transitions[0].width / 2),
                                  y: asset.transitions[0].top - (asset.transitions[0].height / 2),
                                  transformOrigin: asset.transitions[0].originX + " " + asset.transitions[0].originY,
                                  immediateRender: false
                              });
                            }

                            // Loop through transitions and add to timeline
                            $.each(asset.transitions, function(d, t) {
                                var x, y;

                                if(t.originX == 'left') {
                                      x = t.left;
                                } else if(t.originX == 'right') {
                                      x = t.left - t.width;
                                } else if(t.originX == 'center') {
                                      x = t.left - (t.width / 2);
                                }

                                if(t.originY == 'top') {
                                    y = t.top;
                                } else if(t.originY == 'center') {
                                    y = t.top - (t.height / 2);
                                }

                                timeline.to( $('#' + asset.type + '_' + asset.id+'_'+fixture.id), t.duration / 1000, { delay: t.wait / 1000, ease: t.easing, opacity: t.opacity, rotation: t.angle, scaleX: t.scaleX, scaleY: t.scaleY, x: x, y: y }, 0);
                            });

                            fixtureTimeline.add(timeline, 0);
                            fixtureTimeline.set({}, {}, 10);
                        });

                    });

                    //masterTimeline.add(fixtureTimeline);
                    fixgenMasterTimeline.add(fixtureTimeline);
                });

                $.each(assets, function(e, asset){
                    TweenMax.set($('#' + asset.type + '_' + asset.id), { autoAlpha: 0 } );

                    var timeline = new TimelineMax();

                    timeline.set($('#' + asset.type + '_' + asset.id), { autoAlpha: 1, immediateRender: false } );

                    if(asset.type == 'text') {

                      var arr2 = ['[date1]', '[home1]', '[away1]', '[date2]', '[home2]', '[away2]', '[date3]', '[home3]', '[away3]'];

                      if(jQuery.inArray(asset.name, arr2) == -1) {
                        //$('#master_container').append('<div id="' + asset.type + '_' + asset.id + '"><p style="disply:block;height:' + asset.transitions[0].height + 'px;">' + asset.text.replace(/\n/g, "<br />") + '');
                        $('#master_container div.fixgen').eq(e).before('<div id="' + asset.type + '_' + asset.id + '"><p style="disply:block;height:' + asset.transitions[0].height + 'px;">' + asset.text.replace(/\n/g, "<br />") + '');

                        timeline.set($('#' + asset.type + '_' + asset.id), {
                            color: asset.transitions[0].fill,
                            fontFamily: asset.fontFamily,
                            fontSize: asset.fontSize + "px",
                            textShadow: shadow,
                            textAlign: asset.textAlign,
                            lineHeight: asset.lineHeight+"em",
                            height: asset.transitions[0].height + "px",
                            whiteSpace: 'nowrap',
                            position: "absolute",
                            opacity: asset.transitions[0].opacity,
                            scaleX: asset.transitions[0].scaleX,
                            scaleY: asset.transitions[0].scaleY,
                            rotation: asset.transitions[0].angle,
                            width: asset.transitions[0].width + "px",
                            x: asset.transitions[0].left - (asset.transitions[0].width / 2),
                            y: asset.transitions[0].top - (asset.transitions[0].height / 2),
                            transformOrigin: asset.transitions[0].originX + " " + asset.transitions[0].originY,
                        });

                        $.each(asset.transitions, function(d, t) {
                            var x, y;

                            if(t.originX == 'left') {
                                x = t.left;
                            } else if(t.originX == 'right') {
                                x = t.left - t.width;
                            } else if(t.originX == 'center') {
                                x = t.left - (t.width / 2);
                            }
                            if(t.originY == 'top') {
                                y = t.top;
                            } else if(t.originY == 'center') {
                                y = t.top - (t.height / 2);
                            }

                            timeline.to( $('#' + asset.type + '_' + asset.id), t.duration / 1000, { delay: t.wait / 1000, ease: t.easing, opacity: t.opacity, rotation: t.angle, scaleX: t.scaleX, scaleY: t.scaleY, x: x, y: y }, 0);
                        });

                        fixgenMasterTimeline.add(timeline, 0);
                      }
                    } else if(asset.type == 'image') {
                      if(asset.name != '[image1]' && asset.name != '[image2]' && asset.name != '[image3]') {
                        $('#master_container div.fixgen').eq(e).before('<div class="fixgen" id="'+asset.type + '_' + asset.id +'">');

                        //TweenMax.set($('#' + asset.type + '_' + asset.id), { autoAlpha: 0 } );

                        //var timeline = new TimelineMax();

                        //timeline.set($('#' + asset.type + '_' + asset.id), { autoAlpha: 1, immediateRender: false } );

                        timeline.set($('#' + asset.type + '_' + asset.id), {
                            backgroundImage: "url('https://storage.googleapis.com/adgen-web-adverts/7963/"+ asset.src +"')",
                            height: asset.transitions[0].height + "px",
                            position: "absolute",
                            opacity: parseInt(asset.transitions[0].opacity),
                            width: asset.transitions[0].width + "px",
                            scaleX: asset.transitions[0].scaleX,
                            scaleY: asset.transitions[0].scaleY,
                            rotation: parseInt(asset.transitions[0].angle),
                            x: asset.transitions[0].left - (asset.transitions[0].width / 2),
                            y: asset.transitions[0].top - (asset.transitions[0].height / 2),
                            transformOrigin: asset.transitions[0].originX + " " + asset.transitions[0].originY,
                            immediateRender: false
                        });

                        $.each(asset.transitions, function(d, t) {
                            var x, y;

                            if(t.originX == 'left') {
                                x = t.left;
                            } else if(t.originX == 'right') {
                                x = t.left - t.width;
                            } else if(t.originX == 'center') {
                                x = t.left - (t.width / 2);
                            }
                            if(t.originY == 'top') {
                                y = t.top;
                            } else if(t.originY == 'center') {
                                y = t.top - (t.height / 2);
                            }

                            timeline.to( $('#' + asset.type + '_' + asset.id), t.duration / 1000, { delay: t.wait / 1000, ease: t.easing, opacity: t.opacity, rotation: t.angle, scaleX: t.scaleX, scaleY: t.scaleY, x: x, y: y }, 0);
                        });

                        fixgenMasterTimeline.add(timeline, 0);
                      }
                    } else if(asset.type == "rect") {
                        $('#master_container div.fixgen').eq(e).before('<div class="fixgen" id="'+asset.type + '_' + asset.id +'">');

                        timeline.set($('#' + asset.type + '_' + asset.id), {
                            backgroundColor: asset.transitions[0].fill,
                            height: asset.transitions[0].height + "px",
                            position: "absolute",
                            opacity: parseInt(asset.transitions[0].opacity),
                            width: asset.transitions[0].width + "px",
                            scaleX: asset.transitions[0].scaleX,
                            scaleY: asset.transitions[0].scaleY,
                            rotation: parseInt(asset.transitions[0].angle),
                            x: asset.transitions[0].left - (asset.transitions[0].width / 2),
                            y: asset.transitions[0].top - (asset.transitions[0].height / 2),
                            transformOrigin: asset.transitions[0].originX + " " + asset.transitions[0].originY,
                            immediateRender: false
                        });

                        $.each(asset.transitions, function(d, t) {
                            var x, y;

                            if(t.originX == 'left') {
                                x = t.left;
                            } else if(t.originX == 'right') {
                                x = t.left - t.width;
                            } else if(t.originX == 'center') {
                                x = t.left - (t.width / 2);
                            }
                            if(t.originY == 'top') {
                                y = t.top;
                            } else if(t.originY == 'center') {
                                y = t.top - (t.height / 2);
                            }

                            timeline.to( $('#' + asset.type + '_' + asset.id), t.duration / 1000, { delay: t.wait / 1000, ease: t.easing, opacity: t.opacity, rotation: t.angle, scaleX: t.scaleX, scaleY: t.scaleY, x: x, y: y }, 0);
                        });

                        fixgenMasterTimeline.add(timeline, 0);
                    }
                });

                masterTimeline.add(fixgenMasterTimeline);

            } else {
                $.each(assets, function(a, asset){

                    assetArray.push(asset.type + '_' + asset.id);

                    if(asset.type == "text") {
                        $('#master_container').append('<div id="asset_' + asset.type + '_' + asset.id + '"><p style="disply:block;height:' + asset.transitions[0].height + 'px;">' + asset.text.replace(/\n/g, "<br />") + '');
                    } else if(asset.type == "image") {
                        $('#master_container').append('<div id="asset_' + asset.type + '_' + asset.id + '"><img class="svg" />');
                    } else if(asset.type == "rect") {
                        $('#master_container').append('<div id="asset_' + asset.type + '_' + asset.id + '">');
                    }

                    var x, y, originX, originY, width, height, xPercent, yPercent, scaleX, scaleY;
                    
                    var cx, cy;   
                    
                    originX = asset.transitions[0].originX;
                    originY = asset.transitions[0].originY;
        
                    x = parseInt(asset.transitions[0].left);
                    y = parseInt(asset.transitions[0].top);
                    
                    width = parseInt(asset.transitions[0].width);
                    height = parseInt(asset.transitions[0].height);
                    
                    var boundingWidth = parseInt(asset.transitions[0].boundingWidth);
                    var boundingHeight = parseInt(asset.transitions[0].boundingHeight);

                    var angle = parseFloat(asset.transitions[0].angle);
                    
                    scaleX = parseFloat(asset.transitions[0].scaleX);
                    scaleY = parseFloat(asset.transitions[0].scaleY);
                
                    if(angle >= 90) {
                        boundingHeight = [boundingWidth, boundingWidth = boundingHeight][0];
                    }
                    
                    switch(originX) {
                        case 'left':
                            xPercent = 0;
                            break;
                        case 'center':
                            xPercent = -50;
                            break;
                        case 'right':
                            xPercent = -100;
                            break;
                    }

                    switch(originY) {
                        case 'top':
                            yPercent = 0;
                            break;
                        case 'center':
                            yPercent = -50;
                            break;
                        case 'bottom':
                            yPercent = -100;
                            break;
                    }
                    
                    if(originY == 'top' && originX == 'left') {
                        // find other points

                        var nW, nH;

                        nW = width * asset.transitions[0].scaleX;
                        nH = height * asset.transitions[0].scaleY;

                        //console.log(x, y);

                        // top right
                        var x1 = x + (nW * Math.cos(toRadians(angle)));
                        var y1 = y + (nW * Math.sin(toRadians(angle)));

                        //console.log(x1, y1);

                        // bottom right
                        var x2 = x1 + (nH * Math.cos(toRadians(angle+90)));
                        var y2 = y1 + (nH * Math.sin(toRadians(angle+90)));

                        //console.log(x2, y2);

                        // find centre
                        cx = (x + x2) / 2;
                        cy = (y + y2) / 2;

                        //console.log(cx, cy);
                    }
                    if(originY == 'top' && originX == 'right') {
                        // find other points

                        var nW, nH;

                        nW = width * asset.transitions[0].scaleX;
                        nH = height * asset.transitions[0].scaleY;

                        //console.log(x, y);

                        // top right
                        var x1 = x + (nH * Math.cos(toRadians(angle+90)));
                        var y1 = y + (nH * Math.sin(toRadians(angle+90)));

                        //console.log(x1, y1);

                        // bottom right
                        var x2 = x1 + (nW * Math.cos(toRadians(angle+180)));
                        var y2 = y1 + (nW * Math.sin(toRadians(angle+180)));

                        //console.log(x2, y2);

                        // find centre
                        cx = (x + x2) / 2;
                        cy = (y + y2) / 2;

                        //console.log(cx, cy);
                    }
                    if(originY == 'top' && originX == 'center') {
                        // find other points

                        var nW, nH;

                        nW = width * asset.transitions[0].scaleX;
                        nH = height * asset.transitions[0].scaleY;

                        //console.log(x, y);

                        // top right
                        var x1 = x + ((nW / 2) * Math.cos(toRadians(angle)));
                        var y1 = y + ((nW / 2) * Math.sin(toRadians(angle)));

                        //console.log(x1, y1);

                        // bottom right
                        var x2 = x1 + (nH * Math.cos(toRadians(angle+90)));
                        var y2 = y1 + (nH * Math.sin(toRadians(angle+90)));

                        // bottom left
                        var x3 = x2 + (nW * Math.cos(toRadians(angle+180)));
                        var y3 = y2 + (nW * Math.sin(toRadians(angle+180)));

                        //console.log(x2, y2);

                        // find centre
                        cx = (x1 + x3) / 2;
                        cy = (y1 + y3) / 2;

                        //console.log(cx, cy);
                    }
                    if(originY == 'center' && originX == 'left') {
                        var nW, nH;

                        nW = width * asset.transitions[0].scaleX;
                        nH = height * asset.transitions[0].scaleY;

                        // top left
                        var x1 = x + ((nH / 2) * Math.cos(toRadians(angle+270)));
                        var y1 = y + ((nH / 2) * Math.sin(toRadians(angle+270)));

                        // top right
                        var x2 = x1 + (nW * Math.cos(toRadians(angle)));
                        var y2 = y1 + (nW * Math.sin(toRadians(angle)));

                        // bottom right
                        var x3 = x2 + (nH * Math.cos(toRadians(angle+90)));
                        var y3 = y2 + (nH * Math.sin(toRadians(angle+90)));

                        cx = (x1 + x3) / 2;
                        cy = (y1 + y3) / 2;
                    }

                    if(originY == 'center' && originX == 'right') {
                        var nW, nH;

                        nW = width * asset.transitions[0].scaleX;
                        nH = height * asset.transitions[0].scaleY;

                        var x1 = x + ((nH / 2) * Math.cos(toRadians(angle+90)));
                        var y1 = y + ((nH / 2) * Math.sin(toRadians(angle+90)));

                        var x2 = x1 + (nW * Math.cos(toRadians(angle+180)));
                        var y2 = y1 + (nW * Math.sin(toRadians(angle+180)));

                        var x3 = x2 + (nH * Math.cos(toRadians(angle+270)));
                        var y3 = y2 + (nH * Math.sin(toRadians(angle+270)));

                        cx = (x1 + x3) / 2;
                        cy = (y1 + y3) / 2;
                    }

                    var timeline = new TimelineMax();

                    timeline.set($('#asset_' + asset.type + '_' + asset.id), { autoAlpha: 1, immediateRender: false } );

                    if(asset.type == "text") {

                        var shadow;
                        if(asset.transitions[0].shadow) {
                            var shadow_props = JSON.parse(asset.transitions[0].shadow);
                            shadow = shadow_props.offsetX + 'px ' + shadow_props.offsetY + 'px ' + shadow_props.blur + 'px ' + shadow_props.color;
                        } else {
                            shadow = '';
                        }

                        timeline.set( $('#asset_' + asset.type + '_' + asset.id), {
                            color: asset.transitions[0].fill,
                            fontFamily: asset.fontFamily,
                            fontSize: asset.fontSize + "px",
                            fontWeight: asset.fontWeight,
                            fontStyle: asset.fontStyle,
                            textShadow: shadow,
                            textAlign: asset.textAlign,
                            lineHeight: asset.lineHeight+"em",
                            whiteSpace: 'nowrap',
                            height: asset.transitions[0].height + "px",
                            position: "absolute",
                            opacity: asset.transitions[0].opacity,
                            scaleX: asset.transitions[0].scaleX,
                            scaleY: asset.transitions[0].scaleY,
                            rotation: asset.transitions[0].angle,
                            width: asset.transitions[0].width + "px",
                            x: cx,
                            y: cy,
                            xPercent: -50,
                            yPercent: -50,
                            //transformOrigin: asset.transitions[0].originX + " " + asset.transitions[0].originY,
                            transformOrigin: "center center",
                            immediateRender: false
                        } );

                    } else if(asset.type == "image") {
                        $('#asset_' + asset.type + '_' + asset.id + ' img').attr('src', 'https://storage.googleapis.com/adgen-web-adverts/7963/'+asset.src);
                        timeline.set($('#asset_' + asset.type + '_' + asset.id), {
                            //backgroundImage: "url('"+ asset.src +"')",
                            height: asset.transitions[0].height + "px",
                            position: "absolute",
                            opacity: parseInt(asset.transitions[0].opacity),
                            width: asset.transitions[0].width + "px",
                            scaleX: asset.transitions[0].scaleX,
                            scaleY: asset.transitions[0].scaleY,
                            rotation: parseInt(asset.transitions[0].angle),
                            x: x,
                            y: y,
                            xPercent: xPercent,
                            yPercent: yPercent,
                            transformOrigin: asset.transitions[0].originX + " " + asset.transitions[0].originY,
                            immediateRender: false
                        } );
                        var filename = asset.src;
                        var fileParts = filename.split(".");

                        if(fileParts[1] == 'svg') {
                            if(asset.transitions[0].filter) {
                                var filter_props = JSON.parse(asset.transitions[0].filter);
                                var color = filter_props[0].color;

                                findSvgs($('#asset_' + asset.type + '_' + asset.id + ' img'), color);
                            }
                        }
                    } else if(asset.type == "rect") {
                        timeline.set($('#asset_' + asset.type + '_' + asset.id), {
                            backgroundColor: asset.transitions[0].fill,
                            height: asset.transitions[0].height + "px",
                            position: "absolute",
                            opacity: parseInt(asset.transitions[0].opacity),
                            width: asset.transitions[0].width + "px",
                            scaleX: asset.transitions[0].scaleX,
                            scaleY: asset.transitions[0].scaleY,
                            rotation: parseInt(asset.transitions[0].angle),
                            x: x,
                            y: y,
                            xPercent: xPercent,
                            yPercent: yPercent,
                            transformOrigin: asset.transitions[0].originX + " " + asset.transitions[0].originY,
                            immediateRender: false
                        });
                    }
                    $.each(asset.transitions, function(e, t) {
                        var x, y;
                        var cx, cy;

                        x = parseInt(t.left);
                        y = parseInt(t.top);

                        var angle = parseInt(t.angle);

                        var boundingWidth = parseInt(t.boundingWidth);
                        var boundingHeight = parseInt(t.boundingHeight);

                        if(angle >= 90) {
                            boundingHeight = [boundingWidth, boundingWidth = boundingHeight][0];
                        }

                        switch(t.originX) {
                            case 'left':
                                //x = parseInt(f.left) + (f.boundingWidth / 2);
                                break;
                            case 'center':
                                break;
  
              
            
!
999px
💕 I'm the CSS to your HTML.

Console