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.

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.

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-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("https://assets.neunie.com/files/codepen/mask_image/reveal.svg");
    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