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

              
                Example #1 - from down to up using vertical slice<br>
<div id="sliced1" class="sliced1 sliced">
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/56901/2d.jpg">
</div>

<br>
Example #2 - from right to left using horizontal slice<br>
<div id="sliced2" class="sliced2 sliced">
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/56901/2d.jpg">
</div>

<h4>Jonny Image Slice GSAP jQuery Plugin <br><span>(various combination of options: number of tiles in x or y axis, duration, stagger delay, and direction)</span></h4>
              
            
!

CSS

              
                /* apply a natural box layout model to all elements */
* {
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
}

body { 
  margin: 15px;
  font-family: "Raleway",sans-serif;
  font-size:14px;
}

h4 {
  font-size: 15px;
  margin-top:1.5em;
  text-transform: uppercase;
}

h4 > span{
  font-size: 12px;
  font-weight: normal;
  text-transform: lowercase;
}

/* required styles */
.sliced {
    position: relative;
    width: 670px;  /* required */
    height: 245px; /* required */
    overflow:hidden;
}

.sliced > img{
    visibility:hidden;
}

.tile {
    float: left;
    opacity: 1;
}
.tile-animated {
    visibility:hidden;
}
              
            
!

JS

              
                //////////////////////////////////////////////////////////
// USAGE - jonny sliced gsap jquery plugin
jQuery(function() { // on ready
  
  jQuery(window).bind("load", function(){ // on load

    // init sliced plugin
    
    // slice and animate image 1
    jQuery("#sliced1").sliced({
      x: 10, // number of tiles in x axis (pre row)
      y: 1, // number of tiles in y axis (per columns)
      duration: 0.4, // time length of animation
      staggerDelay: 0.1, // stagger length of each tile
      axis: "y", // x or y to animate
      direction: "down", // if axis x (left or right), if axis y (left or right)
      topMargin: 0, // to mimic metro grid 
      rightMargin: 0, // to mimic metro grid
      bottomMargin: 0, // to mimic metro grid
      leftMargin:0 // to mimic metro grid
    });
    
    // slice and animate image 2
    jQuery("#sliced2").sliced({
      x: 1, // number of tiles in x axis (pre row)
      y: 6, // number of tiles in y axis (per columns)
      duration: 0.6, // time length of animation
      staggerDelay: 0.2, // stagger length of each tile
      axis: "x", // x or y to animate
      direction: "right", // if axis x (left or right), if axis y (left or right)
      topMargin: 0, // to mimic metro grid
      rightMargin: 0, // to mimic metro grid
      bottomMargin: 0, // to mimic metro grid
      leftMargin:0 // to mimic metro grid
    });


    // trigger animation on load 
    // or trigger when you want with this snippet
     jQuery(".sliced").trigger("animate");

    
  }); // end window load
}); // end dom ready



              
            
!
999px

Console