Giter VIP home page Giter VIP logo

real-shadow's Introduction

Real Shadow โ€” Module that casts photorealistic shadows of any shape

Perfect for eye-catching demos and landing pages.
Works in any browser supporting CSS box-shadow property.

Real Shadow registers itself as CommonJS module, AMD module or jQuery plugin (it depends on your environment).
If there is no CommonJS, AMD or jQuery, Real Shadow registers itself in the global namespace.

What's new

Installing

GitHub

https://github.com/Indamix/real-shadow

npm

npm i real-shadow

bower

bower i real-shadow

Basic Usage with jQuery

$(selector).realshadow(); // options are optional

$(selector).realshadow({

	followMouse: false,   // default: true

	pageX: x,             // x coordinate of the light source
	pageY: y              // y coordinate of the light source

	color: '0,127,255'    // shadow color, rgb 0..255, default: '0,0,0'

	type: 'drop' / 'text' // shadow type

});

Basic Usage without jQuery

realshadow(elements); // options are optional

realshadow(elements, options); // options example listed above

To specify different colors for each element, you can use "data-shadow-color" attribute:

<span data-shadow-color="r,g,b"></span> <!-- values in range 0..255 -->

<span data-shadow-color="255,0,0">red</span>
<span data-shadow-color="0,255,0">green</span>
<span data-shadow-color="0,0,255">blue</span>
<span data-shadow-color="255,255,0">yellow</span>
<span data-shadow-color="0,255,255">cyan</span>
<span data-shadow-color="255,0,255">violet</span>
<span data-shadow-color="100,100,100">grey</span>
$('span').realshadow();

Inset Shadows

$(selector).realshadow({
	inset: true // default: false
});

Inverse Shadows

$(selector).realshadow({
	inverse: true // default: false
});

Custom Shadow Shape

$(selector).realshadow({
	type: 'drop'
});

Text Shadow

$(selector).realshadow({
	type: 'text'
});

Constant Angle

If you would like the shadows angle to be constant, specify the 'angle' option, in radians.

$(selector).realshadow({
    angle: Math.PI / 4
});

Update shadows during/after jQuery animations

// before: apply Real Shadow to elements:
$(selector).realshadow(/* options, if needed */);

// update shadows during jQuery animation, i.e. each animation step:
$(selector).animate(/* animated properties */, {step: $.fn.realshadow.update});

// update shadows after jQuery animation is over:
$(selector).animate(/* animated properties */, $.fn.realshadow.update);

If you update shadows during jQuery animation, you don't need to update shadows after jQuery animation is over.

Custom shadows length

$(selector).realshadow({
	length: 5 // default is 7
});

CommonJS usage

var realshadow = require('realshadow');

realshadow(document.getElementsByClassName('someClass'));
realshadow(document.getElementsByTagName('li'), options);

RequireJS / AMD usage

require(['realshadow'], function(realshadow) {

	realshadow(document.getElementsByClassName('someClass'));
	realshadow(document.getElementsByTagName('li'), options);

});

Reset Real Shadow

Real Shadow will release all added elements and remove all its event listeners

// if you have Real Shadow in the current scope:
realshadow.reset();

// if you use jQuery:
$.fn.realshadow.reset();

If you suppose that the usage of Real Shadow is unclear or have something to say, feel free to contact me.

real-shadow's People

Contributors

indamix avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

real-shadow's Issues

Length setting not working...

It seems like the length setting is not working. I'm assuming it changes the length of the shadow, but I'm not seeing any results output when I try to adjust it.

bug in example.html

shadows($('button, .container, .text'), { ...

change to the realshadow( ... )

Inverse direction

Hello,

I don't know if the script is still maintained...
Anyway, is there a solution to inverse the shadow direction, in order to attract the shadow when the mouse moves?

Thank you in advance,
jB

Touch support

Any chance of touch support on iPad, iPhone, Android? Runs very nicely on desktops.

shadows do not update when moved via JQuery

I'm on the newest update of Chromium on Ubuntu and it doesn't look like my shadows move when I update via JQuery with followMouse set to false. Is this because there's no correct way to handle such a thing?

This is all I've done so far:
http://dropcanvas.com/ewe8w (real-shadow and jquery script calls will need to be relinked)

edit: in fact, when followmouse is set to true and I move the box, it still acts as if it's in the same place

Transforms

When using CSS transforms for example: when you rotate an element shadows are calculated wrong

Changing shadow size

Hi, i'm trying to use your real-shadow code. But need the shadow to be like half the size... I tried to change some value but don't find how to do that...
I thought i just had to change the light distance... But doesn't work :(

Can you help me? Thanks a lot!

project demo page does not display properly in Chrome

project page http://indamix.github.com/real-shadow/ is not working, as newest Google Chrome refuses to run javascrip served as text/plain (and raw.github.com is doing exactly this).

Chrome console error:

Refused to execute script from 'https://raw.github.com/Indamix/real-shadow/master/realshadow.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled. indamix.github.io/:1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.