Spinner Box was inspired by the PBB MagicWheel found here.
This script provides a graphically appealing way to display images and page links in the form of a 3d spinable icon wheel. Spinner box while visually similar to the MagicWheel is built using a completely different code style, one that provides several key differences from MagicWheel
and maintains my views on scripts and widgets. That being it should be small compact easy to use while giving advanced coders limitless flexibility.
The only code segment used from MagicWheel is the image reflection method which was modded and debugged.
Spinner box was built using the Mootools javascript framework as a base.
Features:
Minimal CSS and HTML: Spinner Box can be implemented simply, with only one html div element. For extra styling every element the script adds is accessible through CSS. While it is recommended to
create a CSS loading class it is not required for the widget to function. Styling classes and html structure can be viewed in the Documentation section of this page.
User Interaction:
Implementing mouse movement and mouse wheel tracking, the script provides a very smooth and polished interaction with the users mouse. Use the mouse wheel to spin the icon wheel,
or mouse over the widget for a smooth feel in accessing the icons.
Alternatively the scripts mouseSpin option can be disabled, when this is the case the widget can still be spun through the use of the mouse wheel.
Custom Events:
Built in custom events give coders full flexibility with how the widget displays and behaves. The events available can be viewed in the documentation section of this page.
A full description of the events can be found in the documentation.
Degrades Elegantly:
On browsers that have JavaScript disabled the widget is nothing more then a blank spot on the page. Future implementation of IPhone and Blackberry compatibility are in the works.
Stand-Alone Availability:
Although it is recommended to use spinnerBox in tandem with the Mootools JavaScript framework, this widget is also available in a larger standalone version which can co-exsist
on the same page as other frameworks such as Jquery, Dojo, or Prototype.
Spinner Box has been tested and functions in the following browsers:
Internet Explorer versions 6, 7, and 8
Fire Fox version 3.5.2
Safari
Google Chrome
Documentation:
Implements:
Events,Options
Syntax:
var mySpinner = new spinnerBox(spinBox, [options]);
Arguments:
spinBox - (mixed) A string ID of the Element containing the widget.
options - (options, optional) See below.
.
Options:
icons - (object) Icon information used to initialize the widget. Attribute Format - IconKey: [link, image path, tip]
wheelWidth - (number, defaults to 180) Pixel width of the icon wheel
wheelHeight - (number, defaults to 5) Height measurement of the icon wheel.
boxWidth - (number, defaults to "auto") The fixed height of the spinBox element.
boxHeight - (number, defaults to "auto") The fixed width of the spinBox element.
iconForegroundWidth - (number, defaults to 68) Max pixel width of foreground icons.
iconBackgroundWidth - (number, defaults to 30) Min pixel width of background icons.
Speed Options:
baseSpeed - (number, defaults to 1.5) Minimum speed of wheel rotation. 10 equals the full width of an icon every 50 MS. NOTE: 1 - 3 is recommended for optimal viewing.
maxSpeed - (number, defaults to 3) Maximum speed the wheel rotation is allowed to reach.
friction - (number, defaults to 4) Amount of slowing applied to the excess roation speed. Values range from 1 - 99. NOTE: 1 equals little to no slowing of excess speed, 99 allows for no excess speed.
Mouse Options:
enableMouseSpin - (boolean, defaults to True) Enables mouse position tracking and speed control.
mouseEffectiveness - (number, defaults to 30) How much effect the mouse excerts on the wheel's rotation speed. 100 equals very effective. 1 equals little to no effect. NOTE: Effects mouse wheel speed increases as well.
invertMouseSpinDirection - (boolean, defaults to True) Inverts the rotation direction from mouse spin.
CSS Class Options:
loadingClass - (string, defaults to "spinnerLoading") CSS class that is applied to the spinBox during icon loading phases.
iconClass - (string, defaults to "spinnerIcon") CSS class that is applied to the icons.
reflectionClass - (string, defaults to "spinnerRef") CSS class that is applied to the icon reflection element.
captionClass - (string, defaults to "spinnerCaption") CSS class that is applied to the caption element.
Graphic Options:
foregroundOpacity - (number, defaults to 1) Maximum opacity of the foreground icons.
backgroundOpacity - (number, defaults to 0.4) Minimum opacity of the background icons.
refOpacity - (number, defaults to 0.7) Icon reflection opacity.
gradReflection - (number, defaults to 0.5) Minimum opacity of the gradient applied to simulate icon reflection.
starterCaption - (string, defaults to "Spinner Box") The caption that is shown when no icon is being hovered over.
.
Events:
-- build --
Fired when all icon images are loaded and the widget is built.
Signature:
onBuild();
-- iconAdded --
Fired after addIcon is called.
Signature:
onAddIcon(icon)
Arguments:
icon - (Element) The anchor element containing the new icon.
-- iconRemoved --
Fired after removeIcon is called.
Signature:
onIconRemove(removedInfo)
Arguments:
removedInfo - (Array) Array containing information on the removed icon. Array format is: [key, link, image path, tip]
-- wheelSpin --
Fired when the mouse wheel is spun inside the spinBox.
Signature:
onWheelSpin(wheel)
Arguments:
wheel - (number) the wheel amount from the event.
-- iconEnter --
Fired when mouse enters an icon.
Signature:
onIconEnter(icon,link)
Arguments:
icon - (Element) The Anchor element containing the icon.
link - (string) The link of the icon.
-- iconLeave --
Fired when mouse leaves an icon.
Signature:
onIconLeave(icon)
Arguments:
icon - (Element) The Anchor element containing the icon.
-- iconClick --
Fired when icon is clicked.
Signature:
onIconClick(icon,link)
Arguments:
icon - (Element) The Anchor element containing the icon.
link - (string) The link of the icon.
.
Properties:
halted - (boolean) True if rotation animation is halted.
spinSpeed - (number) Current speed of the rotation.
extraSpeed - (number) Excess speed being applied to spinSpeed.
wheelSpeed - (number) Current speed being applied to spinSpeed from the mouse wheel.
mouseIn - (boolean) True if mouse is inside the spinBox.
.
User Methods:
addIcon (key, link, icon, tip, userIcon) - Adds an Icon to the spinner. Returns new icon element. Arguments:
key - (string) Variable name used to track icon.hash elements. NOTE: treat it as a variable name (no spaces or special characters). Icon id = key + "_icon"
link - (string) Href link that's applied to the icons anchor element.
icon - (string) Path to image used in the icon.
tip - (string) Caption shown when icon is moused over.
userIcon - (boolean, optional) True if class initialization did not call the method. NOTE: recommended user does not enter a value here.
removeIcon (key) - Removes an icon from spinner. Returns array with removed icons information in the following format: [key, link, image path, tip] Arguments:
key - (string) Variable name used locate icon to remove.
.
Structure:
Html:
<divid="spinBox"class="spinnerLoading"><aid="iconKey_icon"class="spinnerIcon"href="sampleLink.html"><imgsrc="sampleImage.jpg"></img><canvasclass="spinnerRef"></canvas></a><aid="iconKey_icon"class="spinnerIcon"href="sampleLink.html"><imgsrc="sampleImage.jpg"></img><divclass="spinnerRef"><imgsrc="sampleImage.jpg"></img></div></a><!-- Internet Explorer --><divclass="spinnerCaption"><div>Spinner Box Caption Text</div></div></div>
Available CSS classes for extreme styling:
spinnerLoading - applied to the spinBox element during loading phases. during these phases the icons are hidden. Can be changed through the options loadingClass.
spinnerCaption - applied to the caption div tag. this tag contains a div tag that holds the caption text. Can be changed through the options captionClass.
spinnerIcon - applied to the anchor element containing the icon image and reflection. Can be changed through the options iconClass.
spinnerRef - applied to the reflection canvas tag ( div tag containing an image for IE ). Can be changed through the options reflectionClass.
.
Example:
Html:
<divid="spinBox1"><noscript>Enable JavaScript to View this section</noscript></div>