• Stars
    star
    2,807
  • Rank 16,217 (Top 0.4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🌟 Shiny reflections for mobile websites

Shiny, Simulating Reflections for Mobile Websites

Add shiny reflections to text, backgrounds, and borders on devices that support the DeviceMotion event.

License: MIT Still in beta Less than 1kB

⚠️ It looks like iOS 12.2 will disable use of device sensors on Safari, so development of Shiny.js is on hold for now

Demo

Use a mobile device, preferably iPhone in portrait mode at the moment

Todo

  • Fix landscape orientation rendering
  • Test on Android (waiting for test device to arrive)
  • Add option to pass custom handler

Installation

Install from npm:

npm install @rikschennink/shiny --save

Or download dist/shiny.umd.js and include the script on your page like shown below.

API

There's currently only one API call to make and it's shiny(). You can either pass a selector or an element (or array of elements), the second argument can be a configuration object telling Shiny how to render the special effects.

If the second argument is not supplied Shiny will render a radial background gradient with a white center and a transparent outer ring.

// No config supplied, select element by class
shiny('.my-shiny-element');

// Select multiple elements
shiny('.my-shiny-element, #my-other-shiny-element');

// Configuration object, see below for details
shiny('.my-shiny-element', { /* config here */ });

// Pass element object
const myElement = document.querySelector('my-shiny-element');
shiny(myElement, { /* config here */ });

// Pass array of elements
shiny([myElement, myOtherElement], { /* config here */ });

Usage

<!-- The element you want to make shiny -->
<div class="my-shiny-element">Hello World</div>

<!-- Include the library -->
<script src="shiny.umd.js"></script>

<!-- Initialize the SHINYNESS -->
<script>
shiny('.my-shiny-element', {
    // type of shiny to render, 
    // 'background', 'border', or 'text'
    type: 'background',
    gradient: {

        // type of gradient
        // 'linear' or 'radial'
        type: 'radial',

        // angle of gradient when type is linear
        angle: '110deg',

        // flip axis movement
        flip: {
            x: true,
            y: false
        },

        // colors to use
        colors: [
            // offset, color, opacity
            // ! don't pass rgba or hsla colors, supply the opacity seperately
            [0, '#fff', 1], // white at 0%
            [1, '#fff', 0], // to fully transparent white at 100%
        ]

    },

    // optional pattern fill
    pattern: {
        type: 'noise', // only 'noise' for now
        opacity: .5
    }
});
</script>

More Repositories

1

fitty

✨ Makes text fit perfectly
JavaScript
3,615
star
2

conditioner

πŸ’†πŸ» Frizz free, context-aware, JavaScript modules
JavaScript
1,068
star
3

short-and-sweet

πŸ“Ÿ Accessible character counter for input elements
JavaScript
277
star
4

tilt

πŸ‚ Simulates touch feedback on HTML elements
CSS
42
star
5

eve-of-impact

πŸŒβ˜„οΈ Eve of Impact iOS game source code
Objective-C
33
star
6

scrollscreen

🌁 Custom styled vertical scrollbars
JavaScript
12
star
7

smashing-magazine-lazy-loading-javascript-with-conditioner

πŸ‘©πŸ»β€πŸ’» Example code for Smashing Magazine article on Conditioner
HTML
8
star
8

react-contextual-router

πŸ“±Render components based on user context
JavaScript
7
star
9

cordova-tabbar

Native iOS TabBar for Cordova
Objective-C
4
star
10

conditioner-boilerplate-amd

An AMD based boilerplate for Conditioner based on RequireJS.
JavaScript
3
star
11

rikschennink.nl

Personal website
HTML
3
star
12

conditioner-boilerplate-webpack

A webpack boilerplate for Conditioner.
JavaScript
3
star
13

quick-fox

Quick Character Visualizer for Web Safe Fonts
3
star
14

prompt-reader

Reddit WritingPrompts Reader
2
star
15

sunsets

A collection of 15 moody sunsets (2560 x 1920)
2
star
16

aria-autopilot

πŸ€– Declarative accessibility control
2
star
17

conditioner-boilerplate-esm

An ES Module based boilerplate for Conditioner
HTML
2
star
18

cordova-networkactivity

Toggle network activity indicator on iOS
Objective-C
2
star
19

highlightjs-themes

Themes for HighlightJS
CSS
2
star
20

conditioner-boilerplate-global

A global scope based boilerplate for Conditioner.
JavaScript
1
star
21

ds-character-count

An accessible character count prototype
JavaScript
1
star
22

poost

Boost form posts
JavaScript
1
star
23

webspockify

NodeJS WebSocket Server to Control Spotify
JavaScript
1
star
24

wally

Subway map of New York traced in Affinity Designer
1
star
25

eve-of-impact-www

Website for Eve of Impact
HTML
1
star
26

cordova-loadingindicator

Cordova iOS loading indicator plugin
Objective-C
1
star
27

gulpin-sass-to-css

Related to article Gulpin SASS to CSS
JavaScript
1
star
28

simulate

simple particle simulator
JavaScript
1
star
29

conditioner-bower

Bower Endpoint for ConditionerJS
1
star
30

hva-css-minor

HTML
1
star
31

conditioner-boilerplate-browserify

A Browserify boilerplate for Conditioner.
JavaScript
1
star