123

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.

            
              <!-- 
  PLEASE NOTE:
  YOU NEED GOOGLE CHROME TO PROPERLY VIEW THIS ANIMATION
-->

<!-- Elements -->
<div class="wrapper">  
  <div class="mouse"></div>
  <div class="random-elements">
    <div class="random one circle not-clicked"></div>
    <div class="random two circle not-clicked"></div>
    <div class="random three triangle not-clicked"></div>
    <div class="random four rectangle not-clicked"></div>
  </div>
  <span class="trigger not-clicked">Click!</span>
</div>
<!-- My details -->
<h1>bleeding effect</h1>
<div class="profile">
  <img src="https://scontent-cai1-1.xx.fbcdn.net/v/t1.0-9/7496_1137108913027953_8040503405200721033_n.jpg?oh=c1749cddd1845b0aa0ad9da397fa2294&oe=58111E00" alt="Profile Image" />
  <h3>Made by <a target="_blank" href="https://www.facebook.com/Eslam.nasser.yousef">Eslam nasser</a></h3>
  <p>
    Another cool <a target="_blank" href="https://codepen.io/eslam-nasser/pen/VexqvG">SVG!</a>
  </p>
</div>


<!-- SVG Filters -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  <defs>
    <!--   This is where the magic happens   -->
    <filter id="sticky">
     
      <!--    Apply 10px blur    -->
      <feGaussianBlur in="SourceGraphic" stdDeviation="12" result="blured" />
      <!--   Increase the contrast of the alpha channel 
              Read this https://goo.gl/P152Jd     -->
      <feColorMatrix in="blured" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 19 -9" result="weirdNumbers" />
      <!--    Adding the two effects,
              Fix some bugs with "atop" -->
      <feComposite in="SourceGraphic" in2="weirdNumbers" operator="atop"/>
    </filter>
  </defs>
</svg>



            
          
!
            
              // Some general stuff
@import 'https://fonts.googleapis.com/css?family=Poiret+One|Roboto+Condensed'
body, html
  cursor: none
  overflow: hidden
  background: 
    color: #34495e
    image: url('https://s10.postimg.org/jbhjp29qh/3_min.png')
  font-family: 'Poiret One', cursive

// Pen Details
h1
  text-align: center
  color: #FFF
  position: relative
  z-index: 3
  text-transform: uppercase
  font:
    weight: 100
    size: 60px
.profile
  position: absolute
  width: 30%
  bottom: 20px
  left: 50%
  margin-left: -15%
  z-index: 3
  img
    width: 20%
    border-radius: 100%
    float: left
    margin: auto 5%
  h3, p
    width: 70%
    float: left
    color: #FFF
    padding: 0
  h3
    margin-bottom: 0
    font:
      size: 22px
  p
    margin-top: 5px
  a
    color: #FFF
    

// Vars
$elements_color: #e74c3c
$elements_shadow:  none // Add shadow if you want 0px 2px 5px 0px rgba(0,0,0,0.16),0px 2px 5px 0px rgba(0,0,0,0.23)

// Must apply the svg filter to the parent
.wrapper 
  filter: url('#sticky') // The id of the filter
  position: absolute
  top: 0
  right: 0
  left: 0
  bottom: 0
  width: 100%
  height: 100%
  z-index: 3
  span.trigger
    position: absolute
    display: block
    width: 100px
    color: #FFF
    text-transform: uppercase
    top: 48%
    left: 50%
    margin-left: -50px
    text-align: center
    font-size: 25px

// Mouse
.mouse
  width: 60px
  height: 60px
  border-radius: 100%
  background: $elements_color
  box-shadow: $elements_shadow
  will-change: transform // Read this https://goo.gl/yYc589

  
.random
  width: 100px
  height: 100px
  margin: 100px
  background: $elements_color
  box-shadow: $elements_shadow
  position: absolute
  top: 50%
  left: 50%
  margin-left: -50px
  margin-top: -50px
  transition: 4s
  transform: translate3d(0,0,0)
  transform-origin: center center
  will-change: transform, transition // Read this https://goo.gl/yYc589


.random.circle
  border-radius: 100%
  
.random.triangle
  width: 0
  height: 0
  background: transparent
  border-left: 50px solid transparent
  border-right: 50px solid transparent
  border-bottom: 100px solid $elements_color
  box-shadow: none
  
  
  
  
  
  
  
  
  
  
  
  
  
            
          
!
            
              // Trace the mouse
// Some vars to start with
var mouse     = $('.mouse'),
    currentX  = 0, 
    currentY  = 0,
    newX      = 0, 
    newY      = 0;

// Get X and Y positions
$(window).mousemove(function(e){
   currentX = e.pageX; // Get the mouse X position
   currentY = e.pageY; // Get the mouse Y position
});
// Make the trace a little bit smooth
var fps = setInterval(function(){
      newX += (currentX - newX) / 5; // Create new X position
      newY += (currentY - newY) / 5; // Create new Y position
      mouse.css({
        'transform': 'translate3d('+(newX - 30)+'px, '+(newY - 30)+'px, 0)' // ALWAYS use transform property to get the best performance
      });
      // console.log('My current Y location is (' +newY+ ') and in X is ('+newX+')' )
  }, 16);// Refresh the positions each 16ms to get ~60fps




// Moving the elements randomly functions
// NOTE : THIS HAVE BAD PREFORMANCE DELETE IF YOU NEED 60fps

// Trigger the movement
$('.random.not-clicked, .trigger.not-clicked').click(function(){
  movingElements();
  $('.not-clicked').removeClass('not-clicked');
});
function makeNewPosition(){
    // All this vars to generate different values for each element
    var windowHeight  = ( $(window).height() - ( $(window).height() / 2 ) ),
        windowWidth   = ( $(window).width() - ( $(window).width() / 2 ) ),
        randomHeight1 = Math.floor(Math.random() * windowHeight),
        randomHeight2 = Math.floor(Math.random() * windowHeight),
        randomHeight3 = Math.floor(Math.random() * windowHeight),
        randomHeight4 = Math.floor(Math.random() * windowHeight),
        randomWidth1  = Math.floor(Math.random() * windowWidth),
        randomWidth2  = Math.floor(Math.random() * windowWidth),
        randomWidth3  = Math.floor(Math.random() * windowWidth),
        randomWidth4  = Math.floor(Math.random() * windowWidth);

  return [randomHeight1, randomHeight2, randomHeight3, randomHeight4, randomWidth1, randomWidth2, randomWidth3, randomWidth4];    
}

function movingElements(){
  var newq = makeNewPosition();
  $('.random.one').css({'transform': 'translate3d('+newq[4]+'px,-'+newq[0]+'px, 0)'});
  $('.random.two').css({'transform': 'translate3d(-'+newq[1]+'px,'+newq[5]+'px, 0)'});
  $('.random.three').css({'transform': 'translate3d('+newq[6]+'px,-'+newq[2]+'px, 0)'});
  $('.random.four').css({'transform': 'translate3d(-'+newq[3]+'px,'+newq[7]+'px, 0)'});
  setTimeout( function() {
    movingElements();
  }, 3000);
};


            
          
!
999px
🕑 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.

Console