real-shadow

Module that casts photorealistic shadows

Github星跟蹤圖

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.

主要指標

概覽
名稱與所有者Indamix/real-shadow
主編程語言JavaScript
編程語言JavaScript (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2012-04-19 12:16:04
推送於2016-11-20 16:09:33
最后一次提交2016-11-20 17:05:09
發布數10
最新版本名稱v1.4.1 (發布於 )
第一版名稱v1.1.0 (發布於 )
用户参与
星數1.1k
關注者數39
派生數121
提交數64
已啟用問題?
問題數15
打開的問題數4
拉請求數2
打開的拉請求數0
關閉的拉請求數3
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?