Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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.

Behavior

Auto Save

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.

HTML

              
                  <div id="banner">

    <div id="screen1" class="fullsize"></div>
    <div id="screen2" class="fullsize"></div>
    <div class="fullsize masked"> <!--this div contains all the content we are going to mask out, in this case a video-->
      <video id="video1" muted playsinline></video>
    </div>
    <div id="reveal"></div>

    <div id="border"></div>
  </div><!--BANNER END--> 
              
            
!

CSS

              
                body,
#banner,
#banner * {
    background-repeat: no-repeat;
    background-size: contain;
    position: absolute
}

#banner * span,
#banner * br {
    position: relative
}

body {
    overflow: hidden;
    margin: 0px;
    padding: 0px;
    -webkit-font-smoothing: antialiased
}

#banner,
#border {
    top: 0px;
    left: 0px;
    overflow: hidden
}

#border {
    position: absolute;
    border: 1px #51555a solid;
    cursor: pointer;
    top: 0px;
    left: 0px;
    overflow: hidden
}

#banner {
    background-color: #fff
}

.masked {
/*     -webkit-mask-image: url("https://assets.neunie.com/files/codepen/mask_image/mask.svg");
    mask-image: url("https://assets.neunie.com/files/codepen/mask_image/mask.svg"); */
    -webkit-mask-image: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0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zMiwxNi45NzI1IDI5LjI2NjY2NjcsMTQuMTYzNzUgMjUuODEzMzMzMywxMy45Mjc1IEMyNC44OTMzMzMzLDkuMzk5Mzc1IDIwLjg1MzMzMzMsNiAxNiw2IFoiIGlkPSJTaGFwZSIgZmlsbD0iIzAwMDAwMCIgZmlsbC1ydWxlPSJub256ZXJvIj48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=");
    -webkit-mask-size: 36px 36px;
    mask-size: 36px 36px;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: 50% 60%;
    mask-position: 50% 60%
}

#reveal {
    background-image: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNDBweCIgaGVpZ2h0PSI0MHB4IiB2aWV3Qm94PSIwIDAgNDAgNDAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvcjogU2tldGNoIDU4ICg4NDY2MykgLSBodHRwczovL3NrZXRjaC5jb20gLS0+CiAgICA8dGl0bGU+cmV2ZWFsPC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGcgaWQ9InJldmVhbCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9IndiX2Nsb3VkeV9ibGFja18yNGRwIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg0LjAwMDAwMCwgNC4wMDAwMDApIj4KICAgICAgICAgICAgPHBvbHlnb24gaWQ9IlBhdGgiIHBvaW50cz0iMCAwIDMyIDAgMzIgMzIgM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=");
    background-size: contain;
    width: 38px;
    height: 38px
}

#screen1 {
    background-image: url("https://assets.neunie.com/files/codepen/mask_image/screen1.png")
}

#screen2 {
    background-image: url("https://assets.neunie.com/files/codepen/mask_image/screen2.png");
    opacity: 0
}
              
            
!

JS

              
                //set banner width and height
var ad_width = 300;
var ad_height = 250;

var body = document.getElementsByTagName("body");
var banner = document.getElementById("banner");
var border = document.getElementById("border");
var fullsize = document.getElementsByClassName('fullsize');
    body[0].style.width = ad_width + "px";
    body[0].style.height = ad_height + "px";
    banner.style.width = ad_width + "px";
    banner.style.height = ad_height + "px";
    border.style.width = (ad_width - 2) + "px";
    border.style.height = (ad_height - 2) + "px";

for (var i = 0; i < fullsize.length; i++) {
        fullsize[i].style.width = ad_width + "px";
        fullsize[i].style.height = ad_height + "px";
}

var tl;

//VIDEO SETUP
var videoUrl = 'https://assets.neunie.com/files/codepen/mask_image/food_300x250.mp4';
var videoDuration;

var video1 = document.getElementById("video1");

video1.setAttribute('src', videoUrl);


function startBanner(){ 
    tl = new TimelineMax();
    tl.set(['#banner'], {rotation: 0.01})
    tl.call(runVideo);
    tl.addLabel('start')
    tl.to('#banner', 0.3, { opacity:1, ease: Power2.easeOut},'=.3')      
        
        .to('.masked', 2.5, {css:{webkitMaskSize: maskExpandedDimensions, maskSize: maskExpandedDimensions}, ease: Power2.easeIn}, 'start+=.5')
        .to('#reveal', 2.5, {scale: maskScale, ease: Power2.easeIn}, 'start+=.5')
        .set('#screen2', {opacity: 1}, 'start+=3')
        .to('.masked', 1.5, {css:{webkitMaskSize: '0px 0px', maskSize: '0px 0px'}, ease: Power0.easeNone}, 'start+=3')
        .to('#reveal', 1.5, {scale: 0, ease: Power0.easeNone}, 'start+=3')

};

//MASK SCALE/ZOOM
var maskScale = 60;
var maskExpandedDimensions;
var maskedElementPosition;
var maskRevealOriginalSize;

//MASK REVEAL POSITION
function maskPrep () {
    var maskedElement = document.querySelector('.masked')
    //CONVERT MASK POSITION PERCENTAGE INTO A DECIMAL
    if (window.getComputedStyle(maskedElement).getPropertyValue("-webkit-mask-position") != "") {
        maskedElementPosition = window.getComputedStyle(maskedElement).getPropertyValue("-webkit-mask-position")
        maskRevealOriginalSize = window.getComputedStyle(maskedElement).getPropertyValue("-webkit-mask-size")
    } else {
        maskedElementPosition = window.getComputedStyle(maskedElement).getPropertyValue("mask-position")
        maskRevealOriginalSize = window.getComputedStyle(maskedElement).getPropertyValue("mask-size")
    }
    var maskedElementPositionY = maskedElementPosition.split(' ').pop()
    var maskedPositionYString = maskedElementPositionY.split('%')
    var maskPositionDecimal = parseInt(maskedPositionYString) / 100
    var reveal = document.getElementById('reveal');
        reveal.style.transformOrigin = maskedElementPosition;

    //CALCULATE REVEAL ELEMENT TOP AND LEFT
    var revealHeight = reveal.clientHeight;
    var revealWidth = reveal.clientWidth;
    var maskedRegionWidth = maskedElement.clientWidth;
    var maskedRegionHeight = maskedElement.clientHeight;
    var calculatedTop = (maskedRegionHeight * maskPositionDecimal) - (maskPositionDecimal * revealHeight) + "px";
    var calculatedLeft = (maskedRegionWidth / 2) - (revealWidth / 2) + "px";
        reveal.style.top = calculatedTop;
        reveal.style.left = calculatedLeft;

    //CALCULATE MASK SCALE FOR GSAP
    var maskScaleWidth = maskScale * revealWidth;
    var maskScaleHeight = maskScale * revealHeight;
        maskExpandedDimensions = maskScaleWidth + 'px ' + maskScaleHeight + 'px';
}

maskPrep()

//PLAY VIDEO
function runVideo() {
    video1.play();
}

//CAN VIDEO PLAY
function checkVideoCanPlay(){
    video1.addEventListener('canplaythrough', (event) => {
        startBanner()
      });
}

checkVideoCanPlay()
              
            
!
999px

Console