Giter Club home page Giter Club logo

gsap-player's Introduction

๐Ÿ“ฝ GSAP Player ๐Ÿ“ฝ

A small, customizable YouTube-like player for GSAP (GreenSock) Timelines

Project Demo Page: http://s.codepen.io/sdras/debug/Mpjxxq/

GSAP Player

Usage

The simplest possible use is loading gsap-player.js before the closing body tag (you do not need the CSS file) and implementing:

gsapPlayer({ playerTL: yourtimelinehere });

This will append the player to document.body. The default timeline name is tl, if you're using tl, you only need to call gsapPlayer();

Configurations

Light Theme

Light Theme

GSAP Player will default to a dark theme, but you can also configure a light theme:

gsapPlayer({ light: true });

Position

By default, the GSAP player will be 80% wide and 40px from the bottom of the viewport. You can configure it to be full-width or flush to the bottom, or slightly higher or lower. Bottom must be in a string.

gsapPlayer({
  fullWidth: true,
  bottom: '0'
});

If you use full-width and keep the container defaulted to document.body, you should be sure that you've either used a reset or placed margin: 0 on the body due to strange browser defaults.

Container

By default, the player is instantiated on the body, but if you'd like to change the parent, you can do:

gsapPlayer({ container: '#foo' });

You'll need to put position: relative on that containing element to enclose the player spacially in that div. Just a heads up: this won't put the animation in the container as well (the configuration is kept separate for flexibility.

License

(The MIT License)

Copyright (c)2017 Sarah Drasner @sarah_edo All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

gsap-player's People

Contributors

basthomas avatar sdras avatar shshaw 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gsap-player's Issues

UI Concept

Put this UI concept together a few weeks ago when we initially discussed various features.

Feel free to pull from this where it makes sense:
sockdrawer

  • Top right is a show/hide toggle.
    • This may be different for the way you have the controls floating. Perhaps it would be far-left/right and would toggle down to just the play/pause button?
  • Labels shown on Timeline, clickable to jump straight to the label.
  • Repeat button on the far right
  • Handles for looping only a part of the timeline (as discussed in #5)
  • Skip left/right arrows for jumping between Labels

.svg and .afdesign (Affinity Designer) included:
SockDrawer UI Concept.zip

I only did a dark theme, but it was mainly for layout, icons and functionality concepts.

Functionality

Per our conversations in Slack:

  • Label Support
  • Toggle infinite repeat
  • Show/Hide Player
  • Limit playback to section of timeline
  • Save settings via localStorage

(Just transcribing these for future reference. Not giving you a to-do list!)

Use `new TimelineMax()` for better control

Instead of attaching directly to the user's timeline, create a new TimelineMax instance to allow for attaching to event callbacks and controlling repeats.

Rough idea of how it might used:

var playerTL = new TimelineMax();
playerTL.add( params.playerTL ); // User timeline is added and now has set the whole duration of the new Timeline.

playerTL.eventCallback('onUpdate',function(){
  var p = playerTL.progress();
  slider.value = p * 100;

  var wasPlaying = isPlaying;
  isPlaying = !playerTL.paused();
  if ( wasPlaying !== isPlaying ) {
    TweenMax.set( isPlaying ? play : pause, { opacity: 0 });
    TweenMax.set( isPlaying ? pause : play, { opacity: 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.