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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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="myCanvas"></div>
<!-- this div is what creates the scrollbar -->
<div style="height:3000px;"></div>
              
            
!

CSS

              
                #myCanvas {
	position:fixed; top:0px; left:50%; margin-left:-400px;
	box-shadow: 0px 0px 30px 12px rgba(0,0,0,.2);
}
              
            
!

JS

              
                const frame = new Frame("myCanvas", 800, 1600, yellow, green, {font:"reuben", src:"https://assets.codepen.io/1604712/Reuben.otf"});
frame.on("ready", ()=>{ // ES6 Arrow Function - similar to function(){}
    zog("ready from ZIM Frame"); // logs in console (F12 - choose console)

    // often need below - so consider it part of the template
    let stage = frame.stage;
    let stageW = frame.width;
    let stageH = frame.height;

    // REFERENCES for ZIM at http://zimjs.com
    // see http://zimjs.com/learn.html for video and code tutorials
    // see http://zimjs.com/docs.html for documentation
    // see https://www.youtube.com/watch?v=pUjHFptXspM for INTRO to ZIM
    // see https://www.youtube.com/watch?v=v7OT0YrDWiY for INTRO to CODE

    // CODE HERE
   
    // ZIM Parallax
    // parallax is when things move at different rates to suggest depth
    // normally, parallax works with x and y mouse movement
    // but scrollX and scrollY can also be used (as can a custom input)
    // Scroll Parallax may just animate objects and not really be parallax
    // that is the case in this case

    // Here are other ZIM Parallax examples:
    // https://zimjs.com/bits/view/parallax.html
    // https://zimjs.com/bits/view/parallax2.html
    // https://codepen.io/danzen/pen/BeaBvg
    // https://codepen.io/danzen/pen/moBMeY
    // https://zimjs.com/droid2/index.html
    // https://zimjs.com/vr.html
    // http://danzen.com/holiday2015/
    // https://zimjs.com/parallax.html


    // Create a page to hold things we want to scroll
    const page = new Page(stageW, 3000, yellow, orange).addTo();
    pizzazz.makePattern("stripes", series([grey,clear]), 20, 151, 40)
        .rot(90)
        .alp(.1)
        .center(page);

    // Create a Parallax object
    // we can pass things to parallax as an argument
    // or just use addLayer when we are ready to add things
    const parallax = new Parallax();
    parallax.addLayer({
			obj:page, // object to change
			prop:"y", // property to change
			propChange:-(3000-windowHeight()), // how much to change
			input:"scrollY", // input used to change
			inMin:0,
			inMax:3000-windowHeight() // range to change
    });

    // here we add the parallax after we animate the header in
    // otherwise the parallax setting would confict with the animation
    const header = new Container()
        .addTo(page)
        .animate({
            from:true,
            props:{y:-200},
            ease:"bounceOut",
            call:() => {
                parallax.addLayer({
                    obj:header,
                    prop:"y",
                    propChange:-200,
                    input:"scrollY",
                    inMin:0,
                    inMax:100
                });
            }
        })
        .tap(() => {
            scrollY(1800, 3); // scroll to bottom in 3 seconds
        });
    new Rectangle(stageW, 200, purple).addTo(header).sha("rgba(0,0,0,.2)",0,10,10)
    new Label({text:"ZIM Scroll Parallax", font:"reuben", color:white, size:60, variant:true}).center(header);


    STYLE = {
        font:"reuben",
        align:CENTER,
        valign:CENTER,
        color:white,
        backing:new Rectangle(60, 60, purple, null, null, 5).sha(),
        letterSpacing:15
    }

    // LETTERS
    // We could create separate Label objects and add to a vertical Tile
    // but here we use LabelLetters which is horizontal
    // and then rotate 90 and rotate each letter -90
    // we then loop through these and add Parallax
    // but... we want the letters to come in from each side
    // so we prepare a series() to give us the values we want
    // for the starting position and the propChange for the parallax
    // the range is created with a little trial and error
    // probably there is a programatical way
    // to center these based on position and windowHeight()

    const letters = new LabelLetters("PARALLAX").sca(3).rot(90).noMouse();
    const dir = series(-200,200,200,-200); // each time this is called it returns the next value
    letters.loop((letter, i)=>{
        letter.rot(-90).mov(0,dir());
        parallax.addLayer({
            obj: letter,
            prop: "y",
            propChange:dir(),
            input:"scrollY",
            inMin:50+180*i,
            inMax:50+180*i+10
        });
    });
    letters.pos(0,300,CENTER,TOP,page);


    // Create a link at the bottom to scroll to the top
    STYLE = {font:"reuben"};
    const top = new Label("TOP").pos(0,3000,CENTER,TOP,page).tap(()=>{
        scrollY(0,3); // to 0 in three seconds
    });
    parallax.addLayer({
        obj: top,
        prop: "y",
        propChange:-800,
        input:"scrollY",
        inMin:1400,
        inMax:1450
    });

    // start the page at the top incase refreshing when scrolled down
    scrollY(0);
	
    stage.update(); // this is needed to show any changes
  
    // DOCS FOR ITEMS USED
		// https://zimjs.com/docs.html?item=Frame
		// https://zimjs.com/docs.html?item=Container
		// https://zimjs.com/docs.html?item=Rectangle
		// https://zimjs.com/docs.html?item=Label
		// https://zimjs.com/docs.html?item=LabelLetters
		// https://zimjs.com/docs.html?item=Page
		// https://zimjs.com/docs.html?item=tap
		// https://zimjs.com/docs.html?item=noMouse
		// https://zimjs.com/docs.html?item=animate
		// https://zimjs.com/docs.html?item=loop
		// https://zimjs.com/docs.html?item=sha
		// https://zimjs.com/docs.html?item=pos
		// https://zimjs.com/docs.html?item=mov
		// https://zimjs.com/docs.html?item=alp
		// https://zimjs.com/docs.html?item=rot
		// https://zimjs.com/docs.html?item=sca
		// https://zimjs.com/docs.html?item=addTo
		// https://zimjs.com/docs.html?item=center
		// https://zimjs.com/docs.html?item=Parallax
		// https://zimjs.com/docs.html?item=series
		// https://zimjs.com/docs.html?item=scrollY
		// https://zimjs.com/docs.html?item=windowHeight
		// https://zimjs.com/docs.html?item=zog
		// https://zimjs.com/docs.html?item=STYLE
  

}); // end of ready
              
            
!
999px

Console