cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <div class="container">
<svg class="zipSVG" xmlns="http://www.w3.org/2000/svg"	 x="0px" y="0px" width="600px" height="600px" viewBox="0 0 600 600">
<defs>
<marker id="zipToothR" markerWidth="20" markerHeight="8" refX="4" refY="0" markerUnits="userSpaceOnUse"
	 viewBox="0 0 20 8">

<rect y="0" width="20" height="8" fill="#2d2d2d" />
</marker>	
	
<marker id="zipToothL" markerWidth="20" markerHeight="8" refX="8" refY="0" markerUnits="userSpaceOnUse"
	 viewBox="0 0 20 8">
<rect y="0" width="20" height="8" fill="#2d2d2d"/>
</marker>
	
<rect id="zipTooth" y="0" width="20" height="8" fill="#2d2d2d" />	

	
	<clipPath id="zipToothMask" >
	<rect class="zipToothMask" x="282" y="170" width="40" height="500" fill="#ffffff"/>
	</clipPath>
	
		<clipPath id="zipOpenMask" >
	<rect class="zipOpenMask" x="0" y="-330" width="500" height="500" fill="#FFFFFF"/>
	</clipPath>

	</defs>

	<g class="zipOpenToothGroup" clip-path="url(#zipOpenMask)"></g>
	
	<g class="zipToothGroup">
