Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              const frame = new Frame("fit", 400, 300, darker, dark);
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
	 // Thanks https://codepen.io/eliCrow/pen/MLdddR for the elegant drag on path formula 
	 // we have installed it in the new ZIM 10.3.0 and works better than what we had!
	 // It feels wrong to compare... but ZIM is 46% the size of the Paper version 
	 // ZIM itself will be bigger as it contains the dragging on path code
	 // but it is nicely abstracted so you don't have to think about it...
    const path = new Squiggle({

    // using percentComplete works on the current animation only
    // so if planning on doing more than one animation, 
	 // add the object to a container and animate the container and object separately
    const circle = new Container();
    const circleShape = new Circle(6, green).addTo(circle);
		 		// setting drag pauses the animation 
		 		// but could circle.pauseAnimate(false) to drag while animating
            ease:"linear", // important for dragging on path
            rewind:true, // rewind allows us to animate backwards at the end
            loop:true, // animation would end (no drag) once rewound if not a loop
                circle.percentComplete = .01;
    circle.blendMode = "difference";

    const ticker = Ticker.add(()=>{
        if (circle.percentComplete > 49.9) { // half way through - due to rewind
            circleShape.animate([ // animation series in array
                {props:{scale:30}, time:1000, call:()=>{circle.pauseAnimate(false);}},
                {props:{scale:1}, time:3000}
    stage.update(); // this is needed to show any changes
	// https://zimjs.com/docs.html?item=Frame
	// https://zimjs.com/docs.html?item=Container
	// https://zimjs.com/docs.html?item=Circle
	// https://zimjs.com/docs.html?item=Squiggle
	// https://zimjs.com/docs.html?item=animate
	// https://zimjs.com/docs.html?item=pauseAnimate
	// https://zimjs.com/docs.html?item=addTo
	// https://zimjs.com/docs.html?item=centerReg
	// https://zimjs.com/docs.html?item=center
	// https://zimjs.com/docs.html?item=zog
	// https://zimjs.com/docs.html?item=Ticker 

}); // end of ready
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.