GithubHelp home page GithubHelp logo

popobe97 / gpickr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simonwep/gpickr

0.0 0.0 0.0 219 KB

Fork from Simonwep/gpickr

Home Page: https://simonwep.github.io/gpickr

License: MIT License

HTML 2.73% JavaScript 72.00% CSS 4.09% SCSS 21.18%

gpickr's Introduction

This is a demo of how pickr could be implemented / integrated in other scenarios.

Usage

const gpickr = new GPickr({
    el: '.gradient-pickr',
    
    // Pre-defined stops. These are the default since at least two should be defined
    stops: [
        ['rgb(255,132,109)', 0],
        ['rgb(255,136,230)', 1]
    ]
})

GPickr Instance / static props

  • gpickr.Pickr - Pickr.
  • gpickr.addStop(color:String, loc:Number) - Add a color-stop.
  • gpickr.removeStop(v:String|Number|Stop) - Remove a color stop by color, location or stop-instance.
  • gpickr.getGradient() - Returns the current gradient as css string.
  • gpickr.getStops() - Array of stop objects with each a location between 0 and 1 as well as an rgba color value. The toString function is overridden and returns the array ready-to-use as comma seperated list, useful if a custom direcation / angle want to be used.
  • gpickr.getLinearAngle() - Returns the current selected angle. -1 if currently in radial-mode
  • gpickr.setLinearAngle(angle:Number) - Applies a new angle to the current linear gradient.
  • gpickr.getRadialPosition() - Returns the current chosen direction. null if currently in linear-mode
  • gpickr.setRadialPosition(position:String) - Sets a new position for the current radial-gradient.
  • gpickr.on(event:String, cb:Function) - Appends an event listener to the given corresponding event-name (see section Events), returns the gpickr instance so it can be chained.
  • gpickr.off(event:String, cb:Function) - Removes an event listener from the given corresponding event-name (see section Events), returns the gpickr instance so it can be chained.

Events

Event Description
init Initialization done - gpickr can be used
change User changed the gradient

Example:

gpickr.on('init', instance => {
    console.log('init', instance);
}).on('change', instance => {
    console.log('change', instance.getGradient());
});

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.