GithubHelp home page GithubHelp logo

nifragos / phaseslider Goto Github PK

View Code? Open in Web Editor NEW

This project forked from netgfx/phaseslider

0.0 1.0 0.0 483 KB

A slider UI component for Phaser.io Javascript library

License: MIT License

JavaScript 100.00%

phaseslider's Introduction

PhaseSlider

A slider UI component for Phaser.io Javascript library

Initialize the slider in your preload function

slider = new phaseSlider(game); //make sure to have slider publicly available

And then simply construct your slider in the main function of your game or anywhere else

slider.createSlider({
    customSliderBG: false,
    mode: "horizontal",
    sliderBGAlpha: 0.8,
    width: 500,
    height: 400,
    x: game.width / 2 - 500 / 2,
    y: game.height / 2 - 400 / 2,
    objects:[block1, block2, block3, block4, block5]
  });

View examples: Advanced example | Simple example


General Options:

  • mode: Type of movement for the slides (default horizontal, vertical-from-bottom, vertical-from-top)
  • width: The width of the slider (default 500 pixels)
  • height: The height of the slider (default 400 pixels)
  • x The x position of the slider (default 0)
  • y The y position of the slider (default 0)
  • objects An array of sprites or groups that will be the slides (added as they appear on the array left->right)
  • animationDuration: This sets the speed of the animation while sliding (default: 600ms)
  • animationEasing: The easing applied to the sliding animation (default Phaser.Easing.Cubic.Out)
  • sliderBG A single color to paint the background of the slider (default #35d2e0)
  • customSliderBG A cache value to serve as a background for the slider (default false)
  • sliderBGAlpha The alpha value for the slider background (default 1)
  • customHandleNext A cache value for the the right arrow (if omited the liv has a build-in image to place)
  • customHandlePrev A cache value for the the left arrow (if omited the liv has a build-in image to place)
  • showHandles Whether or not to show arrows for slider navigation (default true)
  • onNextCallback A callback function to be called when the slider navigates forward (default false)
  • onPrevCallback A callback function to be called when the slider navigates backwards (default false)
  • autoAnimate If we want the slider to aumatically rotate the slider (default false)
  • animationDelay The delay between slide change when autoAnimate is set to true (default 2s)
  • modal Add a black modal behind the slider (default false)
  • modalAlpha The amount of alpha (opacity) for the slider modal (default 0.7)
  • staticElements The static elements that need to be added but not move (default [])
  • onPrePrevCallback The function to call `before` the slider moves to the `previous` slide (default false)
  • onPreNextCallback The function to call `before` the slider moves to the `next` slide (default false)
  • onAfterPrevCallback The function to call `after` the slider moves to the `previous` slide (default false)
  • onAfterNextCallback The function to call `after` the slider moves to the `next` slide (default false)

API Functions

  • createSlider | Creates the slider object and the slides
  • startSlider | Starts the automatic rotation of the slider if autoAnimate is set to true
  • stopSlider | Stops the automatic rotation of slides
  • moveToSlide | Navigate to specific slide index (args: index:Number, animated:Boolean)
  • goToNext | Navigate to the next slide
  • goToPrev | Navigate to the previous slide
  • getCurrentIndex | Receive the current slide index
  • hideSlider | Render the slider not visible (the slider will not be able to receive input events)
  • showSlider | Render the slider visible
*Note: When automatic rotation has started, navigating from the control arrows (next, prev) will stop the auto animation

Please let me know if you come across some bug or have something to contribute

phaseslider's People

Contributors

netgfx avatar

Watchers

Nikolaos Fragos avatar

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.