Javascript Spotlight visual cue
Spotlight class provides a way to create a spotlight like visual cue to concentrate visitors attention to specific webpage elements or actions
Contents
Download
Example codes
var sp = new spotlight({
onAnimationStart: function(){alert("start");},
onAnimationEnd: function(){alert("end");}
});
sp.show(200, 200);
Examples in action
Method list
- Constructor
- Show spotlight
- Hide spotlight
- Animate spotlight
- Move spotlight
- Resize spotlight
- Blur spotlight
- Color of background
- Change spotlight
- Set animation speed
Constructor
| Method name | new spotlight(id, config); |
| Description | Create a spotlight instance |
| Input parameters |
json config - Json structure with configuration properties
|
| Example input |
var sp = new spotlight({
bgColor: "rgba(0,0,0,0.9)",
lightStart: 0,
lightEnd: 0.2,
size: 100,
blurRadius: 20,
interval: 10,
steps: 50,
zIndex: 100,
onAnimationStart: function(){alert("start");},
onAnimationEnd: function(){alert("end");}
}); |
Show spotlight
| Method name | show(x,y) |
| Description | Show spotlight at specified position |
| Input parameters | int x - x coordinate in pixels int y - y coordinate in pixels |
| Example | sp.show(100,100) |
Hide spotlight
| Method name | hide() |
| Description | Hide spotlight |
| Example | sp.hide() |
Animate spotlight
| Method name | animate(x, y, r, blur, steps) |
| Description | Animate spotlight with different parameters and animation steps |
| Input parameters | int x - new x coordinate in pixels int y - new y coordinate in pixels int r - new radius of spotlight in pixels int blur - new radius of blur around spotlight in pixels int steps - steps of animations to perform |
| Example | sp.animate(200, 200, 100, 50, 20) |
Move spotlight
| Method name | move(x,y) |
| Description | Animates moving of spotlight (shorthand from animation) |
| Input parameters | int x - new x coordinate in pixels int y - new y coordinate in pixels |
| Example | sp.move(200,200) |
Resize spotlight
| Method name | resize(radius) |
| Description | Animates resizing of spotlight (shorthand from animation) |
| Input parameters | int radius - new radius of spotlight in pixels |
| Example | sp.resize(200) |
Blur spotlight
| Method name | blur(radius) |
| Description | Animates resizing of blur around spotlight (shorthand from animation) |
| Input parameters | int radius - new radius of spotlight blur in pixels |
| Example | sp.blur(50) |
Color of background
| Method name | changeBgColor(color) |
| Description | Change color of bakground |
| Input parameters | string color - color of background |
| Example | sp.changeBgColor("rgba(255,255,0,0.5)") |
Change spotlight
| Method name | changeSpot(start,end) |
| Description | Change opacity of spotlight. Spotlight is created using radial gradient and you can setp start opacity and end opacity of this gradient |
| Input parameters | float start - start opacity of radial gradient float end - end opacity of radial gradient |
| Example | sp.changeSpot(0,1) |
Set animation speed
| Method name | animationSpeed(steps, interval) |
| Description | Set amount of animation steps and interval to be used in animations |
| Input parameters | int steps - in how many steps to finish animation int interval - amount of time between animation steps |
| Example | sp.animationSpeed(20, 10) |
Latest changes
None for nowYou may also be interested in:
Powered by BlogAlike.com










