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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 class="container">
<svg version="1.1"
	 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
	 x="0px" y="0px" viewBox="0 0 600 600" enable-background="new 0 0 600 600" xml:space="preserve">
<defs>
<path id="titlePath" fill="none" stroke="#FF0049" stroke-miterlimit="10" d="M284,346.5c-14.6,0-26.5-11.9-26.5-26.5
		c0-14.6,11.9-26.5,26.5-26.5s26.5,11.9,26.5,26.5C310.5,334.6,298.6,346.5,284,346.5z"/>
</defs>

<g id="vinylGroup">
	<circle id="vinylMain" fill="#2A2525" cx="284" cy="320" r="121"/>

<circle id="vinylStart" fill="#262121" cx="284" cy="320" r="117"/>
<circle id="vinylEnd" fill="#2A2525" cx="284" cy="320" r="50"/>
	<circle id="vinylLabel" fill="#F27469" cx="284" cy="320" r="40.8"/>
	<circle id="vinylInner" fill="#B32A38" cx="284" cy="320" r="17"/>
	<circle id="vinylHole" fill="#eff2e1" cx="284" cy="320" r="2.5"/>


</g>
	<g id="vinylShineGroup"  stroke="#403737" stroke-linecap="round" stroke-linejoin="round">
<circle id="vinylShine1" opacity="0.3" fill="none" cx="284" cy="320" r="103"/>
	<circle id="vinylShine2" opacity="0.3"  fill="none" cx="284" cy="320" r="91"/>
	<circle id="vinylShine3" opacity="0.3"  fill="none" cx="284" cy="320" r="60"/>    
<g id="titleGroup" stroke="none" opacity="1">
<text>
  <textPath xlink:href="#titlePath">Arthur - Wind Therapy </textPath>
  </text>   
  </g>    
</g>

<g id="armGroup">
	<path id="arm" fill="none" stroke="#9F978D" stroke-width="5" stroke-linecap="round" stroke-miterlimit="10" d="M398.5,159v29c0,0-5.7,11.2-6.4,15.2
		s-4.3,16.2,7.6,30.1s81.7,93.9,85.5,99.4c3.7,5.5,5.1,8.7,3.4,20.2"/>
	<circle id="balance" fill="#CCCBCB" cx="396.5" cy="188" r="19"/>
	<path id="stylus" fill="#18110E" d="M489.9,367.5l-11.5-1.1c-2.2-0.2-3.8-2.2-3.6-4.4l1.5-15.9c0.2-2.2,2.2-3.8,4.4-3.6
		l11.5,1.1c2.2,0.2,3.8,2.2,3.6,4.4l-1.5,15.9C494,366.1,492.1,367.7,489.9,367.5z"/>
</g>

 
<g id="circleDragger" opacity="0">  
  <circle cx="396.5" cy="188" r="190" fill="rgba(89,89,89,0.2)" stroke="red"/>
  <rect id="dragger" x="472" y="338" fill="#EF2572" width="26" height="36" opacity="1"/>   
</g>
  <text id="info" x="50%" y="150">Version 1.1 is <a xlink:href="https://codepen.io/chrisgannon/pen/GpwqgG" target="_new">here</a></text> 
</svg>

  
</div>

              
            
!

CSS

              
                body {
  background-color:#FFF6E7;
  overflow: hidden;
  font-family:Arial, sans-serif;
}

body,
html {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}
.container{
  position:absolute;
  width:900px;

}

svg{

  width:100%;
  visibility:hidden;
 
}
#titleGroup text{
  font-size:5px;
  
  fill:#ededed;
  letter-spacing:2.25px;
  text-rendering: optimizeSpeed;
}

#info{
  font-size:10px;
  fill:#9F978D;
  text-anchor:middle;

}
#info a{
  font-size:10px;
  fill:#9F978D;
  text-anchor:middle;
  font-weight:700;
}
#dragger{
  cursor:move;
}
              
            
!

JS

              
                var xmlns = "http://www.w3.org/2000/svg",
  select = function(s) {
    return document.querySelector(s);
  },
  selectAll = function(s) {
    return document.querySelectorAll(s);
  },
  container = select('.container'),
  imageContainer = select('#image-container'),
  circleDragger = select('#circleDragger'),
    scPlayer,
    vinylStartRotation = 31,
    vinylEndRotation = 53,
    vinylRotationScale = (vinylEndRotation - vinylStartRotation),
    trackDuration


//center the container cos it's pretty an' that
TweenMax.set(container, {
  position: 'absolute',
  top: '50%',
  left: '50%',
  xPercent: -50,
  yPercent: -50
})
TweenMax.set('svg', {
  visibility:'visible'
})

SC.initialize({
    client_id: '516b790a82b7c6d89856376fa4ced361',
    redirect_uri: 'https://storymore.com/soundcloud'
  });


 createTrack()


TweenMax.set(['#vinylShine1', '#vinylShine2', '#vinylShine3'], {
  drawSVG:'30% 30%'
})
TweenMax.set('#armGroup',  {
  //rotation:33,
  svgOrigin:'396.5 188'
})

TweenMax.set([ circleDragger], {
  svgOrigin:'396.5 188'
})

TweenMax.set('#vinylShineGroup', {
  //svgOrigin:'284 320'
  transformOrigin:'50% 50%'
})