<polyline  clip-path="url(#zipToothMask)" fill="none"  stroke-miterlimit="10" points="299.5,156 299.5,175 299.5,194.1 299.5,213.1 299.5,232.2 
	299.5,251.2 299.5,270.3 299.5,289.3 299.5,308.4 299.5,327.4 299.5,346.5 299.5,365.5 299.5,384.6 299.5,403.6 299.5,422.6 
	299.5,441.7 299.5,460.7 299.5,479.8 299.5,498.8 299.5,517.9 299.5,536.9 299.5,556 " marker-mid="url(#zipToothR)"/>
<polyline clip-path="url(#zipToothMask)" fill="none" stroke="none" stroke-miterlimit="10" points="296.5,165 296.5,184 296.5,203.1 296.5,222.1 296.5,241.2 
	296.5,260.2 296.5,279.3 296.5,298.3 296.5,317.4 296.5,336.4 296.5,355.5 296.5,374.5 296.5,393.6 296.5,412.6 296.5,431.6 
	296.5,450.7 296.5,469.7 296.5,488.8 296.5,507.8 296.5,526.9 296.5,545.9 296.5,565 " marker-mid="url(#zipToothL)"/>
	
	</g>

</svg>

<!--ZIP TAG SVG-->
<svg class="zipTagSVG" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="44.7px" height="101.7px" viewBox="0 0 44.7 101.7" opacity="1">
<defs>
</defs>
<g id="zipTagGroup">
	<path fill="#2d2d2d" d="M31.4,40.4c-6-0.9-12-0.9-18,0c-3,0.5-6-1.3-6.5-4.2C5.1,27,3.2,17.7,0.2,8.4c-1-2.9,2-6.5,7.1-7.3
		c9.8-1.6,20.2-1.6,30.1,0c5.1,0.8,8.1,4.3,7.1,7.3c-3,9.3-4.9,18.6-6.6,27.8C37.3,39.2,34.4,40.9,31.4,40.4z"/>
	<path class="zipHandle" fill="#2d2d2d" stroke="#EDEDED" stroke-miterlimit="10" d="M9.2,28.7c0,0-1.9,34.8-5.5,54.8c-1.1,9.4,5.2,17.7,18.5,17.7
		c12.3,0,20-8.4,18.9-17.7c-3.6-20-5.5-54.8-5.5-54.8H9.2z M22.7,94.5c-6.3,0-11.5-3.7-11.5-8.3c0-4.6,5.1-8.3,11.5-8.3
		c6.3,0,11.5,3.7,11.5,8.3C34.2,90.8,29,94.5,22.7,94.5z"/>
	<path fill="#EDEDED" d="M23.5,43.5h-2.3c-1.6,0-3-1.3-3-3V6.6c0-1.7,1.4-3,3-3h2.3c1.7,0,3,1.3,3,3v33.9
		C26.5,42.2,25.2,43.5,23.5,43.5z"/>
</g>
</svg>
</div>
            
          
!
            
              body{
  background-color:#EDEDED;
  overflow:hidden;
}
body, html {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
}

.container{
  width:600px;
  height:600px;
}

svg{
	position:absolute;
}

.zipHandle{
	-webkit-tap-highlight-color:rgba(0,0,0,0);
}

            
          
!
            
              var xmlns="http://www.w3.org/2000/svg", xlinkns = "http://www.w3.org/1999/xlink";
//refs to the various elements to layout and animate
var container = document.querySelector('.container');
var zipSVG = document.querySelector('.zipSVG');
var zipTagSVG = document.querySelector('.zipTagSVG');
var zipToothMask = document.querySelector('.zipToothMask');
var zipOpenMask = document.querySelector('.zipOpenMask');
var zipTooth = document.querySelector('#zipTooth');
var zipHandle = document.querySelector('.zipHandle');

var zipOpenToothGroup = document.querySelector('.zipOpenToothGroup');

var zipToothMaskInitY = Number(zipToothMask.getAttribute('y'));
var zipOpenMaskInitY = Number(zipOpenMask.getAttribute('y'));
var zipOpenMaskHeight = Number(zipOpenMask.getAttribute('height'));

var minDragY = zipToothMaskInitY, maxDragY = 490, dragLength = maxDragY - minDragY, percentOpen;
var initOpenZipToothRPosX = 299.5;
var initOpenZipToothLPosX = 296.5;
var zipOpenIncrement = 2, numZipTeeth = 21;
var zipOpenTeethArrayL = [], zipOpenTeethArrayR = [];

createOpenZipTeeth();

//center the whole thing
TweenMax.set(container, {
  position:'absolute',
  top:'50%',
  left:'50%',
  xPercent:-50,
  yPercent:-50
})


TweenMax.set(zipTagSVG, {
	x:280,
	y:zipToothMaskInitY
})


Draggable.create(zipTagSVG, {
	type:'y',
	bounds:{minY:minDragY, maxY:maxDragY},
	onDrag:onDrag,
	onPress:function(){
		TweenMax.to(zipHandle, 0.1, {
			scaleY:0.7,
			transformOrigin:'50% 0%'
		})
	},
	onRelease:function(){
		TweenMax.to(zipHandle, 0.3, {
			scaleY:1,
			ease:Bounce.easeOut
		})		
	},
	throwProps:true,
	overshootTolerance:0, 
	onThrowUpdate:onDrag

})

function onDrag(e){
	
	TweenMax.set(zipToothMask, {
		y:this.y - zipToothMaskInitY
	})
	
	TweenMax.set(zipOpenMask, {
		y:(this.y - zipOpenMaskInitY) - zipOpenMaskHeight
	})

	percentOpen = (this.y - minDragY)/dragLength;
	
	zipOpenTimelineL.seek(percentOpen);
	zipOpenTimelineR.seek(percentOpen);


}

function createOpenZipTeeth(){
	var posYL, posYR;
	for(var i = 0; i < numZipTeeth; i++){
		
		var ztR = document.createElementNS(xmlns, 'use');
		ztR.setAttributeNS(xlinkns, "xlink:href", "#zipTooth");
		ztR.setAttributeNS(null, "x", 295.5);
		posYR = ((156) + (i*19.05));
		ztR.setAttributeNS(null, "y", posYR);
		ztR.setAttributeNS(null, "fill", '#000000');

		var ztL = document.createElementNS(xmlns, 'use');
		ztL.setAttributeNS(xlinkns, "xlink:href", "#zipTooth");
		ztL.setAttributeNS(null, "x", 288.5);
		posYL = ((165) + (i*19.05)) ;
		ztL.setAttributeNS(null, "y", posYL );
		ztL.setAttributeNS(null, "fill", '#000000');

		zipOpenToothGroup.appendChild(ztL);
		zipOpenToothGroup.appendChild(ztR);
		
		zipOpenTeethArrayL.push(ztL);
		zipOpenTeethArrayR.push(ztR);

	}	
	TweenMax.set(zipOpenTeethArrayL, {
		svgOrigin:'288.5 270'
		})	
	TweenMax.set(zipOpenTeethArrayR, {
		svgOrigin:'288.5 270'
		})
	
	TweenMax.set([zipOpenTeethArrayR[0], zipOpenTeethArrayL[0]],{
		alpha:0
	})
}

var zipOpenTimelineL = new TimelineMax({paused:true});
zipOpenTimelineL.staggerTo(zipOpenTeethArrayL, 5, {
	attr:{
		x:'-=450'
	},
	rotation:-123
}, 0.06);

var zipOpenTimelineR = new TimelineMax({paused:true});
zipOpenTimelineR.staggerTo(zipOpenTeethArrayR, 5, {
	attr:{
		x:'+=450'
	},
	rotation:123
}, 0.06, '-=5')



            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console