The Official Blog of Patcoola

Im just a dude watching over my parents,
and trying to make cartoons and video games from home.

Script: Tween Width To [JS Class]

, By Patcoola

Script Title: tweenWidthTo
Programming Language: Java Script
Date Completed: 2013/04/07

Purpose: To animate the changing width of an HTML Element.

Advertisement

Donate Now!

I don't always use the women's bathroom, but when I do, you can bet it really smells. If you like my blog, please consider donating.


Description: Changes the width of an HTML Element by animating the width change. Note: method will not start if the targetId or targetSize is not set or the input is not valid.

Methods:

var class = new tweenWidthTo();

class.targetId

Set to select a HTML Element by ID to be sized. *Required

class.targetSize

Set the amount of the new height measured in pixels. Takes a number value. *Required

class.pixelRate

Set the amount of pixels to change the size of the element each interval. Takes a positive or negative number. Determines whether to make larger or smaller. Default value 5.

class.intervals

Set the interval rate measured in milliseconds. Default value 16.

class.start()

Function to start the resizing animation.

class.stop()

Function to stop the resizing animation, sets the element size to the target size.

class.pause()

Function to pause the resizing animation.

class.isActive()

Function to determine if the resizing animation is active. Returns true or false.

Example Usage:

var sizeBox1 = new tweenWidthTo();

sizeBox1.targetId = “box”;
sizeBox1.targetSize = 60;
sizeBox1.pixelRate = -5;
sizeBox1.intervals = 8;
sizeBox1.start();

This example decreases the size of element ID box to the size of 60 by 5 pixels every 8 milliseconds (125 frames per second)

 

Advertisement

Donate Now!

Hey buddy, it takes a lot to make a blog. How about a donation?


 

Post Meta

Share Post

 

Comments: Write Comment

Be the first to write a comment.


Leave a Comment


All comments are reviewed before publishing. Comments must be related to the page topic, must not be spam, and must comply with the criminal code of Canada.