var tl = new TimelineMax();
tl.fromTo('#arm', 1, {
  drawSVG:'0% 0%'
}, {
  drawSVG:'0% 13%',
  ease:Power1.easeOut
})
.from('#balance', 1, {
  attr:{
    r:0
  },
  ease:Anticipate.easeIn
},'-=1')
.to('#arm', 2, {
  drawSVG:'0% 100%',
  ease:Power4.easeInOut
},'-=0.5')
.from('#stylus', 1, {
  scale:0,
  transformOrigin:'75% 15%',
  ease:Power2.easeInOut
},'-=0.9')
.staggerFrom('#vinylGroup circle', 2, {
  //x:'-=100',
  attr:{
    r:0
  },
  ease:Elastic.easeOut.config(1, 0.82)
},0.46,'-=0.6')
.from('#titleGroup', 0.5, {
  scale:0.8,
  alpha:0,
  //rotation:-45,
  transformOrigin:'50% 50%'//,
  //ease:Elastic.easeOut.config(1, 0.82)
},'-=2.6')

tl.timeScale(1.2);

var vinylShineTl = new TimelineMax({paused:true});
vinylShineTl.to(['#vinylShine1', '#vinylShine2', '#vinylShine3'], 1.4, {
  drawSVG:'65% 78%',
  ease:Linear.easeNone
})
.to(['#vinylShineGroup'], 3.3, {
  rotation:'+=360',
  repeat:-1,
  yoyo:false,
  transformOrigin:'50% 50%',
  ease:Linear.easeNone
},'-=1.4');


stylusDragger = Draggable.create(circleDragger,{
  type:'rotation',
  trigger:'#dragger',
  cursor:'pointer',
  bounds:{min:0,max:vinylStartRotation},
  onDrag:onDrag,
  onRelease:onDragEnd,
  onPress:onPress
})

function onDrag(e){
  
  TweenMax.set('#armGroup', {
    rotation:circleDragger._gsTransform.rotation
  })
}

function onPress(){
  
  scPlayer.pause();
  setSylusHold();
}


function onDragEnd(e){
  
  //return stylus to off position
  if(circleDragger._gsTransform.rotation < vinylStartRotation){
    
    TweenMax.to(['#armGroup'], 0.3,{
      rotation:0,
      ease:Back.easeOut.config(0.6)
    })       
    TweenMax.set(circleDragger,{
      rotation:0
    })   
    
    stopVinyl(); 
    
    scPlayer.pause();
    
    setSylusDropped();
    
    return;
    
  }
  
  
  if(scPlayer.currentTime() > 0){
    var headDragPercent = ((circleDragger._gsTransform.rotation - vinylStartRotation)/vinylRotationScale);
    
    //console.log("headDragPercent: " + (headDragPercent * trackDuration) );
    scPlayer.play();
    scPlayer.seek(headDragPercent * trackDuration);
    playVinyl();
    setSylusDropped();
  
    return;
    
  }
  //console.log(circleDragger._gsTransform.rotation)
  //put the needle on the reckid  
  if(circleDragger._gsTransform.rotation >= vinylStartRotation){
  
    scPlayer.play();
    
    TweenMax.to('#armGroup', 0.3,{
      rotation:vinylStartRotation,
      ease:Back.easeOut.config(0.6)
    })
 
    TweenMax.set(circleDragger, {
      rotation:vinylStartRotation
    })   
    
    playVinyl();
    
    setSylusDropped();
    
  } 
    stylusDragger[0].vars.bounds.max = vinylEndRotation;
    stylusDragger[0].applyBounds();    
 
}

function setSylusDropped(){
  
    TweenMax.to('#armGroup', 0.2,{
      scaleY:1,
      ease:Back.easeOut.config(2)
    })   
}

function setSylusHold(){
  
    TweenMax.to('#armGroup', 0.2,{
      scaleY:0.98,
      ease:Back.easeOut.config(0.3)
    })   
}

function playVinyl(){
  //console.log(playTrackTl.duration())
  //
  //console.log(vinylShineTl.paused())
  if(vinylShineTl.paused()){
    vinylShineTl.resume();
    
    
  } else {
    
  }
  

}


function stopVinyl(){
  
  vinylShineTl.pause();
  TweenMax.to(['#vinylShine1', '#vinylShine2', '#vinylShine3'], 1, {
    drawSVG:'100% 100%',
    ease:Linear.easeNone,
    onComplete:function(){
      //vinylShineTl.pause(0);
      TweenMax.set(['#vinylShine1', '#vinylShine2', '#vinylShine3'], {
      drawSVG:'30% 30%'
      })
    }
})
  TweenMax.to(['#vinylShineGroup'], 3.3, {
    rotation:'+=90',
    ease:Power1.easeOut
  })  
}

function endTrack(e){
  //alert('endTrack')
  TweenMax.to([circleDragger, '#armGroup'], 2, {
    rotation:0,
    ease:Back.easeOut.config(0.3)
  })
  
  stopVinyl();

}

function updateDragger(){
  //console.log(scPlayer.currentTime())
  //console.log(scPlayer.currentTime()/trackDuration)
  var trackTimePercent = scPlayer.currentTime()/trackDuration;
  TweenMax.to([circleDragger, '#armGroup'], 0.1, {
    rotation:vinylStartRotation + ((trackTimePercent * vinylRotationScale)),
    ease:Linear.easeNone
  })
}

function createTrack(tracks){
  streamTrack();
  
}

function streamTrack(){
  
  SC.stream('/tracks/271746620').then(function(player){
    //player.play();
if (player.options.protocols[0] === 'rtmp') {
        player.options.protocols.splice(0, 1);
    }       
    scPlayer = player;  

    trackDuration = scPlayer.options.duration;
    player.on('time', function (){
      updateDragger();

    })
      player.on('finish', function (){
        endTrack()
    })

  });  
}


//ScrubGSAPTimeline(tl)
              
            
!
999px

Console