“Progressive Draw - SVG” Documentation by “DXC” v1.0


Progressive Draw - SVG

By: DXC (Lance Snider)
Email

Thanks so much for purchasing my item! If you have any questions, please feel free to email via my user page contact form here.




Please note that to test this locally, you need a server. I like WAMP (for Windows) and MAMP (for Mac).

Tips for Preparing Your SVG Image In Illustrator

Modern browsers and Adobe Illustrator do a great job of handling SVG's, but there are still some tricks you need to follow to make sure your image works properly in Progressive Draw - SVG.


Setting Up Your HTML

  1. Open the HTML file where you'd like to put the .svg image and add the following code to the <head>:
    <link rel="stylesheet" type="text/css" href="css/lines.css">
    <script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>
    <script src="dist/snap.svg-min.js" type="text/javascript"></script>
    <script src="js/snapLines.js" type="text/javascript"></script>
    					
  2. If you want your animations to start when you scroll to them, add this just under the previous code that you added:
    <script src="js/noframework.waypoints.min.js"></script>
    					
  3. Add the following code in the <body> (the div is optional)
    <div class="svgHolder">
    	<svg class="dxcLines yourArtwork" width="100%" viewBox="0 0 590 590"></svg>
    </div>
    					
  4. Change where it says "yourArtwork" to whatever you named your .svg file. For example, if your artwork was named fish.svg, your code would look like this:
    <div class="svgHolder">
    	<svg class="dxcLines fish" width="100%" viewBox="0 0 590 590"></svg>
    </div>
    
  5. Where it says "590 590", you need to change that to the dimensions of your artwork in Illustrator (not the size you want it on the page). If you don't know what this is, open your artwork in Illustrator, click the Artboards button,

    then look where it says "W:" and "H:" in the top, right corner.

    If your artwork in Illustrator is 900px wide by 340px tall, your code would look like this:
    <div class="svgHolder">
    	<svg class="dxcLines fish" width="100%" viewBox="0 0 900 340"></svg>
    </div>
    

Modifying Animation Parameters (Optional)

It's easy to add parameters so you can better control your animation.
  1. Open your .html file.
  2. In between your <svg> tags, add parameters like this:
    <div class="svgHolder">
    	<svg class="dxcLines fish" width="100%" viewBox="0 0 900 340">
    		<param 
    			animationtime="0.6" 
    			drawFillsOnComplete="false" 
    			animateFillTime=".1"
    			defaultStroke="#fff"
    			progressiveDrawing="true"
    			delayBetweenSVGs="2"
    			animateOnPageLoad="true"
    			animateOnScroll="true"
    			useMenu="true"
    		 ></param>
    	</svg>
    </div>
    
    Here's what each of these does:
    • animationtime - Default: 1
      Larger numbers make the animation go faster
    • progressiveDrawing - Default: true
      When set to false, all objects draw at the same time. When set to true, they wait for the last one to finish.
    • delayBetweenSVGs - Default: .5 seconds
      If you have multiple .svg's on the page, it will wait between each one.
    • drawFillsOnComplete - Default: true
      Wait for all the strokes before the fills fade in. When set to false, the fills animate in as soon as the assosiated stroke is done drawing.
    • animateFillTime - Default: 1 second
      The time it takes for the fills to animate in
    • animateOnPageLoad - Default: true
      When set to false, nothing will happen unless the user clicks play.
    • defaultStroke - Default: #000000
      If a fill doesn't have a stroke, it will be given one temporarily so that it's outline can be drawn. This is the stroke color.
    • animateOnScroll - default: false
      Instead of auto-playing or having to click the play button, the animation starts as soon as it's visible on the screen.
    • useMenu - default: true
      Determines whether there's a play/pause button on hover.

Adding external controls

You may want to control your animation from outside Progressive Draw - SVG. Doing so is simple. For example, let's look at how you'd create a custom play button. Here's the play function.
PlaySVGs([0])
This will play the first animation on your page. Let's say you had several animations on your page and you wanted to play the first and third, you'd just add another index into the array:
PlaySVGs([0, 2]);
If you wanted to put this function on a button, this is what it would look like:
<button onclick="PlaySVGs([0, 2])">Play First and Third</button>
Here are all of the functions:

Upload Your Files

  1. Log into your hosting space via FTP software (I recommend Transmit).
  2. Upload the files to your server.

Once again, thank you so much for purchasing this item. As I said at the beginning, I'd be glad to help you if you have any questions relating to this theme. I'll do my best to assist. If you have a more general question relating to the items on CodeCanyon, you might consider visiting the forums and asking your question in the "Item Discussion" section.

Lance Snider